babylon.module.d.ts 4.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269
  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/andOrNotEvaluator" {
  4961. /**
  4962. * Class used to evalaute queries containing `and` and `or` operators
  4963. */
  4964. export class AndOrNotEvaluator {
  4965. /**
  4966. * Evaluate a query
  4967. * @param query defines the query to evaluate
  4968. * @param evaluateCallback defines the callback used to filter result
  4969. * @returns true if the query matches
  4970. */
  4971. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  4972. private static _HandleParenthesisContent;
  4973. private static _SimplifyNegation;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/tags" {
  4977. /**
  4978. * Class used to store custom tags
  4979. */
  4980. export class Tags {
  4981. /**
  4982. * Adds support for tags on the given object
  4983. * @param obj defines the object to use
  4984. */
  4985. static EnableFor(obj: any): void;
  4986. /**
  4987. * Removes tags support
  4988. * @param obj defines the object to use
  4989. */
  4990. static DisableFor(obj: any): void;
  4991. /**
  4992. * Gets a boolean indicating if the given object has tags
  4993. * @param obj defines the object to use
  4994. * @returns a boolean
  4995. */
  4996. static HasTags(obj: any): boolean;
  4997. /**
  4998. * Gets the tags available on a given object
  4999. * @param obj defines the object to use
  5000. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5001. * @returns the tags
  5002. */
  5003. static GetTags(obj: any, asString?: boolean): any;
  5004. /**
  5005. * Adds tags to an object
  5006. * @param obj defines the object to use
  5007. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5008. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5009. */
  5010. static AddTagsTo(obj: any, tagsString: string): void;
  5011. /**
  5012. * @hidden
  5013. */
  5014. static _AddTagTo(obj: any, tag: string): void;
  5015. /**
  5016. * Removes specific tags from a specific object
  5017. * @param obj defines the object to use
  5018. * @param tagsString defines the tags to remove
  5019. */
  5020. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5021. /**
  5022. * @hidden
  5023. */
  5024. static _RemoveTagFrom(obj: any, tag: string): void;
  5025. /**
  5026. * Defines if tags hosted on an object match a given query
  5027. * @param obj defines the object to use
  5028. * @param tagsQuery defines the tag query
  5029. * @returns a boolean
  5030. */
  5031. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5032. }
  5033. }
  5034. declare module "babylonjs/Materials/materialDefines" {
  5035. /**
  5036. * Manages the defines for the Material
  5037. */
  5038. export class MaterialDefines {
  5039. private _keys;
  5040. private _isDirty;
  5041. /** @hidden */
  5042. _renderId: number;
  5043. /** @hidden */
  5044. _areLightsDirty: boolean;
  5045. /** @hidden */
  5046. _areAttributesDirty: boolean;
  5047. /** @hidden */
  5048. _areTexturesDirty: boolean;
  5049. /** @hidden */
  5050. _areFresnelDirty: boolean;
  5051. /** @hidden */
  5052. _areMiscDirty: boolean;
  5053. /** @hidden */
  5054. _areImageProcessingDirty: boolean;
  5055. /** @hidden */
  5056. _normals: boolean;
  5057. /** @hidden */
  5058. _uvs: boolean;
  5059. /** @hidden */
  5060. _needNormals: boolean;
  5061. /** @hidden */
  5062. _needUVs: boolean;
  5063. /**
  5064. * Specifies if the material needs to be re-calculated
  5065. */
  5066. readonly isDirty: boolean;
  5067. /**
  5068. * Marks the material to indicate that it has been re-calculated
  5069. */
  5070. markAsProcessed(): void;
  5071. /**
  5072. * Marks the material to indicate that it needs to be re-calculated
  5073. */
  5074. markAsUnprocessed(): void;
  5075. /**
  5076. * Marks the material to indicate all of its defines need to be re-calculated
  5077. */
  5078. markAllAsDirty(): void;
  5079. /**
  5080. * Marks the material to indicate that image processing needs to be re-calculated
  5081. */
  5082. markAsImageProcessingDirty(): void;
  5083. /**
  5084. * Marks the material to indicate the lights need to be re-calculated
  5085. */
  5086. markAsLightDirty(): void;
  5087. /**
  5088. * Marks the attribute state as changed
  5089. */
  5090. markAsAttributesDirty(): void;
  5091. /**
  5092. * Marks the texture state as changed
  5093. */
  5094. markAsTexturesDirty(): void;
  5095. /**
  5096. * Marks the fresnel state as changed
  5097. */
  5098. markAsFresnelDirty(): void;
  5099. /**
  5100. * Marks the misc state as changed
  5101. */
  5102. markAsMiscDirty(): void;
  5103. /**
  5104. * Rebuilds the material defines
  5105. */
  5106. rebuild(): void;
  5107. /**
  5108. * Specifies if two material defines are equal
  5109. * @param other - A material define instance to compare to
  5110. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5111. */
  5112. isEqual(other: MaterialDefines): boolean;
  5113. /**
  5114. * Clones this instance's defines to another instance
  5115. * @param other - material defines to clone values to
  5116. */
  5117. cloneTo(other: MaterialDefines): void;
  5118. /**
  5119. * Resets the material define values
  5120. */
  5121. reset(): void;
  5122. /**
  5123. * Converts the material define values to a string
  5124. * @returns - String of material define information
  5125. */
  5126. toString(): string;
  5127. }
  5128. }
  5129. declare module "babylonjs/Misc/performanceMonitor" {
  5130. /**
  5131. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5132. */
  5133. export class PerformanceMonitor {
  5134. private _enabled;
  5135. private _rollingFrameTime;
  5136. private _lastFrameTimeMs;
  5137. /**
  5138. * constructor
  5139. * @param frameSampleSize The number of samples required to saturate the sliding window
  5140. */
  5141. constructor(frameSampleSize?: number);
  5142. /**
  5143. * Samples current frame
  5144. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5145. */
  5146. sampleFrame(timeMs?: number): void;
  5147. /**
  5148. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5149. */
  5150. readonly averageFrameTime: number;
  5151. /**
  5152. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5153. */
  5154. readonly averageFrameTimeVariance: number;
  5155. /**
  5156. * Returns the frame time of the most recent frame
  5157. */
  5158. readonly instantaneousFrameTime: number;
  5159. /**
  5160. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5161. */
  5162. readonly averageFPS: number;
  5163. /**
  5164. * Returns the average framerate in frames per second using the most recent frame time
  5165. */
  5166. readonly instantaneousFPS: number;
  5167. /**
  5168. * Returns true if enough samples have been taken to completely fill the sliding window
  5169. */
  5170. readonly isSaturated: boolean;
  5171. /**
  5172. * Enables contributions to the sliding window sample set
  5173. */
  5174. enable(): void;
  5175. /**
  5176. * Disables contributions to the sliding window sample set
  5177. * Samples will not be interpolated over the disabled period
  5178. */
  5179. disable(): void;
  5180. /**
  5181. * Returns true if sampling is enabled
  5182. */
  5183. readonly isEnabled: boolean;
  5184. /**
  5185. * Resets performance monitor
  5186. */
  5187. reset(): void;
  5188. }
  5189. /**
  5190. * RollingAverage
  5191. *
  5192. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5193. */
  5194. export class RollingAverage {
  5195. /**
  5196. * Current average
  5197. */
  5198. average: number;
  5199. /**
  5200. * Current variance
  5201. */
  5202. variance: number;
  5203. protected _samples: Array<number>;
  5204. protected _sampleCount: number;
  5205. protected _pos: number;
  5206. protected _m2: number;
  5207. /**
  5208. * constructor
  5209. * @param length The number of samples required to saturate the sliding window
  5210. */
  5211. constructor(length: number);
  5212. /**
  5213. * Adds a sample to the sample set
  5214. * @param v The sample value
  5215. */
  5216. add(v: number): void;
  5217. /**
  5218. * Returns previously added values or null if outside of history or outside the sliding window domain
  5219. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5220. * @return Value previously recorded with add() or null if outside of range
  5221. */
  5222. history(i: number): number;
  5223. /**
  5224. * Returns true if enough samples have been taken to completely fill the sliding window
  5225. * @return true if sample-set saturated
  5226. */
  5227. isSaturated(): boolean;
  5228. /**
  5229. * Resets the rolling average (equivalent to 0 samples taken so far)
  5230. */
  5231. reset(): void;
  5232. /**
  5233. * Wraps a value around the sample range boundaries
  5234. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5235. * @return Wrapped position in sample range
  5236. */
  5237. protected _wrapPosition(i: number): number;
  5238. }
  5239. }
  5240. declare module "babylonjs/Misc/stringDictionary" {
  5241. import { Nullable } from "babylonjs/types";
  5242. /**
  5243. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5244. * The underlying implementation relies on an associative array to ensure the best performances.
  5245. * The value can be anything including 'null' but except 'undefined'
  5246. */
  5247. export class StringDictionary<T> {
  5248. /**
  5249. * This will clear this dictionary and copy the content from the 'source' one.
  5250. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5251. * @param source the dictionary to take the content from and copy to this dictionary
  5252. */
  5253. copyFrom(source: StringDictionary<T>): void;
  5254. /**
  5255. * Get a value based from its key
  5256. * @param key the given key to get the matching value from
  5257. * @return the value if found, otherwise undefined is returned
  5258. */
  5259. get(key: string): T | undefined;
  5260. /**
  5261. * Get a value from its key or add it if it doesn't exist.
  5262. * This method will ensure you that a given key/data will be present in the dictionary.
  5263. * @param key the given key to get the matching value from
  5264. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5265. * The factory will only be invoked if there's no data for the given key.
  5266. * @return the value corresponding to the key.
  5267. */
  5268. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5269. /**
  5270. * Get a value from its key if present in the dictionary otherwise add it
  5271. * @param key the key to get the value from
  5272. * @param val if there's no such key/value pair in the dictionary add it with this value
  5273. * @return the value corresponding to the key
  5274. */
  5275. getOrAdd(key: string, val: T): T;
  5276. /**
  5277. * Check if there's a given key in the dictionary
  5278. * @param key the key to check for
  5279. * @return true if the key is present, false otherwise
  5280. */
  5281. contains(key: string): boolean;
  5282. /**
  5283. * Add a new key and its corresponding value
  5284. * @param key the key to add
  5285. * @param value the value corresponding to the key
  5286. * @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
  5287. */
  5288. add(key: string, value: T): boolean;
  5289. /**
  5290. * Update a specific value associated to a key
  5291. * @param key defines the key to use
  5292. * @param value defines the value to store
  5293. * @returns true if the value was updated (or false if the key was not found)
  5294. */
  5295. set(key: string, value: T): boolean;
  5296. /**
  5297. * Get the element of the given key and remove it from the dictionary
  5298. * @param key defines the key to search
  5299. * @returns the value associated with the key or null if not found
  5300. */
  5301. getAndRemove(key: string): Nullable<T>;
  5302. /**
  5303. * Remove a key/value from the dictionary.
  5304. * @param key the key to remove
  5305. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5306. */
  5307. remove(key: string): boolean;
  5308. /**
  5309. * Clear the whole content of the dictionary
  5310. */
  5311. clear(): void;
  5312. /**
  5313. * Gets the current count
  5314. */
  5315. readonly count: number;
  5316. /**
  5317. * Execute a callback on each key/val of the dictionary.
  5318. * Note that you can remove any element in this dictionary in the callback implementation
  5319. * @param callback the callback to execute on a given key/value pair
  5320. */
  5321. forEach(callback: (key: string, val: T) => void): void;
  5322. /**
  5323. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5324. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5325. * Note that you can remove any element in this dictionary in the callback implementation
  5326. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5327. * @returns the first item
  5328. */
  5329. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5330. private _count;
  5331. private _data;
  5332. }
  5333. }
  5334. declare module "babylonjs/Misc/promise" {
  5335. /**
  5336. * Helper class that provides a small promise polyfill
  5337. */
  5338. export class PromisePolyfill {
  5339. /**
  5340. * Static function used to check if the polyfill is required
  5341. * If this is the case then the function will inject the polyfill to window.Promise
  5342. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5343. */
  5344. static Apply(force?: boolean): void;
  5345. }
  5346. }
  5347. declare module "babylonjs/Meshes/buffer" {
  5348. import { Nullable, DataArray } from "babylonjs/types";
  5349. /**
  5350. * Class used to store data that will be store in GPU memory
  5351. */
  5352. export class Buffer {
  5353. private _engine;
  5354. private _buffer;
  5355. /** @hidden */
  5356. _data: Nullable<DataArray>;
  5357. private _updatable;
  5358. private _instanced;
  5359. /**
  5360. * Gets the byte stride.
  5361. */
  5362. readonly byteStride: number;
  5363. /**
  5364. * Constructor
  5365. * @param engine the engine
  5366. * @param data the data to use for this buffer
  5367. * @param updatable whether the data is updatable
  5368. * @param stride the stride (optional)
  5369. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5370. * @param instanced whether the buffer is instanced (optional)
  5371. * @param useBytes set to true if the stride in in bytes (optional)
  5372. */
  5373. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5374. /**
  5375. * Create a new VertexBuffer based on the current buffer
  5376. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5377. * @param offset defines offset in the buffer (0 by default)
  5378. * @param size defines the size in floats of attributes (position is 3 for instance)
  5379. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5380. * @param instanced defines if the vertex buffer contains indexed data
  5381. * @param useBytes defines if the offset and stride are in bytes
  5382. * @returns the new vertex buffer
  5383. */
  5384. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5385. /**
  5386. * Gets a boolean indicating if the Buffer is updatable?
  5387. * @returns true if the buffer is updatable
  5388. */
  5389. isUpdatable(): boolean;
  5390. /**
  5391. * Gets current buffer's data
  5392. * @returns a DataArray or null
  5393. */
  5394. getData(): Nullable<DataArray>;
  5395. /**
  5396. * Gets underlying native buffer
  5397. * @returns underlying native buffer
  5398. */
  5399. getBuffer(): Nullable<WebGLBuffer>;
  5400. /**
  5401. * Gets the stride in float32 units (i.e. byte stride / 4).
  5402. * May not be an integer if the byte stride is not divisible by 4.
  5403. * DEPRECATED. Use byteStride instead.
  5404. * @returns the stride in float32 units
  5405. */
  5406. getStrideSize(): number;
  5407. /**
  5408. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5409. * @param data defines the data to store
  5410. */
  5411. create(data?: Nullable<DataArray>): void;
  5412. /** @hidden */
  5413. _rebuild(): void;
  5414. /**
  5415. * Update current buffer data
  5416. * @param data defines the data to store
  5417. */
  5418. update(data: DataArray): void;
  5419. /**
  5420. * Updates the data directly.
  5421. * @param data the new data
  5422. * @param offset the new offset
  5423. * @param vertexCount the vertex count (optional)
  5424. * @param useBytes set to true if the offset is in bytes
  5425. */
  5426. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5427. /**
  5428. * Release all resources
  5429. */
  5430. dispose(): void;
  5431. }
  5432. /**
  5433. * Specialized buffer used to store vertex data
  5434. */
  5435. export class VertexBuffer {
  5436. /** @hidden */
  5437. _buffer: Buffer;
  5438. private _kind;
  5439. private _size;
  5440. private _ownsBuffer;
  5441. private _instanced;
  5442. private _instanceDivisor;
  5443. /**
  5444. * The byte type.
  5445. */
  5446. static readonly BYTE: number;
  5447. /**
  5448. * The unsigned byte type.
  5449. */
  5450. static readonly UNSIGNED_BYTE: number;
  5451. /**
  5452. * The short type.
  5453. */
  5454. static readonly SHORT: number;
  5455. /**
  5456. * The unsigned short type.
  5457. */
  5458. static readonly UNSIGNED_SHORT: number;
  5459. /**
  5460. * The integer type.
  5461. */
  5462. static readonly INT: number;
  5463. /**
  5464. * The unsigned integer type.
  5465. */
  5466. static readonly UNSIGNED_INT: number;
  5467. /**
  5468. * The float type.
  5469. */
  5470. static readonly FLOAT: number;
  5471. /**
  5472. * Gets or sets the instance divisor when in instanced mode
  5473. */
  5474. instanceDivisor: number;
  5475. /**
  5476. * Gets the byte stride.
  5477. */
  5478. readonly byteStride: number;
  5479. /**
  5480. * Gets the byte offset.
  5481. */
  5482. readonly byteOffset: number;
  5483. /**
  5484. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5485. */
  5486. readonly normalized: boolean;
  5487. /**
  5488. * Gets the data type of each component in the array.
  5489. */
  5490. readonly type: number;
  5491. /**
  5492. * Constructor
  5493. * @param engine the engine
  5494. * @param data the data to use for this vertex buffer
  5495. * @param kind the vertex buffer kind
  5496. * @param updatable whether the data is updatable
  5497. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5498. * @param stride the stride (optional)
  5499. * @param instanced whether the buffer is instanced (optional)
  5500. * @param offset the offset of the data (optional)
  5501. * @param size the number of components (optional)
  5502. * @param type the type of the component (optional)
  5503. * @param normalized whether the data contains normalized data (optional)
  5504. * @param useBytes set to true if stride and offset are in bytes (optional)
  5505. */
  5506. 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);
  5507. /** @hidden */
  5508. _rebuild(): void;
  5509. /**
  5510. * Returns the kind of the VertexBuffer (string)
  5511. * @returns a string
  5512. */
  5513. getKind(): string;
  5514. /**
  5515. * Gets a boolean indicating if the VertexBuffer is updatable?
  5516. * @returns true if the buffer is updatable
  5517. */
  5518. isUpdatable(): boolean;
  5519. /**
  5520. * Gets current buffer's data
  5521. * @returns a DataArray or null
  5522. */
  5523. getData(): Nullable<DataArray>;
  5524. /**
  5525. * Gets underlying native buffer
  5526. * @returns underlying native buffer
  5527. */
  5528. getBuffer(): Nullable<WebGLBuffer>;
  5529. /**
  5530. * Gets the stride in float32 units (i.e. byte stride / 4).
  5531. * May not be an integer if the byte stride is not divisible by 4.
  5532. * DEPRECATED. Use byteStride instead.
  5533. * @returns the stride in float32 units
  5534. */
  5535. getStrideSize(): number;
  5536. /**
  5537. * Returns the offset as a multiple of the type byte length.
  5538. * DEPRECATED. Use byteOffset instead.
  5539. * @returns the offset in bytes
  5540. */
  5541. getOffset(): number;
  5542. /**
  5543. * Returns the number of components per vertex attribute (integer)
  5544. * @returns the size in float
  5545. */
  5546. getSize(): number;
  5547. /**
  5548. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5549. * @returns true if this buffer is instanced
  5550. */
  5551. getIsInstanced(): boolean;
  5552. /**
  5553. * Returns the instancing divisor, zero for non-instanced (integer).
  5554. * @returns a number
  5555. */
  5556. getInstanceDivisor(): number;
  5557. /**
  5558. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5559. * @param data defines the data to store
  5560. */
  5561. create(data?: DataArray): void;
  5562. /**
  5563. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5564. * This function will create a new buffer if the current one is not updatable
  5565. * @param data defines the data to store
  5566. */
  5567. update(data: DataArray): void;
  5568. /**
  5569. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5570. * Returns the directly updated WebGLBuffer.
  5571. * @param data the new data
  5572. * @param offset the new offset
  5573. * @param useBytes set to true if the offset is in bytes
  5574. */
  5575. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5576. /**
  5577. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5578. */
  5579. dispose(): void;
  5580. /**
  5581. * Enumerates each value of this vertex buffer as numbers.
  5582. * @param count the number of values to enumerate
  5583. * @param callback the callback function called for each value
  5584. */
  5585. forEach(count: number, callback: (value: number, index: number) => void): void;
  5586. /**
  5587. * Positions
  5588. */
  5589. static readonly PositionKind: string;
  5590. /**
  5591. * Normals
  5592. */
  5593. static readonly NormalKind: string;
  5594. /**
  5595. * Tangents
  5596. */
  5597. static readonly TangentKind: string;
  5598. /**
  5599. * Texture coordinates
  5600. */
  5601. static readonly UVKind: string;
  5602. /**
  5603. * Texture coordinates 2
  5604. */
  5605. static readonly UV2Kind: string;
  5606. /**
  5607. * Texture coordinates 3
  5608. */
  5609. static readonly UV3Kind: string;
  5610. /**
  5611. * Texture coordinates 4
  5612. */
  5613. static readonly UV4Kind: string;
  5614. /**
  5615. * Texture coordinates 5
  5616. */
  5617. static readonly UV5Kind: string;
  5618. /**
  5619. * Texture coordinates 6
  5620. */
  5621. static readonly UV6Kind: string;
  5622. /**
  5623. * Colors
  5624. */
  5625. static readonly ColorKind: string;
  5626. /**
  5627. * Matrix indices (for bones)
  5628. */
  5629. static readonly MatricesIndicesKind: string;
  5630. /**
  5631. * Matrix weights (for bones)
  5632. */
  5633. static readonly MatricesWeightsKind: string;
  5634. /**
  5635. * Additional matrix indices (for bones)
  5636. */
  5637. static readonly MatricesIndicesExtraKind: string;
  5638. /**
  5639. * Additional matrix weights (for bones)
  5640. */
  5641. static readonly MatricesWeightsExtraKind: string;
  5642. /**
  5643. * Deduces the stride given a kind.
  5644. * @param kind The kind string to deduce
  5645. * @returns The deduced stride
  5646. */
  5647. static DeduceStride(kind: string): number;
  5648. /**
  5649. * Gets the byte length of the given type.
  5650. * @param type the type
  5651. * @returns the number of bytes
  5652. */
  5653. static GetTypeByteLength(type: number): number;
  5654. /**
  5655. * Enumerates each value of the given parameters as numbers.
  5656. * @param data the data to enumerate
  5657. * @param byteOffset the byte offset of the data
  5658. * @param byteStride the byte stride of the data
  5659. * @param componentCount the number of components per element
  5660. * @param componentType the type of the component
  5661. * @param count the total number of components
  5662. * @param normalized whether the data is normalized
  5663. * @param callback the callback function called for each value
  5664. */
  5665. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5666. private static _GetFloatValue;
  5667. }
  5668. }
  5669. declare module "babylonjs/Maths/sphericalPolynomial" {
  5670. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5671. /**
  5672. * Class representing spherical polynomial coefficients to the 3rd degree
  5673. */
  5674. export class SphericalPolynomial {
  5675. /**
  5676. * The x coefficients of the spherical polynomial
  5677. */
  5678. x: Vector3;
  5679. /**
  5680. * The y coefficients of the spherical polynomial
  5681. */
  5682. y: Vector3;
  5683. /**
  5684. * The z coefficients of the spherical polynomial
  5685. */
  5686. z: Vector3;
  5687. /**
  5688. * The xx coefficients of the spherical polynomial
  5689. */
  5690. xx: Vector3;
  5691. /**
  5692. * The yy coefficients of the spherical polynomial
  5693. */
  5694. yy: Vector3;
  5695. /**
  5696. * The zz coefficients of the spherical polynomial
  5697. */
  5698. zz: Vector3;
  5699. /**
  5700. * The xy coefficients of the spherical polynomial
  5701. */
  5702. xy: Vector3;
  5703. /**
  5704. * The yz coefficients of the spherical polynomial
  5705. */
  5706. yz: Vector3;
  5707. /**
  5708. * The zx coefficients of the spherical polynomial
  5709. */
  5710. zx: Vector3;
  5711. /**
  5712. * Adds an ambient color to the spherical polynomial
  5713. * @param color the color to add
  5714. */
  5715. addAmbient(color: Color3): void;
  5716. /**
  5717. * Scales the spherical polynomial by the given amount
  5718. * @param scale the amount to scale
  5719. */
  5720. scale(scale: number): void;
  5721. /**
  5722. * Gets the spherical polynomial from harmonics
  5723. * @param harmonics the spherical harmonics
  5724. * @returns the spherical polynomial
  5725. */
  5726. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5727. /**
  5728. * Constructs a spherical polynomial from an array.
  5729. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5730. * @returns the spherical polynomial
  5731. */
  5732. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5733. }
  5734. /**
  5735. * Class representing spherical harmonics coefficients to the 3rd degree
  5736. */
  5737. export class SphericalHarmonics {
  5738. /**
  5739. * The l0,0 coefficients of the spherical harmonics
  5740. */
  5741. l00: Vector3;
  5742. /**
  5743. * The l1,-1 coefficients of the spherical harmonics
  5744. */
  5745. l1_1: Vector3;
  5746. /**
  5747. * The l1,0 coefficients of the spherical harmonics
  5748. */
  5749. l10: Vector3;
  5750. /**
  5751. * The l1,1 coefficients of the spherical harmonics
  5752. */
  5753. l11: Vector3;
  5754. /**
  5755. * The l2,-2 coefficients of the spherical harmonics
  5756. */
  5757. l2_2: Vector3;
  5758. /**
  5759. * The l2,-1 coefficients of the spherical harmonics
  5760. */
  5761. l2_1: Vector3;
  5762. /**
  5763. * The l2,0 coefficients of the spherical harmonics
  5764. */
  5765. l20: Vector3;
  5766. /**
  5767. * The l2,1 coefficients of the spherical harmonics
  5768. */
  5769. l21: Vector3;
  5770. /**
  5771. * The l2,2 coefficients of the spherical harmonics
  5772. */
  5773. lL22: Vector3;
  5774. /**
  5775. * Adds a light to the spherical harmonics
  5776. * @param direction the direction of the light
  5777. * @param color the color of the light
  5778. * @param deltaSolidAngle the delta solid angle of the light
  5779. */
  5780. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5781. /**
  5782. * Scales the spherical harmonics by the given amount
  5783. * @param scale the amount to scale
  5784. */
  5785. scale(scale: number): void;
  5786. /**
  5787. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5788. *
  5789. * ```
  5790. * E_lm = A_l * L_lm
  5791. * ```
  5792. *
  5793. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5794. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5795. * the scaling factors are given in equation 9.
  5796. */
  5797. convertIncidentRadianceToIrradiance(): void;
  5798. /**
  5799. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5800. *
  5801. * ```
  5802. * L = (1/pi) * E * rho
  5803. * ```
  5804. *
  5805. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5806. */
  5807. convertIrradianceToLambertianRadiance(): void;
  5808. /**
  5809. * Gets the spherical harmonics from polynomial
  5810. * @param polynomial the spherical polynomial
  5811. * @returns the spherical harmonics
  5812. */
  5813. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5814. /**
  5815. * Constructs a spherical harmonics from an array.
  5816. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5817. * @returns the spherical harmonics
  5818. */
  5819. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5820. }
  5821. }
  5822. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5823. import { Nullable } from "babylonjs/types";
  5824. /**
  5825. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5826. */
  5827. export interface CubeMapInfo {
  5828. /**
  5829. * The pixel array for the front face.
  5830. * This is stored in format, left to right, up to down format.
  5831. */
  5832. front: Nullable<ArrayBufferView>;
  5833. /**
  5834. * The pixel array for the back face.
  5835. * This is stored in format, left to right, up to down format.
  5836. */
  5837. back: Nullable<ArrayBufferView>;
  5838. /**
  5839. * The pixel array for the left face.
  5840. * This is stored in format, left to right, up to down format.
  5841. */
  5842. left: Nullable<ArrayBufferView>;
  5843. /**
  5844. * The pixel array for the right face.
  5845. * This is stored in format, left to right, up to down format.
  5846. */
  5847. right: Nullable<ArrayBufferView>;
  5848. /**
  5849. * The pixel array for the up face.
  5850. * This is stored in format, left to right, up to down format.
  5851. */
  5852. up: Nullable<ArrayBufferView>;
  5853. /**
  5854. * The pixel array for the down face.
  5855. * This is stored in format, left to right, up to down format.
  5856. */
  5857. down: Nullable<ArrayBufferView>;
  5858. /**
  5859. * The size of the cubemap stored.
  5860. *
  5861. * Each faces will be size * size pixels.
  5862. */
  5863. size: number;
  5864. /**
  5865. * The format of the texture.
  5866. *
  5867. * RGBA, RGB.
  5868. */
  5869. format: number;
  5870. /**
  5871. * The type of the texture data.
  5872. *
  5873. * UNSIGNED_INT, FLOAT.
  5874. */
  5875. type: number;
  5876. /**
  5877. * Specifies whether the texture is in gamma space.
  5878. */
  5879. gammaSpace: boolean;
  5880. }
  5881. /**
  5882. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5883. */
  5884. export class PanoramaToCubeMapTools {
  5885. private static FACE_FRONT;
  5886. private static FACE_BACK;
  5887. private static FACE_RIGHT;
  5888. private static FACE_LEFT;
  5889. private static FACE_DOWN;
  5890. private static FACE_UP;
  5891. /**
  5892. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5893. *
  5894. * @param float32Array The source data.
  5895. * @param inputWidth The width of the input panorama.
  5896. * @param inputHeight The height of the input panorama.
  5897. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5898. * @return The cubemap data
  5899. */
  5900. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5901. private static CreateCubemapTexture;
  5902. private static CalcProjectionSpherical;
  5903. }
  5904. }
  5905. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  5906. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  5907. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  5908. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  5909. /**
  5910. * Helper class dealing with the extraction of spherical polynomial dataArray
  5911. * from a cube map.
  5912. */
  5913. export class CubeMapToSphericalPolynomialTools {
  5914. private static FileFaces;
  5915. /**
  5916. * Converts a texture to the according Spherical Polynomial data.
  5917. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5918. *
  5919. * @param texture The texture to extract the information from.
  5920. * @return The Spherical Polynomial data.
  5921. */
  5922. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5923. /**
  5924. * Converts a cubemap to the according Spherical Polynomial data.
  5925. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5926. *
  5927. * @param cubeInfo The Cube map to extract the information from.
  5928. * @return The Spherical Polynomial data.
  5929. */
  5930. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5931. }
  5932. }
  5933. declare module "babylonjs/Engines/engineStore" {
  5934. import { Nullable } from "babylonjs/types";
  5935. import { Engine } from "babylonjs/Engines/engine";
  5936. import { Scene } from "babylonjs/scene";
  5937. /**
  5938. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5939. * during the life time of the application.
  5940. */
  5941. export class EngineStore {
  5942. /** Gets the list of created engines */
  5943. static Instances: import("babylonjs/Engines/engine").Engine[];
  5944. /**
  5945. * Gets the latest created engine
  5946. */
  5947. static readonly LastCreatedEngine: Nullable<Engine>;
  5948. /**
  5949. * Gets the latest created scene
  5950. */
  5951. static readonly LastCreatedScene: Nullable<Scene>;
  5952. }
  5953. }
  5954. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  5955. /**
  5956. * Define options used to create a render target texture
  5957. */
  5958. export class RenderTargetCreationOptions {
  5959. /**
  5960. * Specifies is mipmaps must be generated
  5961. */
  5962. generateMipMaps?: boolean;
  5963. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5964. generateDepthBuffer?: boolean;
  5965. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5966. generateStencilBuffer?: boolean;
  5967. /** Defines texture type (int by default) */
  5968. type?: number;
  5969. /** Defines sampling mode (trilinear by default) */
  5970. samplingMode?: number;
  5971. /** Defines format (RGBA by default) */
  5972. format?: number;
  5973. }
  5974. }
  5975. declare module "babylonjs/States/alphaCullingState" {
  5976. /**
  5977. * @hidden
  5978. **/
  5979. export class _AlphaState {
  5980. private _isAlphaBlendDirty;
  5981. private _isBlendFunctionParametersDirty;
  5982. private _isBlendEquationParametersDirty;
  5983. private _isBlendConstantsDirty;
  5984. private _alphaBlend;
  5985. private _blendFunctionParameters;
  5986. private _blendEquationParameters;
  5987. private _blendConstants;
  5988. /**
  5989. * Initializes the state.
  5990. */
  5991. constructor();
  5992. readonly isDirty: boolean;
  5993. alphaBlend: boolean;
  5994. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5995. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5996. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5997. reset(): void;
  5998. apply(gl: WebGLRenderingContext): void;
  5999. }
  6000. }
  6001. declare module "babylonjs/States/depthCullingState" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * @hidden
  6005. **/
  6006. export class _DepthCullingState {
  6007. private _isDepthTestDirty;
  6008. private _isDepthMaskDirty;
  6009. private _isDepthFuncDirty;
  6010. private _isCullFaceDirty;
  6011. private _isCullDirty;
  6012. private _isZOffsetDirty;
  6013. private _isFrontFaceDirty;
  6014. private _depthTest;
  6015. private _depthMask;
  6016. private _depthFunc;
  6017. private _cull;
  6018. private _cullFace;
  6019. private _zOffset;
  6020. private _frontFace;
  6021. /**
  6022. * Initializes the state.
  6023. */
  6024. constructor();
  6025. readonly isDirty: boolean;
  6026. zOffset: number;
  6027. cullFace: Nullable<number>;
  6028. cull: Nullable<boolean>;
  6029. depthFunc: Nullable<number>;
  6030. depthMask: boolean;
  6031. depthTest: boolean;
  6032. frontFace: Nullable<number>;
  6033. reset(): void;
  6034. apply(gl: WebGLRenderingContext): void;
  6035. }
  6036. }
  6037. declare module "babylonjs/States/stencilState" {
  6038. /**
  6039. * @hidden
  6040. **/
  6041. export class _StencilState {
  6042. /** 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 */
  6043. static readonly ALWAYS: number;
  6044. /** Passed to stencilOperation to specify that stencil value must be kept */
  6045. static readonly KEEP: number;
  6046. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6047. static readonly REPLACE: number;
  6048. private _isStencilTestDirty;
  6049. private _isStencilMaskDirty;
  6050. private _isStencilFuncDirty;
  6051. private _isStencilOpDirty;
  6052. private _stencilTest;
  6053. private _stencilMask;
  6054. private _stencilFunc;
  6055. private _stencilFuncRef;
  6056. private _stencilFuncMask;
  6057. private _stencilOpStencilFail;
  6058. private _stencilOpDepthFail;
  6059. private _stencilOpStencilDepthPass;
  6060. readonly isDirty: boolean;
  6061. stencilFunc: number;
  6062. stencilFuncRef: number;
  6063. stencilFuncMask: number;
  6064. stencilOpStencilFail: number;
  6065. stencilOpDepthFail: number;
  6066. stencilOpStencilDepthPass: number;
  6067. stencilMask: number;
  6068. stencilTest: boolean;
  6069. constructor();
  6070. reset(): void;
  6071. apply(gl: WebGLRenderingContext): void;
  6072. }
  6073. }
  6074. declare module "babylonjs/States/index" {
  6075. export * from "babylonjs/States/alphaCullingState";
  6076. export * from "babylonjs/States/depthCullingState";
  6077. export * from "babylonjs/States/stencilState";
  6078. }
  6079. declare module "babylonjs/Instrumentation/timeToken" {
  6080. import { Nullable } from "babylonjs/types";
  6081. /**
  6082. * @hidden
  6083. **/
  6084. export class _TimeToken {
  6085. _startTimeQuery: Nullable<WebGLQuery>;
  6086. _endTimeQuery: Nullable<WebGLQuery>;
  6087. _timeElapsedQuery: Nullable<WebGLQuery>;
  6088. _timeElapsedQueryEnded: boolean;
  6089. }
  6090. }
  6091. declare module "babylonjs/Materials/Textures/internalTextureTracker" {
  6092. import { Nullable } from "babylonjs/types";
  6093. /**
  6094. * Internal interface used to track InternalTexture already bound to the GL context
  6095. */
  6096. export interface IInternalTextureTracker {
  6097. /**
  6098. * Gets or set the previous tracker in the list
  6099. */
  6100. previous: Nullable<IInternalTextureTracker>;
  6101. /**
  6102. * Gets or set the next tracker in the list
  6103. */
  6104. next: Nullable<IInternalTextureTracker>;
  6105. }
  6106. /**
  6107. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6108. */
  6109. export class DummyInternalTextureTracker {
  6110. /**
  6111. * Gets or set the previous tracker in the list
  6112. */
  6113. previous: Nullable<IInternalTextureTracker>;
  6114. /**
  6115. * Gets or set the next tracker in the list
  6116. */
  6117. next: Nullable<IInternalTextureTracker>;
  6118. }
  6119. }
  6120. declare module "babylonjs/Materials/Textures/internalTexture" {
  6121. import { Observable } from "babylonjs/Misc/observable";
  6122. import { Nullable, int } from "babylonjs/types";
  6123. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6124. import { IInternalTextureTracker } from "babylonjs/Materials/Textures/internalTextureTracker";
  6125. import { Engine } from "babylonjs/Engines/engine";
  6126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6127. /**
  6128. * Class used to store data associated with WebGL texture data for the engine
  6129. * This class should not be used directly
  6130. */
  6131. export class InternalTexture implements IInternalTextureTracker {
  6132. /** hidden */
  6133. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6134. /**
  6135. * The source of the texture data is unknown
  6136. */
  6137. static DATASOURCE_UNKNOWN: number;
  6138. /**
  6139. * Texture data comes from an URL
  6140. */
  6141. static DATASOURCE_URL: number;
  6142. /**
  6143. * Texture data is only used for temporary storage
  6144. */
  6145. static DATASOURCE_TEMP: number;
  6146. /**
  6147. * Texture data comes from raw data (ArrayBuffer)
  6148. */
  6149. static DATASOURCE_RAW: number;
  6150. /**
  6151. * Texture content is dynamic (video or dynamic texture)
  6152. */
  6153. static DATASOURCE_DYNAMIC: number;
  6154. /**
  6155. * Texture content is generated by rendering to it
  6156. */
  6157. static DATASOURCE_RENDERTARGET: number;
  6158. /**
  6159. * Texture content is part of a multi render target process
  6160. */
  6161. static DATASOURCE_MULTIRENDERTARGET: number;
  6162. /**
  6163. * Texture data comes from a cube data file
  6164. */
  6165. static DATASOURCE_CUBE: number;
  6166. /**
  6167. * Texture data comes from a raw cube data
  6168. */
  6169. static DATASOURCE_CUBERAW: number;
  6170. /**
  6171. * Texture data come from a prefiltered cube data file
  6172. */
  6173. static DATASOURCE_CUBEPREFILTERED: number;
  6174. /**
  6175. * Texture content is raw 3D data
  6176. */
  6177. static DATASOURCE_RAW3D: number;
  6178. /**
  6179. * Texture content is a depth texture
  6180. */
  6181. static DATASOURCE_DEPTHTEXTURE: number;
  6182. /**
  6183. * Texture data comes from a raw cube data encoded with RGBD
  6184. */
  6185. static DATASOURCE_CUBERAW_RGBD: number;
  6186. /**
  6187. * Defines if the texture is ready
  6188. */
  6189. isReady: boolean;
  6190. /**
  6191. * Defines if the texture is a cube texture
  6192. */
  6193. isCube: boolean;
  6194. /**
  6195. * Defines if the texture contains 3D data
  6196. */
  6197. is3D: boolean;
  6198. /**
  6199. * Gets the URL used to load this texture
  6200. */
  6201. url: string;
  6202. /**
  6203. * Gets the sampling mode of the texture
  6204. */
  6205. samplingMode: number;
  6206. /**
  6207. * Gets a boolean indicating if the texture needs mipmaps generation
  6208. */
  6209. generateMipMaps: boolean;
  6210. /**
  6211. * Gets the number of samples used by the texture (WebGL2+ only)
  6212. */
  6213. samples: number;
  6214. /**
  6215. * Gets the type of the texture (int, float...)
  6216. */
  6217. type: number;
  6218. /**
  6219. * Gets the format of the texture (RGB, RGBA...)
  6220. */
  6221. format: number;
  6222. /**
  6223. * Observable called when the texture is loaded
  6224. */
  6225. onLoadedObservable: Observable<InternalTexture>;
  6226. /**
  6227. * Gets the width of the texture
  6228. */
  6229. width: number;
  6230. /**
  6231. * Gets the height of the texture
  6232. */
  6233. height: number;
  6234. /**
  6235. * Gets the depth of the texture
  6236. */
  6237. depth: number;
  6238. /**
  6239. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6240. */
  6241. baseWidth: number;
  6242. /**
  6243. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6244. */
  6245. baseHeight: number;
  6246. /**
  6247. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6248. */
  6249. baseDepth: number;
  6250. /**
  6251. * Gets a boolean indicating if the texture is inverted on Y axis
  6252. */
  6253. invertY: boolean;
  6254. /**
  6255. * Gets or set the previous tracker in the list
  6256. */
  6257. previous: Nullable<IInternalTextureTracker>;
  6258. /**
  6259. * Gets or set the next tracker in the list
  6260. */
  6261. next: Nullable<IInternalTextureTracker>;
  6262. /** @hidden */
  6263. _invertVScale: boolean;
  6264. /** @hidden */
  6265. _initialSlot: number;
  6266. /** @hidden */
  6267. _designatedSlot: number;
  6268. /** @hidden */
  6269. _dataSource: number;
  6270. /** @hidden */
  6271. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6272. /** @hidden */
  6273. _bufferView: Nullable<ArrayBufferView>;
  6274. /** @hidden */
  6275. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6276. /** @hidden */
  6277. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6278. /** @hidden */
  6279. _size: number;
  6280. /** @hidden */
  6281. _extension: string;
  6282. /** @hidden */
  6283. _files: Nullable<string[]>;
  6284. /** @hidden */
  6285. _workingCanvas: HTMLCanvasElement;
  6286. /** @hidden */
  6287. _workingContext: CanvasRenderingContext2D;
  6288. /** @hidden */
  6289. _framebuffer: Nullable<WebGLFramebuffer>;
  6290. /** @hidden */
  6291. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6292. /** @hidden */
  6293. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6294. /** @hidden */
  6295. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6296. /** @hidden */
  6297. _attachments: Nullable<number[]>;
  6298. /** @hidden */
  6299. _cachedCoordinatesMode: Nullable<number>;
  6300. /** @hidden */
  6301. _cachedWrapU: Nullable<number>;
  6302. /** @hidden */
  6303. _cachedWrapV: Nullable<number>;
  6304. /** @hidden */
  6305. _cachedWrapR: Nullable<number>;
  6306. /** @hidden */
  6307. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6308. /** @hidden */
  6309. _isDisabled: boolean;
  6310. /** @hidden */
  6311. _compression: Nullable<string>;
  6312. /** @hidden */
  6313. _generateStencilBuffer: boolean;
  6314. /** @hidden */
  6315. _generateDepthBuffer: boolean;
  6316. /** @hidden */
  6317. _comparisonFunction: number;
  6318. /** @hidden */
  6319. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6320. /** @hidden */
  6321. _lodGenerationScale: number;
  6322. /** @hidden */
  6323. _lodGenerationOffset: number;
  6324. /** @hidden */
  6325. _lodTextureHigh: BaseTexture;
  6326. /** @hidden */
  6327. _lodTextureMid: BaseTexture;
  6328. /** @hidden */
  6329. _lodTextureLow: BaseTexture;
  6330. /** @hidden */
  6331. _isRGBD: boolean;
  6332. /** @hidden */
  6333. _webGLTexture: Nullable<WebGLTexture>;
  6334. /** @hidden */
  6335. _references: number;
  6336. private _engine;
  6337. /**
  6338. * Gets the Engine the texture belongs to.
  6339. * @returns The babylon engine
  6340. */
  6341. getEngine(): Engine;
  6342. /**
  6343. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6344. */
  6345. readonly dataSource: number;
  6346. /**
  6347. * Creates a new InternalTexture
  6348. * @param engine defines the engine to use
  6349. * @param dataSource defines the type of data that will be used
  6350. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6351. */
  6352. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6353. /**
  6354. * Increments the number of references (ie. the number of Texture that point to it)
  6355. */
  6356. incrementReferences(): void;
  6357. /**
  6358. * Change the size of the texture (not the size of the content)
  6359. * @param width defines the new width
  6360. * @param height defines the new height
  6361. * @param depth defines the new depth (1 by default)
  6362. */
  6363. updateSize(width: int, height: int, depth?: int): void;
  6364. /** @hidden */
  6365. _rebuild(): void;
  6366. /** @hidden */
  6367. _swapAndDie(target: InternalTexture): void;
  6368. /**
  6369. * Dispose the current allocated resources
  6370. */
  6371. dispose(): void;
  6372. }
  6373. }
  6374. declare module "babylonjs/Animations/easing" {
  6375. /**
  6376. * This represents the main contract an easing function should follow.
  6377. * Easing functions are used throughout the animation system.
  6378. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6379. */
  6380. export interface IEasingFunction {
  6381. /**
  6382. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6383. * of the easing function.
  6384. * The link below provides some of the most common examples of easing functions.
  6385. * @see https://easings.net/
  6386. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6387. * @returns the corresponding value on the curve defined by the easing function
  6388. */
  6389. ease(gradient: number): number;
  6390. }
  6391. /**
  6392. * Base class used for every default easing function.
  6393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6394. */
  6395. export class EasingFunction implements IEasingFunction {
  6396. /**
  6397. * Interpolation follows the mathematical formula associated with the easing function.
  6398. */
  6399. static readonly EASINGMODE_EASEIN: number;
  6400. /**
  6401. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6402. */
  6403. static readonly EASINGMODE_EASEOUT: number;
  6404. /**
  6405. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6406. */
  6407. static readonly EASINGMODE_EASEINOUT: number;
  6408. private _easingMode;
  6409. /**
  6410. * Sets the easing mode of the current function.
  6411. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6412. */
  6413. setEasingMode(easingMode: number): void;
  6414. /**
  6415. * Gets the current easing mode.
  6416. * @returns the easing mode
  6417. */
  6418. getEasingMode(): number;
  6419. /**
  6420. * @hidden
  6421. */
  6422. easeInCore(gradient: number): number;
  6423. /**
  6424. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6425. * of the easing function.
  6426. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6427. * @returns the corresponding value on the curve defined by the easing function
  6428. */
  6429. ease(gradient: number): number;
  6430. }
  6431. /**
  6432. * Easing function with a circle shape (see link below).
  6433. * @see https://easings.net/#easeInCirc
  6434. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6435. */
  6436. export class CircleEase extends EasingFunction implements IEasingFunction {
  6437. /** @hidden */
  6438. easeInCore(gradient: number): number;
  6439. }
  6440. /**
  6441. * Easing function with a ease back shape (see link below).
  6442. * @see https://easings.net/#easeInBack
  6443. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6444. */
  6445. export class BackEase extends EasingFunction implements IEasingFunction {
  6446. /** Defines the amplitude of the function */
  6447. amplitude: number;
  6448. /**
  6449. * Instantiates a back ease easing
  6450. * @see https://easings.net/#easeInBack
  6451. * @param amplitude Defines the amplitude of the function
  6452. */
  6453. constructor(
  6454. /** Defines the amplitude of the function */
  6455. amplitude?: number);
  6456. /** @hidden */
  6457. easeInCore(gradient: number): number;
  6458. }
  6459. /**
  6460. * Easing function with a bouncing shape (see link below).
  6461. * @see https://easings.net/#easeInBounce
  6462. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6463. */
  6464. export class BounceEase extends EasingFunction implements IEasingFunction {
  6465. /** Defines the number of bounces */
  6466. bounces: number;
  6467. /** Defines the amplitude of the bounce */
  6468. bounciness: number;
  6469. /**
  6470. * Instantiates a bounce easing
  6471. * @see https://easings.net/#easeInBounce
  6472. * @param bounces Defines the number of bounces
  6473. * @param bounciness Defines the amplitude of the bounce
  6474. */
  6475. constructor(
  6476. /** Defines the number of bounces */
  6477. bounces?: number,
  6478. /** Defines the amplitude of the bounce */
  6479. bounciness?: number);
  6480. /** @hidden */
  6481. easeInCore(gradient: number): number;
  6482. }
  6483. /**
  6484. * Easing function with a power of 3 shape (see link below).
  6485. * @see https://easings.net/#easeInCubic
  6486. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6487. */
  6488. export class CubicEase extends EasingFunction implements IEasingFunction {
  6489. /** @hidden */
  6490. easeInCore(gradient: number): number;
  6491. }
  6492. /**
  6493. * Easing function with an elastic shape (see link below).
  6494. * @see https://easings.net/#easeInElastic
  6495. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6496. */
  6497. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6498. /** Defines the number of oscillations*/
  6499. oscillations: number;
  6500. /** Defines the amplitude of the oscillations*/
  6501. springiness: number;
  6502. /**
  6503. * Instantiates an elastic easing function
  6504. * @see https://easings.net/#easeInElastic
  6505. * @param oscillations Defines the number of oscillations
  6506. * @param springiness Defines the amplitude of the oscillations
  6507. */
  6508. constructor(
  6509. /** Defines the number of oscillations*/
  6510. oscillations?: number,
  6511. /** Defines the amplitude of the oscillations*/
  6512. springiness?: number);
  6513. /** @hidden */
  6514. easeInCore(gradient: number): number;
  6515. }
  6516. /**
  6517. * Easing function with an exponential shape (see link below).
  6518. * @see https://easings.net/#easeInExpo
  6519. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6520. */
  6521. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6522. /** Defines the exponent of the function */
  6523. exponent: number;
  6524. /**
  6525. * Instantiates an exponential easing function
  6526. * @see https://easings.net/#easeInExpo
  6527. * @param exponent Defines the exponent of the function
  6528. */
  6529. constructor(
  6530. /** Defines the exponent of the function */
  6531. exponent?: number);
  6532. /** @hidden */
  6533. easeInCore(gradient: number): number;
  6534. }
  6535. /**
  6536. * Easing function with a power shape (see link below).
  6537. * @see https://easings.net/#easeInQuad
  6538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6539. */
  6540. export class PowerEase extends EasingFunction implements IEasingFunction {
  6541. /** Defines the power of the function */
  6542. power: number;
  6543. /**
  6544. * Instantiates an power base easing function
  6545. * @see https://easings.net/#easeInQuad
  6546. * @param power Defines the power of the function
  6547. */
  6548. constructor(
  6549. /** Defines the power of the function */
  6550. power?: number);
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with a power of 2 shape (see link below).
  6556. * @see https://easings.net/#easeInQuad
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6560. /** @hidden */
  6561. easeInCore(gradient: number): number;
  6562. }
  6563. /**
  6564. * Easing function with a power of 4 shape (see link below).
  6565. * @see https://easings.net/#easeInQuart
  6566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6567. */
  6568. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6569. /** @hidden */
  6570. easeInCore(gradient: number): number;
  6571. }
  6572. /**
  6573. * Easing function with a power of 5 shape (see link below).
  6574. * @see https://easings.net/#easeInQuint
  6575. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6576. */
  6577. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6578. /** @hidden */
  6579. easeInCore(gradient: number): number;
  6580. }
  6581. /**
  6582. * Easing function with a sin shape (see link below).
  6583. * @see https://easings.net/#easeInSine
  6584. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6585. */
  6586. export class SineEase extends EasingFunction implements IEasingFunction {
  6587. /** @hidden */
  6588. easeInCore(gradient: number): number;
  6589. }
  6590. /**
  6591. * Easing function with a bezier shape (see link below).
  6592. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6594. */
  6595. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6596. /** Defines the x component of the start tangent in the bezier curve */
  6597. x1: number;
  6598. /** Defines the y component of the start tangent in the bezier curve */
  6599. y1: number;
  6600. /** Defines the x component of the end tangent in the bezier curve */
  6601. x2: number;
  6602. /** Defines the y component of the end tangent in the bezier curve */
  6603. y2: number;
  6604. /**
  6605. * Instantiates a bezier function
  6606. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6607. * @param x1 Defines the x component of the start tangent in the bezier curve
  6608. * @param y1 Defines the y component of the start tangent in the bezier curve
  6609. * @param x2 Defines the x component of the end tangent in the bezier curve
  6610. * @param y2 Defines the y component of the end tangent in the bezier curve
  6611. */
  6612. constructor(
  6613. /** Defines the x component of the start tangent in the bezier curve */
  6614. x1?: number,
  6615. /** Defines the y component of the start tangent in the bezier curve */
  6616. y1?: number,
  6617. /** Defines the x component of the end tangent in the bezier curve */
  6618. x2?: number,
  6619. /** Defines the y component of the end tangent in the bezier curve */
  6620. y2?: number);
  6621. /** @hidden */
  6622. easeInCore(gradient: number): number;
  6623. }
  6624. }
  6625. declare module "babylonjs/Animations/animationKey" {
  6626. /**
  6627. * Defines an interface which represents an animation key frame
  6628. */
  6629. export interface IAnimationKey {
  6630. /**
  6631. * Frame of the key frame
  6632. */
  6633. frame: number;
  6634. /**
  6635. * Value at the specifies key frame
  6636. */
  6637. value: any;
  6638. /**
  6639. * The input tangent for the cubic hermite spline
  6640. */
  6641. inTangent?: any;
  6642. /**
  6643. * The output tangent for the cubic hermite spline
  6644. */
  6645. outTangent?: any;
  6646. /**
  6647. * The animation interpolation type
  6648. */
  6649. interpolation?: AnimationKeyInterpolation;
  6650. }
  6651. /**
  6652. * Enum for the animation key frame interpolation type
  6653. */
  6654. export enum AnimationKeyInterpolation {
  6655. /**
  6656. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6657. */
  6658. STEP = 1
  6659. }
  6660. }
  6661. declare module "babylonjs/Animations/animationRange" {
  6662. /**
  6663. * Represents the range of an animation
  6664. */
  6665. export class AnimationRange {
  6666. /**The name of the animation range**/
  6667. name: string;
  6668. /**The starting frame of the animation */
  6669. from: number;
  6670. /**The ending frame of the animation*/
  6671. to: number;
  6672. /**
  6673. * Initializes the range of an animation
  6674. * @param name The name of the animation range
  6675. * @param from The starting frame of the animation
  6676. * @param to The ending frame of the animation
  6677. */
  6678. constructor(
  6679. /**The name of the animation range**/
  6680. name: string,
  6681. /**The starting frame of the animation */
  6682. from: number,
  6683. /**The ending frame of the animation*/
  6684. to: number);
  6685. /**
  6686. * Makes a copy of the animation range
  6687. * @returns A copy of the animation range
  6688. */
  6689. clone(): AnimationRange;
  6690. }
  6691. }
  6692. declare module "babylonjs/Animations/animationEvent" {
  6693. /**
  6694. * Composed of a frame, and an action function
  6695. */
  6696. export class AnimationEvent {
  6697. /** The frame for which the event is triggered **/
  6698. frame: number;
  6699. /** The event to perform when triggered **/
  6700. action: (currentFrame: number) => void;
  6701. /** Specifies if the event should be triggered only once**/
  6702. onlyOnce?: boolean | undefined;
  6703. /**
  6704. * Specifies if the animation event is done
  6705. */
  6706. isDone: boolean;
  6707. /**
  6708. * Initializes the animation event
  6709. * @param frame The frame for which the event is triggered
  6710. * @param action The event to perform when triggered
  6711. * @param onlyOnce Specifies if the event should be triggered only once
  6712. */
  6713. constructor(
  6714. /** The frame for which the event is triggered **/
  6715. frame: number,
  6716. /** The event to perform when triggered **/
  6717. action: (currentFrame: number) => void,
  6718. /** Specifies if the event should be triggered only once**/
  6719. onlyOnce?: boolean | undefined);
  6720. /** @hidden */
  6721. _clone(): AnimationEvent;
  6722. }
  6723. }
  6724. declare module "babylonjs/Behaviors/behavior" {
  6725. import { Nullable } from "babylonjs/types";
  6726. /**
  6727. * Interface used to define a behavior
  6728. */
  6729. export interface Behavior<T> {
  6730. /** gets or sets behavior's name */
  6731. name: string;
  6732. /**
  6733. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6734. */
  6735. init(): void;
  6736. /**
  6737. * Called when the behavior is attached to a target
  6738. * @param target defines the target where the behavior is attached to
  6739. */
  6740. attach(target: T): void;
  6741. /**
  6742. * Called when the behavior is detached from its target
  6743. */
  6744. detach(): void;
  6745. }
  6746. /**
  6747. * Interface implemented by classes supporting behaviors
  6748. */
  6749. export interface IBehaviorAware<T> {
  6750. /**
  6751. * Attach a behavior
  6752. * @param behavior defines the behavior to attach
  6753. * @returns the current host
  6754. */
  6755. addBehavior(behavior: Behavior<T>): T;
  6756. /**
  6757. * Remove a behavior from the current object
  6758. * @param behavior defines the behavior to detach
  6759. * @returns the current host
  6760. */
  6761. removeBehavior(behavior: Behavior<T>): T;
  6762. /**
  6763. * Gets a behavior using its name to search
  6764. * @param name defines the name to search
  6765. * @returns the behavior or null if not found
  6766. */
  6767. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6768. }
  6769. }
  6770. declare module "babylonjs/Animations/runtimeAnimation" {
  6771. import { Animation } from "babylonjs/Animations/animation";
  6772. import { Animatable } from "babylonjs/Animations/animatable";
  6773. import { Scene } from "babylonjs/scene";
  6774. /**
  6775. * Defines a runtime animation
  6776. */
  6777. export class RuntimeAnimation {
  6778. private _events;
  6779. /**
  6780. * The current frame of the runtime animation
  6781. */
  6782. private _currentFrame;
  6783. /**
  6784. * The animation used by the runtime animation
  6785. */
  6786. private _animation;
  6787. /**
  6788. * The target of the runtime animation
  6789. */
  6790. private _target;
  6791. /**
  6792. * The initiating animatable
  6793. */
  6794. private _host;
  6795. /**
  6796. * The original value of the runtime animation
  6797. */
  6798. private _originalValue;
  6799. /**
  6800. * The original blend value of the runtime animation
  6801. */
  6802. private _originalBlendValue;
  6803. /**
  6804. * The offsets cache of the runtime animation
  6805. */
  6806. private _offsetsCache;
  6807. /**
  6808. * The high limits cache of the runtime animation
  6809. */
  6810. private _highLimitsCache;
  6811. /**
  6812. * Specifies if the runtime animation has been stopped
  6813. */
  6814. private _stopped;
  6815. /**
  6816. * The blending factor of the runtime animation
  6817. */
  6818. private _blendingFactor;
  6819. /**
  6820. * The BabylonJS scene
  6821. */
  6822. private _scene;
  6823. /**
  6824. * The current value of the runtime animation
  6825. */
  6826. private _currentValue;
  6827. /** @hidden */
  6828. _workValue: any;
  6829. /**
  6830. * The active target of the runtime animation
  6831. */
  6832. private _activeTarget;
  6833. /**
  6834. * The target path of the runtime animation
  6835. */
  6836. private _targetPath;
  6837. /**
  6838. * The weight of the runtime animation
  6839. */
  6840. private _weight;
  6841. /**
  6842. * The ratio offset of the runtime animation
  6843. */
  6844. private _ratioOffset;
  6845. /**
  6846. * The previous delay of the runtime animation
  6847. */
  6848. private _previousDelay;
  6849. /**
  6850. * The previous ratio of the runtime animation
  6851. */
  6852. private _previousRatio;
  6853. /**
  6854. * Gets the current frame of the runtime animation
  6855. */
  6856. readonly currentFrame: number;
  6857. /**
  6858. * Gets the weight of the runtime animation
  6859. */
  6860. readonly weight: number;
  6861. /**
  6862. * Gets the current value of the runtime animation
  6863. */
  6864. readonly currentValue: any;
  6865. /**
  6866. * Gets the target path of the runtime animation
  6867. */
  6868. readonly targetPath: string;
  6869. /**
  6870. * Gets the actual target of the runtime animation
  6871. */
  6872. readonly target: any;
  6873. /**
  6874. * Create a new RuntimeAnimation object
  6875. * @param target defines the target of the animation
  6876. * @param animation defines the source animation object
  6877. * @param scene defines the hosting scene
  6878. * @param host defines the initiating Animatable
  6879. */
  6880. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  6881. /**
  6882. * Gets the animation from the runtime animation
  6883. */
  6884. readonly animation: Animation;
  6885. /**
  6886. * Resets the runtime animation to the beginning
  6887. * @param restoreOriginal defines whether to restore the target property to the original value
  6888. */
  6889. reset(restoreOriginal?: boolean): void;
  6890. /**
  6891. * Specifies if the runtime animation is stopped
  6892. * @returns Boolean specifying if the runtime animation is stopped
  6893. */
  6894. isStopped(): boolean;
  6895. /**
  6896. * Disposes of the runtime animation
  6897. */
  6898. dispose(): void;
  6899. /**
  6900. * Interpolates the animation from the current frame
  6901. * @param currentFrame The frame to interpolate the animation to
  6902. * @param repeatCount The number of times that the animation should loop
  6903. * @param loopMode The type of looping mode to use
  6904. * @param offsetValue Animation offset value
  6905. * @param highLimitValue The high limit value
  6906. * @returns The interpolated value
  6907. */
  6908. private _interpolate;
  6909. /**
  6910. * Apply the interpolated value to the target
  6911. * @param currentValue defines the value computed by the animation
  6912. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  6913. */
  6914. setValue(currentValue: any, weight?: number): void;
  6915. private _setValue;
  6916. /**
  6917. * Gets the loop pmode of the runtime animation
  6918. * @returns Loop Mode
  6919. */
  6920. private _getCorrectLoopMode;
  6921. /**
  6922. * Move the current animation to a given frame
  6923. * @param frame defines the frame to move to
  6924. */
  6925. goToFrame(frame: number): void;
  6926. /**
  6927. * @hidden Internal use only
  6928. */
  6929. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  6930. /**
  6931. * Execute the current animation
  6932. * @param delay defines the delay to add to the current frame
  6933. * @param from defines the lower bound of the animation range
  6934. * @param to defines the upper bound of the animation range
  6935. * @param loop defines if the current animation must loop
  6936. * @param speedRatio defines the current speed ratio
  6937. * @param weight defines the weight of the animation (default is -1 so no weight)
  6938. * @param onLoop optional callback called when animation loops
  6939. * @returns a boolean indicating if the animation is running
  6940. */
  6941. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  6942. }
  6943. }
  6944. declare module "babylonjs/Collisions/intersectionInfo" {
  6945. import { Nullable } from "babylonjs/types";
  6946. /**
  6947. * @hidden
  6948. */
  6949. export class IntersectionInfo {
  6950. bu: Nullable<number>;
  6951. bv: Nullable<number>;
  6952. distance: number;
  6953. faceId: number;
  6954. subMeshId: number;
  6955. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6956. }
  6957. }
  6958. declare module "babylonjs/Actions/actionEvent" {
  6959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6960. import { Nullable } from "babylonjs/types";
  6961. import { Sprite } from "babylonjs/Sprites/sprite";
  6962. import { Scene } from "babylonjs/scene";
  6963. import { Vector2 } from "babylonjs/Maths/math";
  6964. /**
  6965. * Interface used to define ActionEvent
  6966. */
  6967. export interface IActionEvent {
  6968. /** The mesh or sprite that triggered the action */
  6969. source: any;
  6970. /** The X mouse cursor position at the time of the event */
  6971. pointerX: number;
  6972. /** The Y mouse cursor position at the time of the event */
  6973. pointerY: number;
  6974. /** The mesh that is currently pointed at (can be null) */
  6975. meshUnderPointer: Nullable<AbstractMesh>;
  6976. /** the original (browser) event that triggered the ActionEvent */
  6977. sourceEvent?: any;
  6978. /** additional data for the event */
  6979. additionalData?: any;
  6980. }
  6981. /**
  6982. * ActionEvent is the event being sent when an action is triggered.
  6983. */
  6984. export class ActionEvent implements IActionEvent {
  6985. /** The mesh or sprite that triggered the action */
  6986. source: any;
  6987. /** The X mouse cursor position at the time of the event */
  6988. pointerX: number;
  6989. /** The Y mouse cursor position at the time of the event */
  6990. pointerY: number;
  6991. /** The mesh that is currently pointed at (can be null) */
  6992. meshUnderPointer: Nullable<AbstractMesh>;
  6993. /** the original (browser) event that triggered the ActionEvent */
  6994. sourceEvent?: any;
  6995. /** additional data for the event */
  6996. additionalData?: any;
  6997. /**
  6998. * Creates a new ActionEvent
  6999. * @param source The mesh or sprite that triggered the action
  7000. * @param pointerX The X mouse cursor position at the time of the event
  7001. * @param pointerY The Y mouse cursor position at the time of the event
  7002. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  7003. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  7004. * @param additionalData additional data for the event
  7005. */
  7006. constructor(
  7007. /** The mesh or sprite that triggered the action */
  7008. source: any,
  7009. /** The X mouse cursor position at the time of the event */
  7010. pointerX: number,
  7011. /** The Y mouse cursor position at the time of the event */
  7012. pointerY: number,
  7013. /** The mesh that is currently pointed at (can be null) */
  7014. meshUnderPointer: Nullable<AbstractMesh>,
  7015. /** the original (browser) event that triggered the ActionEvent */
  7016. sourceEvent?: any,
  7017. /** additional data for the event */
  7018. additionalData?: any);
  7019. /**
  7020. * Helper function to auto-create an ActionEvent from a source mesh.
  7021. * @param source The source mesh that triggered the event
  7022. * @param evt The original (browser) event
  7023. * @param additionalData additional data for the event
  7024. * @returns the new ActionEvent
  7025. */
  7026. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  7027. /**
  7028. * Helper function to auto-create an ActionEvent from a source sprite
  7029. * @param source The source sprite that triggered the event
  7030. * @param scene Scene associated with the sprite
  7031. * @param evt The original (browser) event
  7032. * @param additionalData additional data for the event
  7033. * @returns the new ActionEvent
  7034. */
  7035. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  7036. /**
  7037. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  7038. * @param scene the scene where the event occurred
  7039. * @param evt The original (browser) event
  7040. * @returns the new ActionEvent
  7041. */
  7042. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  7043. /**
  7044. * Helper function to auto-create an ActionEvent from a primitive
  7045. * @param prim defines the target primitive
  7046. * @param pointerPos defines the pointer position
  7047. * @param evt The original (browser) event
  7048. * @param additionalData additional data for the event
  7049. * @returns the new ActionEvent
  7050. */
  7051. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  7052. }
  7053. }
  7054. declare module "babylonjs/Culling/boundingSphere" {
  7055. import { DeepImmutable } from "babylonjs/types";
  7056. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7057. /**
  7058. * Class used to store bounding sphere information
  7059. */
  7060. export class BoundingSphere {
  7061. /**
  7062. * Gets the center of the bounding sphere in local space
  7063. */
  7064. readonly center: Vector3;
  7065. /**
  7066. * Radius of the bounding sphere in local space
  7067. */
  7068. radius: number;
  7069. /**
  7070. * Gets the center of the bounding sphere in world space
  7071. */
  7072. readonly centerWorld: Vector3;
  7073. /**
  7074. * Radius of the bounding sphere in world space
  7075. */
  7076. radiusWorld: number;
  7077. /**
  7078. * Gets the minimum vector in local space
  7079. */
  7080. readonly minimum: Vector3;
  7081. /**
  7082. * Gets the maximum vector in local space
  7083. */
  7084. readonly maximum: Vector3;
  7085. private _worldMatrix;
  7086. private static readonly TmpVector3;
  7087. /**
  7088. * Creates a new bounding sphere
  7089. * @param min defines the minimum vector (in local space)
  7090. * @param max defines the maximum vector (in local space)
  7091. * @param worldMatrix defines the new world matrix
  7092. */
  7093. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7094. /**
  7095. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7096. * @param min defines the new minimum vector (in local space)
  7097. * @param max defines the new maximum vector (in local space)
  7098. * @param worldMatrix defines the new world matrix
  7099. */
  7100. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7101. /**
  7102. * Scale the current bounding sphere by applying a scale factor
  7103. * @param factor defines the scale factor to apply
  7104. * @returns the current bounding box
  7105. */
  7106. scale(factor: number): BoundingSphere;
  7107. /**
  7108. * Gets the world matrix of the bounding box
  7109. * @returns a matrix
  7110. */
  7111. getWorldMatrix(): DeepImmutable<Matrix>;
  7112. /** @hidden */
  7113. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7114. /**
  7115. * Tests if the bounding sphere is intersecting the frustum planes
  7116. * @param frustumPlanes defines the frustum planes to test
  7117. * @returns true if there is an intersection
  7118. */
  7119. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7120. /**
  7121. * Tests if the bounding sphere center is in between the frustum planes.
  7122. * Used for optimistic fast inclusion.
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if the sphere center is in between the frustum planes
  7125. */
  7126. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if a point is inside the bounding sphere
  7129. * @param point defines the point to test
  7130. * @returns true if the point is inside the bounding sphere
  7131. */
  7132. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7133. /**
  7134. * Checks if two sphere intersct
  7135. * @param sphere0 sphere 0
  7136. * @param sphere1 sphere 1
  7137. * @returns true if the speres intersect
  7138. */
  7139. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7140. }
  7141. }
  7142. declare module "babylonjs/Culling/boundingBox" {
  7143. import { DeepImmutable } from "babylonjs/types";
  7144. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7145. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7146. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7147. /**
  7148. * Class used to store bounding box information
  7149. */
  7150. export class BoundingBox implements ICullable {
  7151. /**
  7152. * Gets the 8 vectors representing the bounding box in local space
  7153. */
  7154. readonly vectors: Vector3[];
  7155. /**
  7156. * Gets the center of the bounding box in local space
  7157. */
  7158. readonly center: Vector3;
  7159. /**
  7160. * Gets the center of the bounding box in world space
  7161. */
  7162. readonly centerWorld: Vector3;
  7163. /**
  7164. * Gets the extend size in local space
  7165. */
  7166. readonly extendSize: Vector3;
  7167. /**
  7168. * Gets the extend size in world space
  7169. */
  7170. readonly extendSizeWorld: Vector3;
  7171. /**
  7172. * Gets the OBB (object bounding box) directions
  7173. */
  7174. readonly directions: Vector3[];
  7175. /**
  7176. * Gets the 8 vectors representing the bounding box in world space
  7177. */
  7178. readonly vectorsWorld: Vector3[];
  7179. /**
  7180. * Gets the minimum vector in world space
  7181. */
  7182. readonly minimumWorld: Vector3;
  7183. /**
  7184. * Gets the maximum vector in world space
  7185. */
  7186. readonly maximumWorld: Vector3;
  7187. /**
  7188. * Gets the minimum vector in local space
  7189. */
  7190. readonly minimum: Vector3;
  7191. /**
  7192. * Gets the maximum vector in local space
  7193. */
  7194. readonly maximum: Vector3;
  7195. private _worldMatrix;
  7196. private static readonly TmpVector3;
  7197. /**
  7198. * @hidden
  7199. */
  7200. _tag: number;
  7201. /**
  7202. * Creates a new bounding box
  7203. * @param min defines the minimum vector (in local space)
  7204. * @param max defines the maximum vector (in local space)
  7205. * @param worldMatrix defines the new world matrix
  7206. */
  7207. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7208. /**
  7209. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7210. * @param min defines the new minimum vector (in local space)
  7211. * @param max defines the new maximum vector (in local space)
  7212. * @param worldMatrix defines the new world matrix
  7213. */
  7214. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7215. /**
  7216. * Scale the current bounding box by applying a scale factor
  7217. * @param factor defines the scale factor to apply
  7218. * @returns the current bounding box
  7219. */
  7220. scale(factor: number): BoundingBox;
  7221. /**
  7222. * Gets the world matrix of the bounding box
  7223. * @returns a matrix
  7224. */
  7225. getWorldMatrix(): DeepImmutable<Matrix>;
  7226. /** @hidden */
  7227. _update(world: DeepImmutable<Matrix>): void;
  7228. /**
  7229. * Tests if the bounding box is intersecting the frustum planes
  7230. * @param frustumPlanes defines the frustum planes to test
  7231. * @returns true if there is an intersection
  7232. */
  7233. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7234. /**
  7235. * Tests if the bounding box is entirely inside the frustum planes
  7236. * @param frustumPlanes defines the frustum planes to test
  7237. * @returns true if there is an inclusion
  7238. */
  7239. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7240. /**
  7241. * Tests if a point is inside the bounding box
  7242. * @param point defines the point to test
  7243. * @returns true if the point is inside the bounding box
  7244. */
  7245. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7246. /**
  7247. * Tests if the bounding box intersects with a bounding sphere
  7248. * @param sphere defines the sphere to test
  7249. * @returns true if there is an intersection
  7250. */
  7251. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7252. /**
  7253. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7254. * @param min defines the min vector to use
  7255. * @param max defines the max vector to use
  7256. * @returns true if there is an intersection
  7257. */
  7258. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7259. /**
  7260. * Tests if two bounding boxes are intersections
  7261. * @param box0 defines the first box to test
  7262. * @param box1 defines the second box to test
  7263. * @returns true if there is an intersection
  7264. */
  7265. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7266. /**
  7267. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7268. * @param minPoint defines the minimum vector of the bounding box
  7269. * @param maxPoint defines the maximum vector of the bounding box
  7270. * @param sphereCenter defines the sphere center
  7271. * @param sphereRadius defines the sphere radius
  7272. * @returns true if there is an intersection
  7273. */
  7274. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7275. /**
  7276. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7277. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7278. * @param frustumPlanes defines the frustum planes to test
  7279. * @return true if there is an inclusion
  7280. */
  7281. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7282. /**
  7283. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7284. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7285. * @param frustumPlanes defines the frustum planes to test
  7286. * @return true if there is an intersection
  7287. */
  7288. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7289. }
  7290. }
  7291. declare module "babylonjs/Collisions/collider" {
  7292. import { Nullable, IndicesArray } from "babylonjs/types";
  7293. import { Vector3, Plane } from "babylonjs/Maths/math";
  7294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7295. /** @hidden */
  7296. export class Collider {
  7297. /** Define if a collision was found */
  7298. collisionFound: boolean;
  7299. /**
  7300. * Define last intersection point in local space
  7301. */
  7302. intersectionPoint: Vector3;
  7303. /**
  7304. * Define last collided mesh
  7305. */
  7306. collidedMesh: Nullable<AbstractMesh>;
  7307. private _collisionPoint;
  7308. private _planeIntersectionPoint;
  7309. private _tempVector;
  7310. private _tempVector2;
  7311. private _tempVector3;
  7312. private _tempVector4;
  7313. private _edge;
  7314. private _baseToVertex;
  7315. private _destinationPoint;
  7316. private _slidePlaneNormal;
  7317. private _displacementVector;
  7318. /** @hidden */
  7319. _radius: Vector3;
  7320. /** @hidden */
  7321. _retry: number;
  7322. private _velocity;
  7323. private _basePoint;
  7324. private _epsilon;
  7325. /** @hidden */
  7326. _velocityWorldLength: number;
  7327. /** @hidden */
  7328. _basePointWorld: Vector3;
  7329. private _velocityWorld;
  7330. private _normalizedVelocity;
  7331. /** @hidden */
  7332. _initialVelocity: Vector3;
  7333. /** @hidden */
  7334. _initialPosition: Vector3;
  7335. private _nearestDistance;
  7336. private _collisionMask;
  7337. collisionMask: number;
  7338. /**
  7339. * Gets the plane normal used to compute the sliding response (in local space)
  7340. */
  7341. readonly slidePlaneNormal: Vector3;
  7342. /** @hidden */
  7343. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7344. /** @hidden */
  7345. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7346. /** @hidden */
  7347. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7348. /** @hidden */
  7349. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7350. /** @hidden */
  7351. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7352. /** @hidden */
  7353. _getResponse(pos: Vector3, vel: Vector3): void;
  7354. }
  7355. }
  7356. declare module "babylonjs/Culling/boundingInfo" {
  7357. import { DeepImmutable } from "babylonjs/types";
  7358. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7359. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7360. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7361. import { Collider } from "babylonjs/Collisions/collider";
  7362. /**
  7363. * Interface for cullable objects
  7364. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7365. */
  7366. export interface ICullable {
  7367. /**
  7368. * Checks if the object or part of the object is in the frustum
  7369. * @param frustumPlanes Camera near/planes
  7370. * @returns true if the object is in frustum otherwise false
  7371. */
  7372. isInFrustum(frustumPlanes: Plane[]): boolean;
  7373. /**
  7374. * Checks if a cullable object (mesh...) is in the camera frustum
  7375. * Unlike isInFrustum this cheks the full bounding box
  7376. * @param frustumPlanes Camera near/planes
  7377. * @returns true if the object is in frustum otherwise false
  7378. */
  7379. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7380. }
  7381. /**
  7382. * Info for a bounding data of a mesh
  7383. */
  7384. export class BoundingInfo implements ICullable {
  7385. /**
  7386. * Bounding box for the mesh
  7387. */
  7388. readonly boundingBox: BoundingBox;
  7389. /**
  7390. * Bounding sphere for the mesh
  7391. */
  7392. readonly boundingSphere: BoundingSphere;
  7393. private _isLocked;
  7394. private static readonly TmpVector3;
  7395. /**
  7396. * Constructs bounding info
  7397. * @param minimum min vector of the bounding box/sphere
  7398. * @param maximum max vector of the bounding box/sphere
  7399. * @param worldMatrix defines the new world matrix
  7400. */
  7401. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7402. /**
  7403. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7404. * @param min defines the new minimum vector (in local space)
  7405. * @param max defines the new maximum vector (in local space)
  7406. * @param worldMatrix defines the new world matrix
  7407. */
  7408. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7409. /**
  7410. * min vector of the bounding box/sphere
  7411. */
  7412. readonly minimum: Vector3;
  7413. /**
  7414. * max vector of the bounding box/sphere
  7415. */
  7416. readonly maximum: Vector3;
  7417. /**
  7418. * If the info is locked and won't be updated to avoid perf overhead
  7419. */
  7420. isLocked: boolean;
  7421. /**
  7422. * Updates the bounding sphere and box
  7423. * @param world world matrix to be used to update
  7424. */
  7425. update(world: DeepImmutable<Matrix>): void;
  7426. /**
  7427. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7428. * @param center New center of the bounding info
  7429. * @param extend New extend of the bounding info
  7430. * @returns the current bounding info
  7431. */
  7432. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7433. /**
  7434. * Scale the current bounding info by applying a scale factor
  7435. * @param factor defines the scale factor to apply
  7436. * @returns the current bounding info
  7437. */
  7438. scale(factor: number): BoundingInfo;
  7439. /**
  7440. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7441. * @param frustumPlanes defines the frustum to test
  7442. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7443. * @returns true if the bounding info is in the frustum planes
  7444. */
  7445. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7446. /**
  7447. * Gets the world distance between the min and max points of the bounding box
  7448. */
  7449. readonly diagonalLength: number;
  7450. /**
  7451. * Checks if a cullable object (mesh...) is in the camera frustum
  7452. * Unlike isInFrustum this cheks the full bounding box
  7453. * @param frustumPlanes Camera near/planes
  7454. * @returns true if the object is in frustum otherwise false
  7455. */
  7456. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7457. /** @hidden */
  7458. _checkCollision(collider: Collider): boolean;
  7459. /**
  7460. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7461. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7462. * @param point the point to check intersection with
  7463. * @returns if the point intersects
  7464. */
  7465. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7466. /**
  7467. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7468. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7469. * @param boundingInfo the bounding info to check intersection with
  7470. * @param precise if the intersection should be done using OBB
  7471. * @returns if the bounding info intersects
  7472. */
  7473. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7474. }
  7475. }
  7476. declare module "babylonjs/Misc/smartArray" {
  7477. /**
  7478. * Defines an array and its length.
  7479. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7480. */
  7481. export interface ISmartArrayLike<T> {
  7482. /**
  7483. * The data of the array.
  7484. */
  7485. data: Array<T>;
  7486. /**
  7487. * The active length of the array.
  7488. */
  7489. length: number;
  7490. }
  7491. /**
  7492. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7493. */
  7494. export class SmartArray<T> implements ISmartArrayLike<T> {
  7495. /**
  7496. * The full set of data from the array.
  7497. */
  7498. data: Array<T>;
  7499. /**
  7500. * The active length of the array.
  7501. */
  7502. length: number;
  7503. protected _id: number;
  7504. /**
  7505. * Instantiates a Smart Array.
  7506. * @param capacity defines the default capacity of the array.
  7507. */
  7508. constructor(capacity: number);
  7509. /**
  7510. * Pushes a value at the end of the active data.
  7511. * @param value defines the object to push in the array.
  7512. */
  7513. push(value: T): void;
  7514. /**
  7515. * Iterates over the active data and apply the lambda to them.
  7516. * @param func defines the action to apply on each value.
  7517. */
  7518. forEach(func: (content: T) => void): void;
  7519. /**
  7520. * Sorts the full sets of data.
  7521. * @param compareFn defines the comparison function to apply.
  7522. */
  7523. sort(compareFn: (a: T, b: T) => number): void;
  7524. /**
  7525. * Resets the active data to an empty array.
  7526. */
  7527. reset(): void;
  7528. /**
  7529. * Releases all the data from the array as well as the array.
  7530. */
  7531. dispose(): void;
  7532. /**
  7533. * Concats the active data with a given array.
  7534. * @param array defines the data to concatenate with.
  7535. */
  7536. concat(array: any): void;
  7537. /**
  7538. * Returns the position of a value in the active data.
  7539. * @param value defines the value to find the index for
  7540. * @returns the index if found in the active data otherwise -1
  7541. */
  7542. indexOf(value: T): number;
  7543. /**
  7544. * Returns whether an element is part of the active data.
  7545. * @param value defines the value to look for
  7546. * @returns true if found in the active data otherwise false
  7547. */
  7548. contains(value: T): boolean;
  7549. private static _GlobalId;
  7550. }
  7551. /**
  7552. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7553. * The data in this array can only be present once
  7554. */
  7555. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7556. private _duplicateId;
  7557. /**
  7558. * Pushes a value at the end of the active data.
  7559. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7560. * @param value defines the object to push in the array.
  7561. */
  7562. push(value: T): void;
  7563. /**
  7564. * Pushes a value at the end of the active data.
  7565. * If the data is already present, it won t be added again
  7566. * @param value defines the object to push in the array.
  7567. * @returns true if added false if it was already present
  7568. */
  7569. pushNoDuplicate(value: T): boolean;
  7570. /**
  7571. * Resets the active data to an empty array.
  7572. */
  7573. reset(): void;
  7574. /**
  7575. * Concats the active data with a given array.
  7576. * This ensures no dupplicate will be present in the result.
  7577. * @param array defines the data to concatenate with.
  7578. */
  7579. concatWithNoDuplicate(array: any): void;
  7580. }
  7581. }
  7582. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7583. import { Nullable } from "babylonjs/types";
  7584. import { Scene } from "babylonjs/scene";
  7585. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7587. /**
  7588. * Class for creating a cube texture
  7589. */
  7590. export class CubeTexture extends BaseTexture {
  7591. private _delayedOnLoad;
  7592. /**
  7593. * The url of the texture
  7594. */
  7595. url: string;
  7596. /**
  7597. * Gets or sets the center of the bounding box associated with the cube texture.
  7598. * It must define where the camera used to render the texture was set
  7599. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7600. */
  7601. boundingBoxPosition: Vector3;
  7602. private _boundingBoxSize;
  7603. /**
  7604. * Gets or sets the size of the bounding box associated with the cube texture
  7605. * When defined, the cubemap will switch to local mode
  7606. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7607. * @example https://www.babylonjs-playground.com/#RNASML
  7608. */
  7609. /**
  7610. * Returns the bounding box size
  7611. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7612. */
  7613. boundingBoxSize: Vector3;
  7614. protected _rotationY: number;
  7615. /**
  7616. * Sets texture matrix rotation angle around Y axis in radians.
  7617. */
  7618. /**
  7619. * Gets texture matrix rotation angle around Y axis radians.
  7620. */
  7621. rotationY: number;
  7622. /**
  7623. * Are mip maps generated for this texture or not.
  7624. */
  7625. readonly noMipmap: boolean;
  7626. private _noMipmap;
  7627. private _files;
  7628. private _extensions;
  7629. private _textureMatrix;
  7630. private _format;
  7631. private _createPolynomials;
  7632. /** @hidden */
  7633. _prefiltered: boolean;
  7634. /**
  7635. * Creates a cube texture from an array of image urls
  7636. * @param files defines an array of image urls
  7637. * @param scene defines the hosting scene
  7638. * @param noMipmap specifies if mip maps are not used
  7639. * @returns a cube texture
  7640. */
  7641. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7642. /**
  7643. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7644. * @param url defines the url of the prefiltered texture
  7645. * @param scene defines the scene the texture is attached to
  7646. * @param forcedExtension defines the extension of the file if different from the url
  7647. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7648. * @return the prefiltered texture
  7649. */
  7650. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7651. /**
  7652. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7653. * as prefiltered data.
  7654. * @param rootUrl defines the url of the texture or the root name of the six images
  7655. * @param scene defines the scene the texture is attached to
  7656. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7657. * @param noMipmap defines if mipmaps should be created or not
  7658. * @param files defines the six files to load for the different faces
  7659. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7660. * @param onError defines a callback triggered in case of error during load
  7661. * @param format defines the internal format to use for the texture once loaded
  7662. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7663. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7664. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7665. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7666. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7667. * @return the cube texture
  7668. */
  7669. 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);
  7670. /**
  7671. * Get the current class name of the texture useful for serialization or dynamic coding.
  7672. * @returns "CubeTexture"
  7673. */
  7674. getClassName(): string;
  7675. /**
  7676. * Update the url (and optional buffer) of this texture if url was null during construction.
  7677. * @param url the url of the texture
  7678. * @param forcedExtension defines the extension to use
  7679. * @param onLoad callback called when the texture is loaded (defaults to null)
  7680. */
  7681. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7682. /**
  7683. * Delays loading of the cube texture
  7684. * @param forcedExtension defines the extension to use
  7685. */
  7686. delayLoad(forcedExtension?: string): void;
  7687. /**
  7688. * Returns the reflection texture matrix
  7689. * @returns the reflection texture matrix
  7690. */
  7691. getReflectionTextureMatrix(): Matrix;
  7692. /**
  7693. * Sets the reflection texture matrix
  7694. * @param value Reflection texture matrix
  7695. */
  7696. setReflectionTextureMatrix(value: Matrix): void;
  7697. /**
  7698. * Parses text to create a cube texture
  7699. * @param parsedTexture define the serialized text to read from
  7700. * @param scene defines the hosting scene
  7701. * @param rootUrl defines the root url of the cube texture
  7702. * @returns a cube texture
  7703. */
  7704. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7705. /**
  7706. * Makes a clone, or deep copy, of the cube texture
  7707. * @returns a new cube texture
  7708. */
  7709. clone(): CubeTexture;
  7710. }
  7711. }
  7712. declare module "babylonjs/Shaders/postprocess.vertex" {
  7713. /** @hidden */
  7714. export var postprocessVertexShader: {
  7715. name: string;
  7716. shader: string;
  7717. };
  7718. }
  7719. declare module "babylonjs/Cameras/targetCamera" {
  7720. import { Nullable } from "babylonjs/types";
  7721. import { Camera } from "babylonjs/Cameras/camera";
  7722. import { Scene } from "babylonjs/scene";
  7723. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7724. /**
  7725. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7726. * This is the base of the follow, arc rotate cameras and Free camera
  7727. * @see http://doc.babylonjs.com/features/cameras
  7728. */
  7729. export class TargetCamera extends Camera {
  7730. private static _RigCamTransformMatrix;
  7731. private static _TargetTransformMatrix;
  7732. private static _TargetFocalPoint;
  7733. /**
  7734. * Define the current direction the camera is moving to
  7735. */
  7736. cameraDirection: Vector3;
  7737. /**
  7738. * Define the current rotation the camera is rotating to
  7739. */
  7740. cameraRotation: Vector2;
  7741. /**
  7742. * When set, the up vector of the camera will be updated by the rotation of the camera
  7743. */
  7744. updateUpVectorFromRotation: boolean;
  7745. private _tmpQuaternion;
  7746. /**
  7747. * Define the current rotation of the camera
  7748. */
  7749. rotation: Vector3;
  7750. /**
  7751. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7752. */
  7753. rotationQuaternion: Quaternion;
  7754. /**
  7755. * Define the current speed of the camera
  7756. */
  7757. speed: number;
  7758. /**
  7759. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7760. * around all axis.
  7761. */
  7762. noRotationConstraint: boolean;
  7763. /**
  7764. * Define the current target of the camera as an object or a position.
  7765. */
  7766. lockedTarget: any;
  7767. /** @hidden */
  7768. _currentTarget: Vector3;
  7769. /** @hidden */
  7770. _initialFocalDistance: number;
  7771. /** @hidden */
  7772. _viewMatrix: Matrix;
  7773. /** @hidden */
  7774. _camMatrix: Matrix;
  7775. /** @hidden */
  7776. _cameraTransformMatrix: Matrix;
  7777. /** @hidden */
  7778. _cameraRotationMatrix: Matrix;
  7779. /** @hidden */
  7780. _referencePoint: Vector3;
  7781. /** @hidden */
  7782. _transformedReferencePoint: Vector3;
  7783. protected _globalCurrentTarget: Vector3;
  7784. protected _globalCurrentUpVector: Vector3;
  7785. /** @hidden */
  7786. _reset: () => void;
  7787. private _defaultUp;
  7788. /**
  7789. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  7790. * This is the base of the follow, arc rotate cameras and Free camera
  7791. * @see http://doc.babylonjs.com/features/cameras
  7792. * @param name Defines the name of the camera in the scene
  7793. * @param position Defines the start position of the camera in the scene
  7794. * @param scene Defines the scene the camera belongs to
  7795. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  7796. */
  7797. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  7798. /**
  7799. * Gets the position in front of the camera at a given distance.
  7800. * @param distance The distance from the camera we want the position to be
  7801. * @returns the position
  7802. */
  7803. getFrontPosition(distance: number): Vector3;
  7804. /** @hidden */
  7805. _getLockedTargetPosition(): Nullable<Vector3>;
  7806. private _storedPosition;
  7807. private _storedRotation;
  7808. private _storedRotationQuaternion;
  7809. /**
  7810. * Store current camera state of the camera (fov, position, rotation, etc..)
  7811. * @returns the camera
  7812. */
  7813. storeState(): Camera;
  7814. /**
  7815. * Restored camera state. You must call storeState() first
  7816. * @returns whether it was successful or not
  7817. * @hidden
  7818. */
  7819. _restoreStateValues(): boolean;
  7820. /** @hidden */
  7821. _initCache(): void;
  7822. /** @hidden */
  7823. _updateCache(ignoreParentClass?: boolean): void;
  7824. /** @hidden */
  7825. _isSynchronizedViewMatrix(): boolean;
  7826. /** @hidden */
  7827. _computeLocalCameraSpeed(): number;
  7828. /** @hidden */
  7829. setTarget(target: Vector3): void;
  7830. /**
  7831. * Return the current target position of the camera. This value is expressed in local space.
  7832. * @returns the target position
  7833. */
  7834. getTarget(): Vector3;
  7835. /** @hidden */
  7836. _decideIfNeedsToMove(): boolean;
  7837. /** @hidden */
  7838. _updatePosition(): void;
  7839. /** @hidden */
  7840. _checkInputs(): void;
  7841. protected _updateCameraRotationMatrix(): void;
  7842. /**
  7843. * 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)
  7844. * @returns the current camera
  7845. */
  7846. private _rotateUpVectorWithCameraRotationMatrix;
  7847. private _cachedRotationZ;
  7848. private _cachedQuaternionRotationZ;
  7849. /** @hidden */
  7850. _getViewMatrix(): Matrix;
  7851. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  7852. /**
  7853. * @hidden
  7854. */
  7855. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  7856. /**
  7857. * @hidden
  7858. */
  7859. _updateRigCameras(): void;
  7860. private _getRigCamPositionAndTarget;
  7861. /**
  7862. * Gets the current object class name.
  7863. * @return the class name
  7864. */
  7865. getClassName(): string;
  7866. }
  7867. }
  7868. declare module "babylonjs/Cameras/cameraInputsManager" {
  7869. import { Nullable } from "babylonjs/types";
  7870. import { Camera } from "babylonjs/Cameras/camera";
  7871. /**
  7872. * @ignore
  7873. * This is a list of all the different input types that are available in the application.
  7874. * Fo instance: ArcRotateCameraGamepadInput...
  7875. */
  7876. export var CameraInputTypes: {};
  7877. /**
  7878. * This is the contract to implement in order to create a new input class.
  7879. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  7880. */
  7881. export interface ICameraInput<TCamera extends Camera> {
  7882. /**
  7883. * Defines the camera the input is attached to.
  7884. */
  7885. camera: Nullable<TCamera>;
  7886. /**
  7887. * Gets the class name of the current intput.
  7888. * @returns the class name
  7889. */
  7890. getClassName(): string;
  7891. /**
  7892. * Get the friendly name associated with the input class.
  7893. * @returns the input friendly name
  7894. */
  7895. getSimpleName(): string;
  7896. /**
  7897. * Attach the input controls to a specific dom element to get the input from.
  7898. * @param element Defines the element the controls should be listened from
  7899. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7900. */
  7901. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  7902. /**
  7903. * Detach the current controls from the specified dom element.
  7904. * @param element Defines the element to stop listening the inputs from
  7905. */
  7906. detachControl(element: Nullable<HTMLElement>): void;
  7907. /**
  7908. * Update the current camera state depending on the inputs that have been used this frame.
  7909. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7910. */
  7911. checkInputs?: () => void;
  7912. }
  7913. /**
  7914. * Represents a map of input types to input instance or input index to input instance.
  7915. */
  7916. export interface CameraInputsMap<TCamera extends Camera> {
  7917. /**
  7918. * Accessor to the input by input type.
  7919. */
  7920. [name: string]: ICameraInput<TCamera>;
  7921. /**
  7922. * Accessor to the input by input index.
  7923. */
  7924. [idx: number]: ICameraInput<TCamera>;
  7925. }
  7926. /**
  7927. * This represents the input manager used within a camera.
  7928. * It helps dealing with all the different kind of input attached to a camera.
  7929. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7930. */
  7931. export class CameraInputsManager<TCamera extends Camera> {
  7932. /**
  7933. * Defines the list of inputs attahed to the camera.
  7934. */
  7935. attached: CameraInputsMap<TCamera>;
  7936. /**
  7937. * Defines the dom element the camera is collecting inputs from.
  7938. * This is null if the controls have not been attached.
  7939. */
  7940. attachedElement: Nullable<HTMLElement>;
  7941. /**
  7942. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7943. */
  7944. noPreventDefault: boolean;
  7945. /**
  7946. * Defined the camera the input manager belongs to.
  7947. */
  7948. camera: TCamera;
  7949. /**
  7950. * Update the current camera state depending on the inputs that have been used this frame.
  7951. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  7952. */
  7953. checkInputs: () => void;
  7954. /**
  7955. * Instantiate a new Camera Input Manager.
  7956. * @param camera Defines the camera the input manager blongs to
  7957. */
  7958. constructor(camera: TCamera);
  7959. /**
  7960. * Add an input method to a camera
  7961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  7962. * @param input camera input method
  7963. */
  7964. add(input: ICameraInput<TCamera>): void;
  7965. /**
  7966. * Remove a specific input method from a camera
  7967. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  7968. * @param inputToRemove camera input method
  7969. */
  7970. remove(inputToRemove: ICameraInput<TCamera>): void;
  7971. /**
  7972. * Remove a specific input type from a camera
  7973. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  7974. * @param inputType the type of the input to remove
  7975. */
  7976. removeByType(inputType: string): void;
  7977. private _addCheckInputs;
  7978. /**
  7979. * Attach the input controls to the currently attached dom element to listen the events from.
  7980. * @param input Defines the input to attach
  7981. */
  7982. attachInput(input: ICameraInput<TCamera>): void;
  7983. /**
  7984. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  7985. * @param element Defines the dom element to collect the events from
  7986. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  7987. */
  7988. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  7989. /**
  7990. * Detach the current manager inputs controls from a specific dom element.
  7991. * @param element Defines the dom element to collect the events from
  7992. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  7993. */
  7994. detachElement(element: HTMLElement, disconnect?: boolean): void;
  7995. /**
  7996. * Rebuild the dynamic inputCheck function from the current list of
  7997. * defined inputs in the manager.
  7998. */
  7999. rebuildInputCheck(): void;
  8000. /**
  8001. * Remove all attached input methods from a camera
  8002. */
  8003. clear(): void;
  8004. /**
  8005. * Serialize the current input manager attached to a camera.
  8006. * This ensures than once parsed,
  8007. * the input associated to the camera will be identical to the current ones
  8008. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8009. */
  8010. serialize(serializedCamera: any): void;
  8011. /**
  8012. * Parses an input manager serialized JSON to restore the previous list of inputs
  8013. * and states associated to a camera.
  8014. * @param parsedCamera Defines the JSON to parse
  8015. */
  8016. parse(parsedCamera: any): void;
  8017. }
  8018. }
  8019. declare module "babylonjs/Events/keyboardEvents" {
  8020. /**
  8021. * Gather the list of keyboard event types as constants.
  8022. */
  8023. export class KeyboardEventTypes {
  8024. /**
  8025. * The keydown event is fired when a key becomes active (pressed).
  8026. */
  8027. static readonly KEYDOWN: number;
  8028. /**
  8029. * The keyup event is fired when a key has been released.
  8030. */
  8031. static readonly KEYUP: number;
  8032. }
  8033. /**
  8034. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8035. */
  8036. export class KeyboardInfo {
  8037. /**
  8038. * Defines the type of event (KeyboardEventTypes)
  8039. */
  8040. type: number;
  8041. /**
  8042. * Defines the related dom event
  8043. */
  8044. event: KeyboardEvent;
  8045. /**
  8046. * Instantiates a new keyboard info.
  8047. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8048. * @param type Defines the type of event (KeyboardEventTypes)
  8049. * @param event Defines the related dom event
  8050. */
  8051. constructor(
  8052. /**
  8053. * Defines the type of event (KeyboardEventTypes)
  8054. */
  8055. type: number,
  8056. /**
  8057. * Defines the related dom event
  8058. */
  8059. event: KeyboardEvent);
  8060. }
  8061. /**
  8062. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8063. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8064. */
  8065. export class KeyboardInfoPre extends KeyboardInfo {
  8066. /**
  8067. * Defines the type of event (KeyboardEventTypes)
  8068. */
  8069. type: number;
  8070. /**
  8071. * Defines the related dom event
  8072. */
  8073. event: KeyboardEvent;
  8074. /**
  8075. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8076. */
  8077. skipOnPointerObservable: boolean;
  8078. /**
  8079. * Instantiates a new keyboard pre info.
  8080. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8081. * @param type Defines the type of event (KeyboardEventTypes)
  8082. * @param event Defines the related dom event
  8083. */
  8084. constructor(
  8085. /**
  8086. * Defines the type of event (KeyboardEventTypes)
  8087. */
  8088. type: number,
  8089. /**
  8090. * Defines the related dom event
  8091. */
  8092. event: KeyboardEvent);
  8093. }
  8094. }
  8095. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8096. import { Nullable } from "babylonjs/types";
  8097. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8098. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8099. /**
  8100. * Manage the keyboard inputs to control the movement of a free camera.
  8101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8102. */
  8103. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8104. /**
  8105. * Defines the camera the input is attached to.
  8106. */
  8107. camera: FreeCamera;
  8108. /**
  8109. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8110. */
  8111. keysUp: number[];
  8112. /**
  8113. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8114. */
  8115. keysDown: number[];
  8116. /**
  8117. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8118. */
  8119. keysLeft: number[];
  8120. /**
  8121. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8122. */
  8123. keysRight: number[];
  8124. private _keys;
  8125. private _onCanvasBlurObserver;
  8126. private _onKeyboardObserver;
  8127. private _engine;
  8128. private _scene;
  8129. /**
  8130. * Attach the input controls to a specific dom element to get the input from.
  8131. * @param element Defines the element the controls should be listened from
  8132. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8133. */
  8134. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8135. /**
  8136. * Detach the current controls from the specified dom element.
  8137. * @param element Defines the element to stop listening the inputs from
  8138. */
  8139. detachControl(element: Nullable<HTMLElement>): void;
  8140. /**
  8141. * Update the current camera state depending on the inputs that have been used this frame.
  8142. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8143. */
  8144. checkInputs(): void;
  8145. /**
  8146. * Gets the class name of the current intput.
  8147. * @returns the class name
  8148. */
  8149. getClassName(): string;
  8150. /** @hidden */
  8151. _onLostFocus(): void;
  8152. /**
  8153. * Get the friendly name associated with the input class.
  8154. * @returns the input friendly name
  8155. */
  8156. getSimpleName(): string;
  8157. }
  8158. }
  8159. declare module "babylonjs/Events/pointerEvents" {
  8160. import { Nullable } from "babylonjs/types";
  8161. import { Vector2 } from "babylonjs/Maths/math";
  8162. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  8163. import { Ray } from "babylonjs/Culling/ray";
  8164. /**
  8165. * Gather the list of pointer event types as constants.
  8166. */
  8167. export class PointerEventTypes {
  8168. /**
  8169. * 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.
  8170. */
  8171. static readonly POINTERDOWN: number;
  8172. /**
  8173. * The pointerup event is fired when a pointer is no longer active.
  8174. */
  8175. static readonly POINTERUP: number;
  8176. /**
  8177. * The pointermove event is fired when a pointer changes coordinates.
  8178. */
  8179. static readonly POINTERMOVE: number;
  8180. /**
  8181. * The pointerwheel event is fired when a mouse wheel has been rotated.
  8182. */
  8183. static readonly POINTERWHEEL: number;
  8184. /**
  8185. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  8186. */
  8187. static readonly POINTERPICK: number;
  8188. /**
  8189. * The pointertap event is fired when a the object has been touched and released without drag.
  8190. */
  8191. static readonly POINTERTAP: number;
  8192. /**
  8193. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  8194. */
  8195. static readonly POINTERDOUBLETAP: number;
  8196. }
  8197. /**
  8198. * Base class of pointer info types.
  8199. */
  8200. export class PointerInfoBase {
  8201. /**
  8202. * Defines the type of event (PointerEventTypes)
  8203. */
  8204. type: number;
  8205. /**
  8206. * Defines the related dom event
  8207. */
  8208. event: PointerEvent | MouseWheelEvent;
  8209. /**
  8210. * Instantiates the base class of pointers info.
  8211. * @param type Defines the type of event (PointerEventTypes)
  8212. * @param event Defines the related dom event
  8213. */
  8214. constructor(
  8215. /**
  8216. * Defines the type of event (PointerEventTypes)
  8217. */
  8218. type: number,
  8219. /**
  8220. * Defines the related dom event
  8221. */
  8222. event: PointerEvent | MouseWheelEvent);
  8223. }
  8224. /**
  8225. * This class is used to store pointer related info for the onPrePointerObservable event.
  8226. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  8227. */
  8228. export class PointerInfoPre extends PointerInfoBase {
  8229. /**
  8230. * Ray from a pointer if availible (eg. 6dof controller)
  8231. */
  8232. ray: Nullable<Ray>;
  8233. /**
  8234. * Defines the local position of the pointer on the canvas.
  8235. */
  8236. localPosition: Vector2;
  8237. /**
  8238. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  8239. */
  8240. skipOnPointerObservable: boolean;
  8241. /**
  8242. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  8243. * @param type Defines the type of event (PointerEventTypes)
  8244. * @param event Defines the related dom event
  8245. * @param localX Defines the local x coordinates of the pointer when the event occured
  8246. * @param localY Defines the local y coordinates of the pointer when the event occured
  8247. */
  8248. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  8249. }
  8250. /**
  8251. * This type contains all the data related to a pointer event in Babylon.js.
  8252. * 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.
  8253. */
  8254. export class PointerInfo extends PointerInfoBase {
  8255. /**
  8256. * Defines the picking info associated to the info (if any)\
  8257. */
  8258. pickInfo: Nullable<PickingInfo>;
  8259. /**
  8260. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  8261. * @param type Defines the type of event (PointerEventTypes)
  8262. * @param event Defines the related dom event
  8263. * @param pickInfo Defines the picking info associated to the info (if any)\
  8264. */
  8265. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  8266. /**
  8267. * Defines the picking info associated to the info (if any)\
  8268. */
  8269. pickInfo: Nullable<PickingInfo>);
  8270. }
  8271. }
  8272. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  8273. import { Nullable } from "babylonjs/types";
  8274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8276. /**
  8277. * Manage the mouse inputs to control the movement of a free camera.
  8278. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8279. */
  8280. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  8281. /**
  8282. * Define if touch is enabled in the mouse input
  8283. */
  8284. touchEnabled: boolean;
  8285. /**
  8286. * Defines the camera the input is attached to.
  8287. */
  8288. camera: FreeCamera;
  8289. /**
  8290. * Defines the buttons associated with the input to handle camera move.
  8291. */
  8292. buttons: number[];
  8293. /**
  8294. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  8295. */
  8296. angularSensibility: number;
  8297. private _pointerInput;
  8298. private _onMouseMove;
  8299. private _observer;
  8300. private previousPosition;
  8301. /**
  8302. * Manage the mouse inputs to control the movement of a free camera.
  8303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8304. * @param touchEnabled Defines if touch is enabled or not
  8305. */
  8306. constructor(
  8307. /**
  8308. * Define if touch is enabled in the mouse input
  8309. */
  8310. touchEnabled?: boolean);
  8311. /**
  8312. * Attach the input controls to a specific dom element to get the input from.
  8313. * @param element Defines the element the controls should be listened from
  8314. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8315. */
  8316. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8317. /**
  8318. * Detach the current controls from the specified dom element.
  8319. * @param element Defines the element to stop listening the inputs from
  8320. */
  8321. detachControl(element: Nullable<HTMLElement>): void;
  8322. /**
  8323. * Gets the class name of the current intput.
  8324. * @returns the class name
  8325. */
  8326. getClassName(): string;
  8327. /**
  8328. * Get the friendly name associated with the input class.
  8329. * @returns the input friendly name
  8330. */
  8331. getSimpleName(): string;
  8332. }
  8333. }
  8334. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  8335. import { Nullable } from "babylonjs/types";
  8336. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8337. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8338. /**
  8339. * Manage the touch inputs to control the movement of a free camera.
  8340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8341. */
  8342. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  8343. /**
  8344. * Defines the camera the input is attached to.
  8345. */
  8346. camera: FreeCamera;
  8347. /**
  8348. * Defines the touch sensibility for rotation.
  8349. * The higher the faster.
  8350. */
  8351. touchAngularSensibility: number;
  8352. /**
  8353. * Defines the touch sensibility for move.
  8354. * The higher the faster.
  8355. */
  8356. touchMoveSensibility: number;
  8357. private _offsetX;
  8358. private _offsetY;
  8359. private _pointerPressed;
  8360. private _pointerInput;
  8361. private _observer;
  8362. private _onLostFocus;
  8363. /**
  8364. * Attach the input controls to a specific dom element to get the input from.
  8365. * @param element Defines the element the controls should be listened from
  8366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8367. */
  8368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8369. /**
  8370. * Detach the current controls from the specified dom element.
  8371. * @param element Defines the element to stop listening the inputs from
  8372. */
  8373. detachControl(element: Nullable<HTMLElement>): void;
  8374. /**
  8375. * Update the current camera state depending on the inputs that have been used this frame.
  8376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8377. */
  8378. checkInputs(): void;
  8379. /**
  8380. * Gets the class name of the current intput.
  8381. * @returns the class name
  8382. */
  8383. getClassName(): string;
  8384. /**
  8385. * Get the friendly name associated with the input class.
  8386. * @returns the input friendly name
  8387. */
  8388. getSimpleName(): string;
  8389. }
  8390. }
  8391. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  8392. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8393. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  8394. /**
  8395. * Default Inputs manager for the FreeCamera.
  8396. * It groups all the default supported inputs for ease of use.
  8397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8398. */
  8399. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  8400. /**
  8401. * Instantiates a new FreeCameraInputsManager.
  8402. * @param camera Defines the camera the inputs belong to
  8403. */
  8404. constructor(camera: FreeCamera);
  8405. /**
  8406. * Add keyboard input support to the input manager.
  8407. * @returns the current input manager
  8408. */
  8409. addKeyboard(): FreeCameraInputsManager;
  8410. /**
  8411. * Add mouse input support to the input manager.
  8412. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  8413. * @returns the current input manager
  8414. */
  8415. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  8416. /**
  8417. * Add touch input support to the input manager.
  8418. * @returns the current input manager
  8419. */
  8420. addTouch(): FreeCameraInputsManager;
  8421. }
  8422. }
  8423. declare module "babylonjs/Cameras/freeCamera" {
  8424. import { Vector3 } from "babylonjs/Maths/math";
  8425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8426. import { Scene } from "babylonjs/scene";
  8427. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  8428. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  8429. /**
  8430. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8431. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  8432. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8433. */
  8434. export class FreeCamera extends TargetCamera {
  8435. /**
  8436. * Define the collision ellipsoid of the camera.
  8437. * This is helpful to simulate a camera body like the player body around the camera
  8438. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  8439. */
  8440. ellipsoid: Vector3;
  8441. /**
  8442. * Define an offset for the position of the ellipsoid around the camera.
  8443. * This can be helpful to determine the center of the body near the gravity center of the body
  8444. * instead of its head.
  8445. */
  8446. ellipsoidOffset: Vector3;
  8447. /**
  8448. * Enable or disable collisions of the camera with the rest of the scene objects.
  8449. */
  8450. checkCollisions: boolean;
  8451. /**
  8452. * Enable or disable gravity on the camera.
  8453. */
  8454. applyGravity: boolean;
  8455. /**
  8456. * Define the input manager associated to the camera.
  8457. */
  8458. inputs: FreeCameraInputsManager;
  8459. /**
  8460. * Gets the input sensibility for a mouse input. (default is 2000.0)
  8461. * Higher values reduce sensitivity.
  8462. */
  8463. /**
  8464. * Sets the input sensibility for a mouse input. (default is 2000.0)
  8465. * Higher values reduce sensitivity.
  8466. */
  8467. angularSensibility: number;
  8468. /**
  8469. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8470. */
  8471. keysUp: number[];
  8472. /**
  8473. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8474. */
  8475. keysDown: number[];
  8476. /**
  8477. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8478. */
  8479. keysLeft: number[];
  8480. /**
  8481. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8482. */
  8483. keysRight: number[];
  8484. /**
  8485. * Event raised when the camera collide with a mesh in the scene.
  8486. */
  8487. onCollide: (collidedMesh: AbstractMesh) => void;
  8488. private _collider;
  8489. private _needMoveForGravity;
  8490. private _oldPosition;
  8491. private _diffPosition;
  8492. private _newPosition;
  8493. /** @hidden */
  8494. _localDirection: Vector3;
  8495. /** @hidden */
  8496. _transformedDirection: Vector3;
  8497. /**
  8498. * Instantiates a Free Camera.
  8499. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  8500. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  8501. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  8502. * @param name Define the name of the camera in the scene
  8503. * @param position Define the start position of the camera in the scene
  8504. * @param scene Define the scene the camera belongs to
  8505. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8506. */
  8507. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8508. /**
  8509. * Attached controls to the current camera.
  8510. * @param element Defines the element the controls should be listened from
  8511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8512. */
  8513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8514. /**
  8515. * Detach the current controls from the camera.
  8516. * The camera will stop reacting to inputs.
  8517. * @param element Defines the element to stop listening the inputs from
  8518. */
  8519. detachControl(element: HTMLElement): void;
  8520. private _collisionMask;
  8521. /**
  8522. * Define a collision mask to limit the list of object the camera can collide with
  8523. */
  8524. collisionMask: number;
  8525. /** @hidden */
  8526. _collideWithWorld(displacement: Vector3): void;
  8527. private _onCollisionPositionChange;
  8528. /** @hidden */
  8529. _checkInputs(): void;
  8530. /** @hidden */
  8531. _decideIfNeedsToMove(): boolean;
  8532. /** @hidden */
  8533. _updatePosition(): void;
  8534. /**
  8535. * Destroy the camera and release the current resources hold by it.
  8536. */
  8537. dispose(): void;
  8538. /**
  8539. * Gets the current object class name.
  8540. * @return the class name
  8541. */
  8542. getClassName(): string;
  8543. }
  8544. }
  8545. declare module "babylonjs/Gamepads/gamepad" {
  8546. import { Observable } from "babylonjs/Misc/observable";
  8547. /**
  8548. * Represents a gamepad control stick position
  8549. */
  8550. export class StickValues {
  8551. /**
  8552. * The x component of the control stick
  8553. */
  8554. x: number;
  8555. /**
  8556. * The y component of the control stick
  8557. */
  8558. y: number;
  8559. /**
  8560. * Initializes the gamepad x and y control stick values
  8561. * @param x The x component of the gamepad control stick value
  8562. * @param y The y component of the gamepad control stick value
  8563. */
  8564. constructor(
  8565. /**
  8566. * The x component of the control stick
  8567. */
  8568. x: number,
  8569. /**
  8570. * The y component of the control stick
  8571. */
  8572. y: number);
  8573. }
  8574. /**
  8575. * An interface which manages callbacks for gamepad button changes
  8576. */
  8577. export interface GamepadButtonChanges {
  8578. /**
  8579. * Called when a gamepad has been changed
  8580. */
  8581. changed: boolean;
  8582. /**
  8583. * Called when a gamepad press event has been triggered
  8584. */
  8585. pressChanged: boolean;
  8586. /**
  8587. * Called when a touch event has been triggered
  8588. */
  8589. touchChanged: boolean;
  8590. /**
  8591. * Called when a value has changed
  8592. */
  8593. valueChanged: boolean;
  8594. }
  8595. /**
  8596. * Represents a gamepad
  8597. */
  8598. export class Gamepad {
  8599. /**
  8600. * The id of the gamepad
  8601. */
  8602. id: string;
  8603. /**
  8604. * The index of the gamepad
  8605. */
  8606. index: number;
  8607. /**
  8608. * The browser gamepad
  8609. */
  8610. browserGamepad: any;
  8611. /**
  8612. * Specifies what type of gamepad this represents
  8613. */
  8614. type: number;
  8615. private _leftStick;
  8616. private _rightStick;
  8617. /** @hidden */
  8618. _isConnected: boolean;
  8619. private _leftStickAxisX;
  8620. private _leftStickAxisY;
  8621. private _rightStickAxisX;
  8622. private _rightStickAxisY;
  8623. /**
  8624. * Triggered when the left control stick has been changed
  8625. */
  8626. private _onleftstickchanged;
  8627. /**
  8628. * Triggered when the right control stick has been changed
  8629. */
  8630. private _onrightstickchanged;
  8631. /**
  8632. * Represents a gamepad controller
  8633. */
  8634. static GAMEPAD: number;
  8635. /**
  8636. * Represents a generic controller
  8637. */
  8638. static GENERIC: number;
  8639. /**
  8640. * Represents an XBox controller
  8641. */
  8642. static XBOX: number;
  8643. /**
  8644. * Represents a pose-enabled controller
  8645. */
  8646. static POSE_ENABLED: number;
  8647. /**
  8648. * Specifies whether the left control stick should be Y-inverted
  8649. */
  8650. protected _invertLeftStickY: boolean;
  8651. /**
  8652. * Specifies if the gamepad has been connected
  8653. */
  8654. readonly isConnected: boolean;
  8655. /**
  8656. * Initializes the gamepad
  8657. * @param id The id of the gamepad
  8658. * @param index The index of the gamepad
  8659. * @param browserGamepad The browser gamepad
  8660. * @param leftStickX The x component of the left joystick
  8661. * @param leftStickY The y component of the left joystick
  8662. * @param rightStickX The x component of the right joystick
  8663. * @param rightStickY The y component of the right joystick
  8664. */
  8665. constructor(
  8666. /**
  8667. * The id of the gamepad
  8668. */
  8669. id: string,
  8670. /**
  8671. * The index of the gamepad
  8672. */
  8673. index: number,
  8674. /**
  8675. * The browser gamepad
  8676. */
  8677. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  8678. /**
  8679. * Callback triggered when the left joystick has changed
  8680. * @param callback
  8681. */
  8682. onleftstickchanged(callback: (values: StickValues) => void): void;
  8683. /**
  8684. * Callback triggered when the right joystick has changed
  8685. * @param callback
  8686. */
  8687. onrightstickchanged(callback: (values: StickValues) => void): void;
  8688. /**
  8689. * Gets the left joystick
  8690. */
  8691. /**
  8692. * Sets the left joystick values
  8693. */
  8694. leftStick: StickValues;
  8695. /**
  8696. * Gets the right joystick
  8697. */
  8698. /**
  8699. * Sets the right joystick value
  8700. */
  8701. rightStick: StickValues;
  8702. /**
  8703. * Updates the gamepad joystick positions
  8704. */
  8705. update(): void;
  8706. /**
  8707. * Disposes the gamepad
  8708. */
  8709. dispose(): void;
  8710. }
  8711. /**
  8712. * Represents a generic gamepad
  8713. */
  8714. export class GenericPad extends Gamepad {
  8715. private _buttons;
  8716. private _onbuttondown;
  8717. private _onbuttonup;
  8718. /**
  8719. * Observable triggered when a button has been pressed
  8720. */
  8721. onButtonDownObservable: Observable<number>;
  8722. /**
  8723. * Observable triggered when a button has been released
  8724. */
  8725. onButtonUpObservable: Observable<number>;
  8726. /**
  8727. * Callback triggered when a button has been pressed
  8728. * @param callback Called when a button has been pressed
  8729. */
  8730. onbuttondown(callback: (buttonPressed: number) => void): void;
  8731. /**
  8732. * Callback triggered when a button has been released
  8733. * @param callback Called when a button has been released
  8734. */
  8735. onbuttonup(callback: (buttonReleased: number) => void): void;
  8736. /**
  8737. * Initializes the generic gamepad
  8738. * @param id The id of the generic gamepad
  8739. * @param index The index of the generic gamepad
  8740. * @param browserGamepad The browser gamepad
  8741. */
  8742. constructor(id: string, index: number, browserGamepad: any);
  8743. private _setButtonValue;
  8744. /**
  8745. * Updates the generic gamepad
  8746. */
  8747. update(): void;
  8748. /**
  8749. * Disposes the generic gamepad
  8750. */
  8751. dispose(): void;
  8752. }
  8753. }
  8754. declare module "babylonjs/Meshes/transformNode" {
  8755. import { DeepImmutable } from "babylonjs/types";
  8756. import { Observable } from "babylonjs/Misc/observable";
  8757. import { Nullable } from "babylonjs/types";
  8758. import { Camera } from "babylonjs/Cameras/camera";
  8759. import { Scene } from "babylonjs/scene";
  8760. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8761. import { Node } from "babylonjs/node";
  8762. import { Bone } from "babylonjs/Bones/bone";
  8763. /**
  8764. * 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.
  8765. * @see https://doc.babylonjs.com/how_to/transformnode
  8766. */
  8767. export class TransformNode extends Node {
  8768. /**
  8769. * Object will not rotate to face the camera
  8770. */
  8771. static BILLBOARDMODE_NONE: number;
  8772. /**
  8773. * Object will rotate to face the camera but only on the x axis
  8774. */
  8775. static BILLBOARDMODE_X: number;
  8776. /**
  8777. * Object will rotate to face the camera but only on the y axis
  8778. */
  8779. static BILLBOARDMODE_Y: number;
  8780. /**
  8781. * Object will rotate to face the camera but only on the z axis
  8782. */
  8783. static BILLBOARDMODE_Z: number;
  8784. /**
  8785. * Object will rotate to face the camera
  8786. */
  8787. static BILLBOARDMODE_ALL: number;
  8788. private _forward;
  8789. private _forwardInverted;
  8790. private _up;
  8791. private _right;
  8792. private _rightInverted;
  8793. private _position;
  8794. private _rotation;
  8795. private _rotationQuaternion;
  8796. protected _scaling: Vector3;
  8797. protected _isDirty: boolean;
  8798. private _transformToBoneReferal;
  8799. /**
  8800. * Set the billboard mode. Default is 0.
  8801. *
  8802. * | Value | Type | Description |
  8803. * | --- | --- | --- |
  8804. * | 0 | BILLBOARDMODE_NONE | |
  8805. * | 1 | BILLBOARDMODE_X | |
  8806. * | 2 | BILLBOARDMODE_Y | |
  8807. * | 4 | BILLBOARDMODE_Z | |
  8808. * | 7 | BILLBOARDMODE_ALL | |
  8809. *
  8810. */
  8811. billboardMode: number;
  8812. /**
  8813. * 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
  8814. */
  8815. scalingDeterminant: number;
  8816. /**
  8817. * Sets the distance of the object to max, often used by skybox
  8818. */
  8819. infiniteDistance: boolean;
  8820. /**
  8821. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8822. * By default the system will update normals to compensate
  8823. */
  8824. ignoreNonUniformScaling: boolean;
  8825. /** @hidden */
  8826. _poseMatrix: Matrix;
  8827. /** @hidden */
  8828. _localMatrix: Matrix;
  8829. private _absolutePosition;
  8830. private _pivotMatrix;
  8831. private _pivotMatrixInverse;
  8832. protected _postMultiplyPivotMatrix: boolean;
  8833. protected _isWorldMatrixFrozen: boolean;
  8834. /** @hidden */
  8835. _indexInSceneTransformNodesArray: number;
  8836. /**
  8837. * An event triggered after the world matrix is updated
  8838. */
  8839. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8840. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8841. /**
  8842. * Gets a string identifying the name of the class
  8843. * @returns "TransformNode" string
  8844. */
  8845. getClassName(): string;
  8846. /**
  8847. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8848. */
  8849. position: Vector3;
  8850. /**
  8851. * 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)).
  8852. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8853. */
  8854. rotation: Vector3;
  8855. /**
  8856. * 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)).
  8857. */
  8858. scaling: Vector3;
  8859. /**
  8860. * 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).
  8861. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8862. */
  8863. rotationQuaternion: Nullable<Quaternion>;
  8864. /**
  8865. * The forward direction of that transform in world space.
  8866. */
  8867. readonly forward: Vector3;
  8868. /**
  8869. * The up direction of that transform in world space.
  8870. */
  8871. readonly up: Vector3;
  8872. /**
  8873. * The right direction of that transform in world space.
  8874. */
  8875. readonly right: Vector3;
  8876. /**
  8877. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8878. * @param matrix the matrix to copy the pose from
  8879. * @returns this TransformNode.
  8880. */
  8881. updatePoseMatrix(matrix: Matrix): TransformNode;
  8882. /**
  8883. * Returns the mesh Pose matrix.
  8884. * @returns the pose matrix
  8885. */
  8886. getPoseMatrix(): Matrix;
  8887. /** @hidden */
  8888. _isSynchronized(): boolean;
  8889. /** @hidden */
  8890. _initCache(): void;
  8891. /**
  8892. * Flag the transform node as dirty (Forcing it to update everything)
  8893. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8894. * @returns this transform node
  8895. */
  8896. markAsDirty(property: string): TransformNode;
  8897. /**
  8898. * Returns the current mesh absolute position.
  8899. * Returns a Vector3.
  8900. */
  8901. readonly absolutePosition: Vector3;
  8902. /**
  8903. * Sets a new matrix to apply before all other transformation
  8904. * @param matrix defines the transform matrix
  8905. * @returns the current TransformNode
  8906. */
  8907. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8908. /**
  8909. * Sets a new pivot matrix to the current node
  8910. * @param matrix defines the new pivot matrix to use
  8911. * @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
  8912. * @returns the current TransformNode
  8913. */
  8914. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8915. /**
  8916. * Returns the mesh pivot matrix.
  8917. * Default : Identity.
  8918. * @returns the matrix
  8919. */
  8920. getPivotMatrix(): Matrix;
  8921. /**
  8922. * Prevents the World matrix to be computed any longer.
  8923. * @returns the TransformNode.
  8924. */
  8925. freezeWorldMatrix(): TransformNode;
  8926. /**
  8927. * Allows back the World matrix computation.
  8928. * @returns the TransformNode.
  8929. */
  8930. unfreezeWorldMatrix(): this;
  8931. /**
  8932. * True if the World matrix has been frozen.
  8933. */
  8934. readonly isWorldMatrixFrozen: boolean;
  8935. /**
  8936. * Retuns the mesh absolute position in the World.
  8937. * @returns a Vector3.
  8938. */
  8939. getAbsolutePosition(): Vector3;
  8940. /**
  8941. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8942. * @param absolutePosition the absolute position to set
  8943. * @returns the TransformNode.
  8944. */
  8945. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8946. /**
  8947. * Sets the mesh position in its local space.
  8948. * @param vector3 the position to set in localspace
  8949. * @returns the TransformNode.
  8950. */
  8951. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8952. /**
  8953. * Returns the mesh position in the local space from the current World matrix values.
  8954. * @returns a new Vector3.
  8955. */
  8956. getPositionExpressedInLocalSpace(): Vector3;
  8957. /**
  8958. * Translates the mesh along the passed Vector3 in its local space.
  8959. * @param vector3 the distance to translate in localspace
  8960. * @returns the TransformNode.
  8961. */
  8962. locallyTranslate(vector3: Vector3): TransformNode;
  8963. private static _lookAtVectorCache;
  8964. /**
  8965. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8966. * @param targetPoint the position (must be in same space as current mesh) to look at
  8967. * @param yawCor optional yaw (y-axis) correction in radians
  8968. * @param pitchCor optional pitch (x-axis) correction in radians
  8969. * @param rollCor optional roll (z-axis) correction in radians
  8970. * @param space the choosen space of the target
  8971. * @returns the TransformNode.
  8972. */
  8973. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8974. /**
  8975. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8976. * This Vector3 is expressed in the World space.
  8977. * @param localAxis axis to rotate
  8978. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8979. */
  8980. getDirection(localAxis: Vector3): Vector3;
  8981. /**
  8982. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8983. * localAxis is expressed in the mesh local space.
  8984. * result is computed in the Wordl space from the mesh World matrix.
  8985. * @param localAxis axis to rotate
  8986. * @param result the resulting transformnode
  8987. * @returns this TransformNode.
  8988. */
  8989. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8990. /**
  8991. * Sets this transform node rotation to the given local axis.
  8992. * @param localAxis the axis in local space
  8993. * @param yawCor optional yaw (y-axis) correction in radians
  8994. * @param pitchCor optional pitch (x-axis) correction in radians
  8995. * @param rollCor optional roll (z-axis) correction in radians
  8996. * @returns this TransformNode
  8997. */
  8998. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8999. /**
  9000. * Sets a new pivot point to the current node
  9001. * @param point defines the new pivot point to use
  9002. * @param space defines if the point is in world or local space (local by default)
  9003. * @returns the current TransformNode
  9004. */
  9005. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  9006. /**
  9007. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  9008. * @returns the pivot point
  9009. */
  9010. getPivotPoint(): Vector3;
  9011. /**
  9012. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  9013. * @param result the vector3 to store the result
  9014. * @returns this TransformNode.
  9015. */
  9016. getPivotPointToRef(result: Vector3): TransformNode;
  9017. /**
  9018. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  9019. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  9020. */
  9021. getAbsolutePivotPoint(): Vector3;
  9022. /**
  9023. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  9024. * @param result vector3 to store the result
  9025. * @returns this TransformNode.
  9026. */
  9027. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  9028. /**
  9029. * Defines the passed node as the parent of the current node.
  9030. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  9031. * @param node the node ot set as the parent
  9032. * @returns this TransformNode.
  9033. */
  9034. setParent(node: Nullable<Node>): TransformNode;
  9035. private _nonUniformScaling;
  9036. /**
  9037. * True if the scaling property of this object is non uniform eg. (1,2,1)
  9038. */
  9039. readonly nonUniformScaling: boolean;
  9040. /** @hidden */
  9041. _updateNonUniformScalingState(value: boolean): boolean;
  9042. /**
  9043. * Attach the current TransformNode to another TransformNode associated with a bone
  9044. * @param bone Bone affecting the TransformNode
  9045. * @param affectedTransformNode TransformNode associated with the bone
  9046. * @returns this object
  9047. */
  9048. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  9049. /**
  9050. * Detach the transform node if its associated with a bone
  9051. * @returns this object
  9052. */
  9053. detachFromBone(): TransformNode;
  9054. private static _rotationAxisCache;
  9055. /**
  9056. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  9057. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9058. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9059. * The passed axis is also normalized.
  9060. * @param axis the axis to rotate around
  9061. * @param amount the amount to rotate in radians
  9062. * @param space Space to rotate in (Default: local)
  9063. * @returns the TransformNode.
  9064. */
  9065. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  9066. /**
  9067. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  9068. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  9069. * The passed axis is also normalized. .
  9070. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  9071. * @param point the point to rotate around
  9072. * @param axis the axis to rotate around
  9073. * @param amount the amount to rotate in radians
  9074. * @returns the TransformNode
  9075. */
  9076. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  9077. /**
  9078. * Translates the mesh along the axis vector for the passed distance in the given space.
  9079. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  9080. * @param axis the axis to translate in
  9081. * @param distance the distance to translate
  9082. * @param space Space to rotate in (Default: local)
  9083. * @returns the TransformNode.
  9084. */
  9085. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  9086. /**
  9087. * Adds a rotation step to the mesh current rotation.
  9088. * x, y, z are Euler angles expressed in radians.
  9089. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  9090. * This means this rotation is made in the mesh local space only.
  9091. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  9092. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  9093. * ```javascript
  9094. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  9095. * ```
  9096. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  9097. * 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.
  9098. * @param x Rotation to add
  9099. * @param y Rotation to add
  9100. * @param z Rotation to add
  9101. * @returns the TransformNode.
  9102. */
  9103. addRotation(x: number, y: number, z: number): TransformNode;
  9104. /**
  9105. * Computes the world matrix of the node
  9106. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9107. * @returns the world matrix
  9108. */
  9109. computeWorldMatrix(force?: boolean): Matrix;
  9110. protected _afterComputeWorldMatrix(): void;
  9111. /**
  9112. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  9113. * @param func callback function to add
  9114. *
  9115. * @returns the TransformNode.
  9116. */
  9117. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9118. /**
  9119. * Removes a registered callback function.
  9120. * @param func callback function to remove
  9121. * @returns the TransformNode.
  9122. */
  9123. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  9124. /**
  9125. * Gets the position of the current mesh in camera space
  9126. * @param camera defines the camera to use
  9127. * @returns a position
  9128. */
  9129. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  9130. /**
  9131. * Returns the distance from the mesh to the active camera
  9132. * @param camera defines the camera to use
  9133. * @returns the distance
  9134. */
  9135. getDistanceToCamera(camera?: Nullable<Camera>): number;
  9136. /**
  9137. * Clone the current transform node
  9138. * @param name Name of the new clone
  9139. * @param newParent New parent for the clone
  9140. * @param doNotCloneChildren Do not clone children hierarchy
  9141. * @returns the new transform node
  9142. */
  9143. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  9144. /**
  9145. * Serializes the objects information.
  9146. * @param currentSerializationObject defines the object to serialize in
  9147. * @returns the serialized object
  9148. */
  9149. serialize(currentSerializationObject?: any): any;
  9150. /**
  9151. * Returns a new TransformNode object parsed from the source provided.
  9152. * @param parsedTransformNode is the source.
  9153. * @param scene the scne the object belongs to
  9154. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  9155. * @returns a new TransformNode object parsed from the source provided.
  9156. */
  9157. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  9158. /**
  9159. * Get all child-transformNodes of this node
  9160. * @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
  9161. * @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
  9162. * @returns an array of TransformNode
  9163. */
  9164. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  9165. /**
  9166. * Releases resources associated with this transform node.
  9167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9169. */
  9170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9171. }
  9172. }
  9173. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  9174. import { Observable } from "babylonjs/Misc/observable";
  9175. import { Nullable } from "babylonjs/types";
  9176. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  9177. import { TransformNode } from "babylonjs/Meshes/transformNode";
  9178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9179. import { Ray } from "babylonjs/Culling/ray";
  9180. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  9181. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  9182. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  9183. /**
  9184. * Defines the types of pose enabled controllers that are supported
  9185. */
  9186. export enum PoseEnabledControllerType {
  9187. /**
  9188. * HTC Vive
  9189. */
  9190. VIVE = 0,
  9191. /**
  9192. * Oculus Rift
  9193. */
  9194. OCULUS = 1,
  9195. /**
  9196. * Windows mixed reality
  9197. */
  9198. WINDOWS = 2,
  9199. /**
  9200. * Samsung gear VR
  9201. */
  9202. GEAR_VR = 3,
  9203. /**
  9204. * Google Daydream
  9205. */
  9206. DAYDREAM = 4,
  9207. /**
  9208. * Generic
  9209. */
  9210. GENERIC = 5
  9211. }
  9212. /**
  9213. * Defines the MutableGamepadButton interface for the state of a gamepad button
  9214. */
  9215. export interface MutableGamepadButton {
  9216. /**
  9217. * Value of the button/trigger
  9218. */
  9219. value: number;
  9220. /**
  9221. * If the button/trigger is currently touched
  9222. */
  9223. touched: boolean;
  9224. /**
  9225. * If the button/trigger is currently pressed
  9226. */
  9227. pressed: boolean;
  9228. }
  9229. /**
  9230. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  9231. * @hidden
  9232. */
  9233. export interface ExtendedGamepadButton extends GamepadButton {
  9234. /**
  9235. * If the button/trigger is currently pressed
  9236. */
  9237. readonly pressed: boolean;
  9238. /**
  9239. * If the button/trigger is currently touched
  9240. */
  9241. readonly touched: boolean;
  9242. /**
  9243. * Value of the button/trigger
  9244. */
  9245. readonly value: number;
  9246. }
  9247. /** @hidden */
  9248. export interface _GamePadFactory {
  9249. /**
  9250. * Returns wether or not the current gamepad can be created for this type of controller.
  9251. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9252. * @returns true if it can be created, otherwise false
  9253. */
  9254. canCreate(gamepadInfo: any): boolean;
  9255. /**
  9256. * Creates a new instance of the Gamepad.
  9257. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  9258. * @returns the new gamepad instance
  9259. */
  9260. create(gamepadInfo: any): Gamepad;
  9261. }
  9262. /**
  9263. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9264. */
  9265. export class PoseEnabledControllerHelper {
  9266. /** @hidden */
  9267. static _ControllerFactories: _GamePadFactory[];
  9268. /** @hidden */
  9269. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  9270. /**
  9271. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  9272. * @param vrGamepad the gamepad to initialized
  9273. * @returns a vr controller of the type the gamepad identified as
  9274. */
  9275. static InitiateController(vrGamepad: any): Gamepad;
  9276. }
  9277. /**
  9278. * Defines the PoseEnabledController object that contains state of a vr capable controller
  9279. */
  9280. export class PoseEnabledController extends Gamepad implements PoseControlled {
  9281. private _deviceRoomPosition;
  9282. private _deviceRoomRotationQuaternion;
  9283. /**
  9284. * The device position in babylon space
  9285. */
  9286. devicePosition: Vector3;
  9287. /**
  9288. * The device rotation in babylon space
  9289. */
  9290. deviceRotationQuaternion: Quaternion;
  9291. /**
  9292. * The scale factor of the device in babylon space
  9293. */
  9294. deviceScaleFactor: number;
  9295. /**
  9296. * (Likely devicePosition should be used instead) The device position in its room space
  9297. */
  9298. position: Vector3;
  9299. /**
  9300. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  9301. */
  9302. rotationQuaternion: Quaternion;
  9303. /**
  9304. * The type of controller (Eg. Windows mixed reality)
  9305. */
  9306. controllerType: PoseEnabledControllerType;
  9307. protected _calculatedPosition: Vector3;
  9308. private _calculatedRotation;
  9309. /**
  9310. * The raw pose from the device
  9311. */
  9312. rawPose: DevicePose;
  9313. private _trackPosition;
  9314. private _maxRotationDistFromHeadset;
  9315. private _draggedRoomRotation;
  9316. /**
  9317. * @hidden
  9318. */
  9319. _disableTrackPosition(fixedPosition: Vector3): void;
  9320. /**
  9321. * Internal, the mesh attached to the controller
  9322. * @hidden
  9323. */
  9324. _mesh: Nullable<AbstractMesh>;
  9325. private _poseControlledCamera;
  9326. private _leftHandSystemQuaternion;
  9327. /**
  9328. * Internal, matrix used to convert room space to babylon space
  9329. * @hidden
  9330. */
  9331. _deviceToWorld: Matrix;
  9332. /**
  9333. * Node to be used when casting a ray from the controller
  9334. * @hidden
  9335. */
  9336. _pointingPoseNode: Nullable<TransformNode>;
  9337. /**
  9338. * Name of the child mesh that can be used to cast a ray from the controller
  9339. */
  9340. static readonly POINTING_POSE: string;
  9341. /**
  9342. * Creates a new PoseEnabledController from a gamepad
  9343. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  9344. */
  9345. constructor(browserGamepad: any);
  9346. private _workingMatrix;
  9347. /**
  9348. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  9349. */
  9350. update(): void;
  9351. /**
  9352. * Updates only the pose device and mesh without doing any button event checking
  9353. */
  9354. protected _updatePoseAndMesh(): void;
  9355. /**
  9356. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  9357. * @param poseData raw pose fromthe device
  9358. */
  9359. updateFromDevice(poseData: DevicePose): void;
  9360. /**
  9361. * @hidden
  9362. */
  9363. _meshAttachedObservable: Observable<AbstractMesh>;
  9364. /**
  9365. * Attaches a mesh to the controller
  9366. * @param mesh the mesh to be attached
  9367. */
  9368. attachToMesh(mesh: AbstractMesh): void;
  9369. /**
  9370. * Attaches the controllers mesh to a camera
  9371. * @param camera the camera the mesh should be attached to
  9372. */
  9373. attachToPoseControlledCamera(camera: TargetCamera): void;
  9374. /**
  9375. * Disposes of the controller
  9376. */
  9377. dispose(): void;
  9378. /**
  9379. * The mesh that is attached to the controller
  9380. */
  9381. readonly mesh: Nullable<AbstractMesh>;
  9382. /**
  9383. * Gets the ray of the controller in the direction the controller is pointing
  9384. * @param length the length the resulting ray should be
  9385. * @returns a ray in the direction the controller is pointing
  9386. */
  9387. getForwardRay(length?: number): Ray;
  9388. }
  9389. }
  9390. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  9391. import { Observable } from "babylonjs/Misc/observable";
  9392. import { Scene } from "babylonjs/scene";
  9393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9394. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  9395. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  9396. /**
  9397. * Defines the WebVRController object that represents controllers tracked in 3D space
  9398. */
  9399. export abstract class WebVRController extends PoseEnabledController {
  9400. /**
  9401. * Internal, the default controller model for the controller
  9402. */
  9403. protected _defaultModel: AbstractMesh;
  9404. /**
  9405. * Fired when the trigger state has changed
  9406. */
  9407. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  9408. /**
  9409. * Fired when the main button state has changed
  9410. */
  9411. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  9412. /**
  9413. * Fired when the secondary button state has changed
  9414. */
  9415. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  9416. /**
  9417. * Fired when the pad state has changed
  9418. */
  9419. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  9420. /**
  9421. * Fired when controllers stick values have changed
  9422. */
  9423. onPadValuesChangedObservable: Observable<StickValues>;
  9424. /**
  9425. * Array of button availible on the controller
  9426. */
  9427. protected _buttons: Array<MutableGamepadButton>;
  9428. private _onButtonStateChange;
  9429. /**
  9430. * Fired when a controller button's state has changed
  9431. * @param callback the callback containing the button that was modified
  9432. */
  9433. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  9434. /**
  9435. * X and Y axis corrisponding to the controllers joystick
  9436. */
  9437. pad: StickValues;
  9438. /**
  9439. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  9440. */
  9441. hand: string;
  9442. /**
  9443. * The default controller model for the controller
  9444. */
  9445. readonly defaultModel: AbstractMesh;
  9446. /**
  9447. * Creates a new WebVRController from a gamepad
  9448. * @param vrGamepad the gamepad that the WebVRController should be created from
  9449. */
  9450. constructor(vrGamepad: any);
  9451. /**
  9452. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  9453. */
  9454. update(): void;
  9455. /**
  9456. * Function to be called when a button is modified
  9457. */
  9458. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  9459. /**
  9460. * Loads a mesh and attaches it to the controller
  9461. * @param scene the scene the mesh should be added to
  9462. * @param meshLoaded callback for when the mesh has been loaded
  9463. */
  9464. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  9465. private _setButtonValue;
  9466. private _changes;
  9467. private _checkChanges;
  9468. /**
  9469. * Disposes of th webVRCOntroller
  9470. */
  9471. dispose(): void;
  9472. }
  9473. }
  9474. declare module "babylonjs/Lights/shadowLight" {
  9475. import { Camera } from "babylonjs/Cameras/camera";
  9476. import { Scene } from "babylonjs/scene";
  9477. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9479. import { Light } from "babylonjs/Lights/light";
  9480. /**
  9481. * Interface describing all the common properties and methods a shadow light needs to implement.
  9482. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9483. * as well as binding the different shadow properties to the effects.
  9484. */
  9485. export interface IShadowLight extends Light {
  9486. /**
  9487. * The light id in the scene (used in scene.findLighById for instance)
  9488. */
  9489. id: string;
  9490. /**
  9491. * The position the shdow will be casted from.
  9492. */
  9493. position: Vector3;
  9494. /**
  9495. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9496. */
  9497. direction: Vector3;
  9498. /**
  9499. * The transformed position. Position of the light in world space taking parenting in account.
  9500. */
  9501. transformedPosition: Vector3;
  9502. /**
  9503. * The transformed direction. Direction of the light in world space taking parenting in account.
  9504. */
  9505. transformedDirection: Vector3;
  9506. /**
  9507. * The friendly name of the light in the scene.
  9508. */
  9509. name: string;
  9510. /**
  9511. * Defines the shadow projection clipping minimum z value.
  9512. */
  9513. shadowMinZ: number;
  9514. /**
  9515. * Defines the shadow projection clipping maximum z value.
  9516. */
  9517. shadowMaxZ: number;
  9518. /**
  9519. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9520. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9521. */
  9522. computeTransformedInformation(): boolean;
  9523. /**
  9524. * Gets the scene the light belongs to.
  9525. * @returns The scene
  9526. */
  9527. getScene(): Scene;
  9528. /**
  9529. * Callback defining a custom Projection Matrix Builder.
  9530. * This can be used to override the default projection matrix computation.
  9531. */
  9532. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9533. /**
  9534. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9535. * @param matrix The materix to updated with the projection information
  9536. * @param viewMatrix The transform matrix of the light
  9537. * @param renderList The list of mesh to render in the map
  9538. * @returns The current light
  9539. */
  9540. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9541. /**
  9542. * Gets the current depth scale used in ESM.
  9543. * @returns The scale
  9544. */
  9545. getDepthScale(): number;
  9546. /**
  9547. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9548. * @returns true if a cube texture needs to be use
  9549. */
  9550. needCube(): boolean;
  9551. /**
  9552. * Detects if the projection matrix requires to be recomputed this frame.
  9553. * @returns true if it requires to be recomputed otherwise, false.
  9554. */
  9555. needProjectionMatrixCompute(): boolean;
  9556. /**
  9557. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9558. */
  9559. forceProjectionMatrixCompute(): void;
  9560. /**
  9561. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9562. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9563. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9564. */
  9565. getShadowDirection(faceIndex?: number): Vector3;
  9566. /**
  9567. * Gets the minZ used for shadow according to both the scene and the light.
  9568. * @param activeCamera The camera we are returning the min for
  9569. * @returns the depth min z
  9570. */
  9571. getDepthMinZ(activeCamera: Camera): number;
  9572. /**
  9573. * Gets the maxZ used for shadow according to both the scene and the light.
  9574. * @param activeCamera The camera we are returning the max for
  9575. * @returns the depth max z
  9576. */
  9577. getDepthMaxZ(activeCamera: Camera): number;
  9578. }
  9579. /**
  9580. * Base implementation IShadowLight
  9581. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9582. */
  9583. export abstract class ShadowLight extends Light implements IShadowLight {
  9584. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9585. protected _position: Vector3;
  9586. protected _setPosition(value: Vector3): void;
  9587. /**
  9588. * Sets the position the shadow will be casted from. Also use as the light position for both
  9589. * point and spot lights.
  9590. */
  9591. /**
  9592. * Sets the position the shadow will be casted from. Also use as the light position for both
  9593. * point and spot lights.
  9594. */
  9595. position: Vector3;
  9596. protected _direction: Vector3;
  9597. protected _setDirection(value: Vector3): void;
  9598. /**
  9599. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9600. * Also use as the light direction on spot and directional lights.
  9601. */
  9602. /**
  9603. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9604. * Also use as the light direction on spot and directional lights.
  9605. */
  9606. direction: Vector3;
  9607. private _shadowMinZ;
  9608. /**
  9609. * Gets the shadow projection clipping minimum z value.
  9610. */
  9611. /**
  9612. * Sets the shadow projection clipping minimum z value.
  9613. */
  9614. shadowMinZ: number;
  9615. private _shadowMaxZ;
  9616. /**
  9617. * Sets the shadow projection clipping maximum z value.
  9618. */
  9619. /**
  9620. * Gets the shadow projection clipping maximum z value.
  9621. */
  9622. shadowMaxZ: number;
  9623. /**
  9624. * Callback defining a custom Projection Matrix Builder.
  9625. * This can be used to override the default projection matrix computation.
  9626. */
  9627. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9628. /**
  9629. * The transformed position. Position of the light in world space taking parenting in account.
  9630. */
  9631. transformedPosition: Vector3;
  9632. /**
  9633. * The transformed direction. Direction of the light in world space taking parenting in account.
  9634. */
  9635. transformedDirection: Vector3;
  9636. private _needProjectionMatrixCompute;
  9637. /**
  9638. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9639. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9640. */
  9641. computeTransformedInformation(): boolean;
  9642. /**
  9643. * Return the depth scale used for the shadow map.
  9644. * @returns the depth scale.
  9645. */
  9646. getDepthScale(): number;
  9647. /**
  9648. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9649. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9650. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9651. */
  9652. getShadowDirection(faceIndex?: number): Vector3;
  9653. /**
  9654. * Returns the ShadowLight absolute position in the World.
  9655. * @returns the position vector in world space
  9656. */
  9657. getAbsolutePosition(): Vector3;
  9658. /**
  9659. * Sets the ShadowLight direction toward the passed target.
  9660. * @param target The point tot target in local space
  9661. * @returns the updated ShadowLight direction
  9662. */
  9663. setDirectionToTarget(target: Vector3): Vector3;
  9664. /**
  9665. * Returns the light rotation in euler definition.
  9666. * @returns the x y z rotation in local space.
  9667. */
  9668. getRotation(): Vector3;
  9669. /**
  9670. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9671. * @returns true if a cube texture needs to be use
  9672. */
  9673. needCube(): boolean;
  9674. /**
  9675. * Detects if the projection matrix requires to be recomputed this frame.
  9676. * @returns true if it requires to be recomputed otherwise, false.
  9677. */
  9678. needProjectionMatrixCompute(): boolean;
  9679. /**
  9680. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9681. */
  9682. forceProjectionMatrixCompute(): void;
  9683. /** @hidden */
  9684. _initCache(): void;
  9685. /** @hidden */
  9686. _isSynchronized(): boolean;
  9687. /**
  9688. * Computes the world matrix of the node
  9689. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9690. * @returns the world matrix
  9691. */
  9692. computeWorldMatrix(force?: boolean): Matrix;
  9693. /**
  9694. * Gets the minZ used for shadow according to both the scene and the light.
  9695. * @param activeCamera The camera we are returning the min for
  9696. * @returns the depth min z
  9697. */
  9698. getDepthMinZ(activeCamera: Camera): number;
  9699. /**
  9700. * Gets the maxZ used for shadow according to both the scene and the light.
  9701. * @param activeCamera The camera we are returning the max for
  9702. * @returns the depth max z
  9703. */
  9704. getDepthMaxZ(activeCamera: Camera): number;
  9705. /**
  9706. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9707. * @param matrix The materix to updated with the projection information
  9708. * @param viewMatrix The transform matrix of the light
  9709. * @param renderList The list of mesh to render in the map
  9710. * @returns The current light
  9711. */
  9712. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9713. }
  9714. }
  9715. declare module "babylonjs/Materials/materialHelper" {
  9716. import { Nullable } from "babylonjs/types";
  9717. import { Scene } from "babylonjs/scene";
  9718. import { Engine } from "babylonjs/Engines/engine";
  9719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9720. import { Light } from "babylonjs/Lights/light";
  9721. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9722. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9724. /**
  9725. * "Static Class" containing the most commonly used helper while dealing with material for
  9726. * rendering purpose.
  9727. *
  9728. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9729. *
  9730. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9731. */
  9732. export class MaterialHelper {
  9733. /**
  9734. * Bind the current view position to an effect.
  9735. * @param effect The effect to be bound
  9736. * @param scene The scene the eyes position is used from
  9737. */
  9738. static BindEyePosition(effect: Effect, scene: Scene): void;
  9739. /**
  9740. * Helps preparing the defines values about the UVs in used in the effect.
  9741. * UVs are shared as much as we can accross channels in the shaders.
  9742. * @param texture The texture we are preparing the UVs for
  9743. * @param defines The defines to update
  9744. * @param key The channel key "diffuse", "specular"... used in the shader
  9745. */
  9746. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9747. /**
  9748. * Binds a texture matrix value to its corrsponding uniform
  9749. * @param texture The texture to bind the matrix for
  9750. * @param uniformBuffer The uniform buffer receivin the data
  9751. * @param key The channel key "diffuse", "specular"... used in the shader
  9752. */
  9753. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9754. /**
  9755. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9756. * @param mesh defines the current mesh
  9757. * @param scene defines the current scene
  9758. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9759. * @param pointsCloud defines if point cloud rendering has to be turned on
  9760. * @param fogEnabled defines if fog has to be turned on
  9761. * @param alphaTest defines if alpha testing has to be turned on
  9762. * @param defines defines the current list of defines
  9763. */
  9764. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9765. /**
  9766. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9767. * @param scene defines the current scene
  9768. * @param engine defines the current engine
  9769. * @param defines specifies the list of active defines
  9770. * @param useInstances defines if instances have to be turned on
  9771. * @param useClipPlane defines if clip plane have to be turned on
  9772. */
  9773. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9774. /**
  9775. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9776. * @param mesh The mesh containing the geometry data we will draw
  9777. * @param defines The defines to update
  9778. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9779. * @param useBones Precise whether bones should be used or not (override mesh info)
  9780. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9781. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9782. * @returns false if defines are considered not dirty and have not been checked
  9783. */
  9784. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9785. /**
  9786. * Prepares the defines related to the light information passed in parameter
  9787. * @param scene The scene we are intending to draw
  9788. * @param mesh The mesh the effect is compiling for
  9789. * @param defines The defines to update
  9790. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9791. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9792. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9793. * @returns true if normals will be required for the rest of the effect
  9794. */
  9795. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9796. /**
  9797. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9798. * that won t be acctive due to defines being turned off.
  9799. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9800. * @param samplersList The samplers list
  9801. * @param defines The defines helping in the list generation
  9802. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9803. */
  9804. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9805. /**
  9806. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9807. * @param defines The defines to update while falling back
  9808. * @param fallbacks The authorized effect fallbacks
  9809. * @param maxSimultaneousLights The maximum number of lights allowed
  9810. * @param rank the current rank of the Effect
  9811. * @returns The newly affected rank
  9812. */
  9813. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9814. /**
  9815. * Prepares the list of attributes required for morph targets according to the effect defines.
  9816. * @param attribs The current list of supported attribs
  9817. * @param mesh The mesh to prepare the morph targets attributes for
  9818. * @param defines The current Defines of the effect
  9819. */
  9820. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9821. /**
  9822. * Prepares the list of attributes required for bones according to the effect defines.
  9823. * @param attribs The current list of supported attribs
  9824. * @param mesh The mesh to prepare the bones attributes for
  9825. * @param defines The current Defines of the effect
  9826. * @param fallbacks The current efffect fallback strategy
  9827. */
  9828. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9829. /**
  9830. * Prepares the list of attributes required for instances according to the effect defines.
  9831. * @param attribs The current list of supported attribs
  9832. * @param defines The current Defines of the effect
  9833. */
  9834. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9835. /**
  9836. * Binds the light shadow information to the effect for the given mesh.
  9837. * @param light The light containing the generator
  9838. * @param scene The scene the lights belongs to
  9839. * @param mesh The mesh we are binding the information to render
  9840. * @param lightIndex The light index in the effect used to render the mesh
  9841. * @param effect The effect we are binding the data to
  9842. */
  9843. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9844. /**
  9845. * Binds the light information to the effect.
  9846. * @param light The light containing the generator
  9847. * @param effect The effect we are binding the data to
  9848. * @param lightIndex The light index in the effect used to render
  9849. */
  9850. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9851. /**
  9852. * Binds the lights information from the scene to the effect for the given mesh.
  9853. * @param scene The scene the lights belongs to
  9854. * @param mesh The mesh we are binding the information to render
  9855. * @param effect The effect we are binding the data to
  9856. * @param defines The generated defines for the effect
  9857. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9858. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9859. */
  9860. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9861. private static _tempFogColor;
  9862. /**
  9863. * Binds the fog information from the scene to the effect for the given mesh.
  9864. * @param scene The scene the lights belongs to
  9865. * @param mesh The mesh we are binding the information to render
  9866. * @param effect The effect we are binding the data to
  9867. * @param linearSpace Defines if the fog effect is applied in linear space
  9868. */
  9869. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9870. /**
  9871. * Binds the bones information from the mesh to the effect.
  9872. * @param mesh The mesh we are binding the information to render
  9873. * @param effect The effect we are binding the data to
  9874. */
  9875. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9876. /**
  9877. * Binds the morph targets information from the mesh to the effect.
  9878. * @param abstractMesh The mesh we are binding the information to render
  9879. * @param effect The effect we are binding the data to
  9880. */
  9881. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9882. /**
  9883. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9884. * @param defines The generated defines used in the effect
  9885. * @param effect The effect we are binding the data to
  9886. * @param scene The scene we are willing to render with logarithmic scale for
  9887. */
  9888. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9889. /**
  9890. * Binds the clip plane information from the scene to the effect.
  9891. * @param scene The scene the clip plane information are extracted from
  9892. * @param effect The effect we are binding the data to
  9893. */
  9894. static BindClipPlane(effect: Effect, scene: Scene): void;
  9895. }
  9896. }
  9897. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9898. /** @hidden */
  9899. export var shadowMapPixelShader: {
  9900. name: string;
  9901. shader: string;
  9902. };
  9903. }
  9904. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9905. /** @hidden */
  9906. export var bonesDeclaration: {
  9907. name: string;
  9908. shader: string;
  9909. };
  9910. }
  9911. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9912. /** @hidden */
  9913. export var morphTargetsVertexGlobalDeclaration: {
  9914. name: string;
  9915. shader: string;
  9916. };
  9917. }
  9918. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9919. /** @hidden */
  9920. export var morphTargetsVertexDeclaration: {
  9921. name: string;
  9922. shader: string;
  9923. };
  9924. }
  9925. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9926. /** @hidden */
  9927. export var instancesDeclaration: {
  9928. name: string;
  9929. shader: string;
  9930. };
  9931. }
  9932. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9933. /** @hidden */
  9934. export var helperFunctions: {
  9935. name: string;
  9936. shader: string;
  9937. };
  9938. }
  9939. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9940. /** @hidden */
  9941. export var morphTargetsVertex: {
  9942. name: string;
  9943. shader: string;
  9944. };
  9945. }
  9946. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9947. /** @hidden */
  9948. export var instancesVertex: {
  9949. name: string;
  9950. shader: string;
  9951. };
  9952. }
  9953. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9954. /** @hidden */
  9955. export var bonesVertex: {
  9956. name: string;
  9957. shader: string;
  9958. };
  9959. }
  9960. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9961. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9962. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9964. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9966. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9967. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9968. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9969. /** @hidden */
  9970. export var shadowMapVertexShader: {
  9971. name: string;
  9972. shader: string;
  9973. };
  9974. }
  9975. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9976. /** @hidden */
  9977. export var depthBoxBlurPixelShader: {
  9978. name: string;
  9979. shader: string;
  9980. };
  9981. }
  9982. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9983. import { Nullable } from "babylonjs/types";
  9984. import { Scene } from "babylonjs/scene";
  9985. import { Matrix } from "babylonjs/Maths/math";
  9986. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9988. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9989. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9990. import { Effect } from "babylonjs/Materials/effect";
  9991. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9992. import "babylonjs/Shaders/shadowMap.fragment";
  9993. import "babylonjs/Shaders/shadowMap.vertex";
  9994. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9995. import { Observable } from "babylonjs/Misc/observable";
  9996. /**
  9997. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9998. */
  9999. export interface ICustomShaderOptions {
  10000. /**
  10001. * Gets or sets the custom shader name to use
  10002. */
  10003. shaderName: string;
  10004. /**
  10005. * The list of attribute names used in the shader
  10006. */
  10007. attributes?: string[];
  10008. /**
  10009. * The list of unifrom names used in the shader
  10010. */
  10011. uniforms?: string[];
  10012. /**
  10013. * The list of sampler names used in the shader
  10014. */
  10015. samplers?: string[];
  10016. /**
  10017. * The list of defines used in the shader
  10018. */
  10019. defines?: string[];
  10020. }
  10021. /**
  10022. * Interface to implement to create a shadow generator compatible with BJS.
  10023. */
  10024. export interface IShadowGenerator {
  10025. /**
  10026. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10027. * @returns The render target texture if present otherwise, null
  10028. */
  10029. getShadowMap(): Nullable<RenderTargetTexture>;
  10030. /**
  10031. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10032. * @returns The render target texture if the shadow map is present otherwise, null
  10033. */
  10034. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10035. /**
  10036. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10037. * @param subMesh The submesh we want to render in the shadow map
  10038. * @param useInstances Defines wether will draw in the map using instances
  10039. * @returns true if ready otherwise, false
  10040. */
  10041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10042. /**
  10043. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10044. * @param defines Defines of the material we want to update
  10045. * @param lightIndex Index of the light in the enabled light list of the material
  10046. */
  10047. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  10048. /**
  10049. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10050. * defined in the generator but impacting the effect).
  10051. * It implies the unifroms available on the materials are the standard BJS ones.
  10052. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10053. * @param effect The effect we are binfing the information for
  10054. */
  10055. bindShadowLight(lightIndex: string, effect: Effect): void;
  10056. /**
  10057. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10058. * (eq to shadow prjection matrix * light transform matrix)
  10059. * @returns The transform matrix used to create the shadow map
  10060. */
  10061. getTransformMatrix(): Matrix;
  10062. /**
  10063. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10064. * Cube and 2D textures for instance.
  10065. */
  10066. recreateShadowMap(): void;
  10067. /**
  10068. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10069. * @param onCompiled Callback triggered at the and of the effects compilation
  10070. * @param options Sets of optional options forcing the compilation with different modes
  10071. */
  10072. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10073. useInstances: boolean;
  10074. }>): void;
  10075. /**
  10076. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10077. * @param options Sets of optional options forcing the compilation with different modes
  10078. * @returns A promise that resolves when the compilation completes
  10079. */
  10080. forceCompilationAsync(options?: Partial<{
  10081. useInstances: boolean;
  10082. }>): Promise<void>;
  10083. /**
  10084. * Serializes the shadow generator setup to a json object.
  10085. * @returns The serialized JSON object
  10086. */
  10087. serialize(): any;
  10088. /**
  10089. * Disposes the Shadow map and related Textures and effects.
  10090. */
  10091. dispose(): void;
  10092. }
  10093. /**
  10094. * Default implementation IShadowGenerator.
  10095. * This is the main object responsible of generating shadows in the framework.
  10096. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  10097. */
  10098. export class ShadowGenerator implements IShadowGenerator {
  10099. /**
  10100. * Shadow generator mode None: no filtering applied.
  10101. */
  10102. static readonly FILTER_NONE: number;
  10103. /**
  10104. * Shadow generator mode ESM: Exponential Shadow Mapping.
  10105. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10106. */
  10107. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  10108. /**
  10109. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  10110. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  10111. */
  10112. static readonly FILTER_POISSONSAMPLING: number;
  10113. /**
  10114. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  10115. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10116. */
  10117. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  10118. /**
  10119. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  10120. * edge artifacts on steep falloff.
  10121. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10122. */
  10123. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  10124. /**
  10125. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10126. * edge artifacts on steep falloff.
  10127. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10128. */
  10129. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10130. /**
  10131. * Shadow generator mode PCF: Percentage Closer Filtering
  10132. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10133. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10134. */
  10135. static readonly FILTER_PCF: number;
  10136. /**
  10137. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10138. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10139. * Contact Hardening
  10140. */
  10141. static readonly FILTER_PCSS: number;
  10142. /**
  10143. * Reserved for PCF and PCSS
  10144. * Highest Quality.
  10145. *
  10146. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10147. *
  10148. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10149. */
  10150. static readonly QUALITY_HIGH: number;
  10151. /**
  10152. * Reserved for PCF and PCSS
  10153. * Good tradeoff for quality/perf cross devices
  10154. *
  10155. * Execute PCF on a 3*3 kernel.
  10156. *
  10157. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10158. */
  10159. static readonly QUALITY_MEDIUM: number;
  10160. /**
  10161. * Reserved for PCF and PCSS
  10162. * The lowest quality but the fastest.
  10163. *
  10164. * Execute PCF on a 1*1 kernel.
  10165. *
  10166. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10167. */
  10168. static readonly QUALITY_LOW: number;
  10169. /** Gets or sets the custom shader name to use */
  10170. customShaderOptions: ICustomShaderOptions;
  10171. /**
  10172. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10173. */
  10174. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10175. private _bias;
  10176. /**
  10177. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10178. */
  10179. /**
  10180. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10181. */
  10182. bias: number;
  10183. private _normalBias;
  10184. /**
  10185. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10186. */
  10187. /**
  10188. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10189. */
  10190. normalBias: number;
  10191. private _blurBoxOffset;
  10192. /**
  10193. * Gets the blur box offset: offset applied during the blur pass.
  10194. * Only useful if useKernelBlur = false
  10195. */
  10196. /**
  10197. * Sets the blur box offset: offset applied during the blur pass.
  10198. * Only useful if useKernelBlur = false
  10199. */
  10200. blurBoxOffset: number;
  10201. private _blurScale;
  10202. /**
  10203. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10204. * 2 means half of the size.
  10205. */
  10206. /**
  10207. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10208. * 2 means half of the size.
  10209. */
  10210. blurScale: number;
  10211. private _blurKernel;
  10212. /**
  10213. * Gets the blur kernel: kernel size of the blur pass.
  10214. * Only useful if useKernelBlur = true
  10215. */
  10216. /**
  10217. * Sets the blur kernel: kernel size of the blur pass.
  10218. * Only useful if useKernelBlur = true
  10219. */
  10220. blurKernel: number;
  10221. private _useKernelBlur;
  10222. /**
  10223. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10224. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10225. */
  10226. /**
  10227. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10228. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10229. */
  10230. useKernelBlur: boolean;
  10231. private _depthScale;
  10232. /**
  10233. * Gets the depth scale used in ESM mode.
  10234. */
  10235. /**
  10236. * Sets the depth scale used in ESM mode.
  10237. * This can override the scale stored on the light.
  10238. */
  10239. depthScale: number;
  10240. private _filter;
  10241. /**
  10242. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10243. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10244. */
  10245. /**
  10246. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10247. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10248. */
  10249. filter: number;
  10250. /**
  10251. * Gets if the current filter is set to Poisson Sampling.
  10252. */
  10253. /**
  10254. * Sets the current filter to Poisson Sampling.
  10255. */
  10256. usePoissonSampling: boolean;
  10257. /**
  10258. * Gets if the current filter is set to ESM.
  10259. */
  10260. /**
  10261. * Sets the current filter is to ESM.
  10262. */
  10263. useExponentialShadowMap: boolean;
  10264. /**
  10265. * Gets if the current filter is set to filtered ESM.
  10266. */
  10267. /**
  10268. * Gets if the current filter is set to filtered ESM.
  10269. */
  10270. useBlurExponentialShadowMap: boolean;
  10271. /**
  10272. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10273. * exponential to prevent steep falloff artifacts).
  10274. */
  10275. /**
  10276. * Sets the current filter to "close ESM" (using the inverse of the
  10277. * exponential to prevent steep falloff artifacts).
  10278. */
  10279. useCloseExponentialShadowMap: boolean;
  10280. /**
  10281. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10282. * exponential to prevent steep falloff artifacts).
  10283. */
  10284. /**
  10285. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10286. * exponential to prevent steep falloff artifacts).
  10287. */
  10288. useBlurCloseExponentialShadowMap: boolean;
  10289. /**
  10290. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10291. */
  10292. /**
  10293. * Sets the current filter to "PCF" (percentage closer filtering).
  10294. */
  10295. usePercentageCloserFiltering: boolean;
  10296. private _filteringQuality;
  10297. /**
  10298. * Gets the PCF or PCSS Quality.
  10299. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10300. */
  10301. /**
  10302. * Sets the PCF or PCSS Quality.
  10303. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10304. */
  10305. filteringQuality: number;
  10306. /**
  10307. * Gets if the current filter is set to "PCSS" (contact hardening).
  10308. */
  10309. /**
  10310. * Sets the current filter to "PCSS" (contact hardening).
  10311. */
  10312. useContactHardeningShadow: boolean;
  10313. private _contactHardeningLightSizeUVRatio;
  10314. /**
  10315. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10316. * Using a ratio helps keeping shape stability independently of the map size.
  10317. *
  10318. * It does not account for the light projection as it was having too much
  10319. * instability during the light setup or during light position changes.
  10320. *
  10321. * Only valid if useContactHardeningShadow is true.
  10322. */
  10323. /**
  10324. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10325. * Using a ratio helps keeping shape stability independently of the map size.
  10326. *
  10327. * It does not account for the light projection as it was having too much
  10328. * instability during the light setup or during light position changes.
  10329. *
  10330. * Only valid if useContactHardeningShadow is true.
  10331. */
  10332. contactHardeningLightSizeUVRatio: number;
  10333. private _darkness;
  10334. /**
  10335. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10336. * 0 means strongest and 1 would means no shadow.
  10337. * @returns the darkness.
  10338. */
  10339. getDarkness(): number;
  10340. /**
  10341. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10342. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10343. * @returns the shadow generator allowing fluent coding.
  10344. */
  10345. setDarkness(darkness: number): ShadowGenerator;
  10346. private _transparencyShadow;
  10347. /**
  10348. * Sets the ability to have transparent shadow (boolean).
  10349. * @param transparent True if transparent else False
  10350. * @returns the shadow generator allowing fluent coding
  10351. */
  10352. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10353. private _shadowMap;
  10354. private _shadowMap2;
  10355. /**
  10356. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10357. * @returns The render target texture if present otherwise, null
  10358. */
  10359. getShadowMap(): Nullable<RenderTargetTexture>;
  10360. /**
  10361. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10362. * @returns The render target texture if the shadow map is present otherwise, null
  10363. */
  10364. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10365. /**
  10366. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10367. * @param mesh Mesh to add
  10368. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10369. * @returns the Shadow Generator itself
  10370. */
  10371. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10372. /**
  10373. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10374. * @param mesh Mesh to remove
  10375. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10376. * @returns the Shadow Generator itself
  10377. */
  10378. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10379. /**
  10380. * Controls the extent to which the shadows fade out at the edge of the frustum
  10381. * Used only by directionals and spots
  10382. */
  10383. frustumEdgeFalloff: number;
  10384. private _light;
  10385. /**
  10386. * Returns the associated light object.
  10387. * @returns the light generating the shadow
  10388. */
  10389. getLight(): IShadowLight;
  10390. /**
  10391. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10392. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10393. * It might on the other hand introduce peter panning.
  10394. */
  10395. forceBackFacesOnly: boolean;
  10396. private _scene;
  10397. private _lightDirection;
  10398. private _effect;
  10399. private _viewMatrix;
  10400. private _projectionMatrix;
  10401. private _transformMatrix;
  10402. private _cachedPosition;
  10403. private _cachedDirection;
  10404. private _cachedDefines;
  10405. private _currentRenderID;
  10406. private _boxBlurPostprocess;
  10407. private _kernelBlurXPostprocess;
  10408. private _kernelBlurYPostprocess;
  10409. private _blurPostProcesses;
  10410. private _mapSize;
  10411. private _currentFaceIndex;
  10412. private _currentFaceIndexCache;
  10413. private _textureType;
  10414. private _defaultTextureMatrix;
  10415. /** @hidden */
  10416. static _SceneComponentInitialization: (scene: Scene) => void;
  10417. /**
  10418. * Creates a ShadowGenerator object.
  10419. * A ShadowGenerator is the required tool to use the shadows.
  10420. * Each light casting shadows needs to use its own ShadowGenerator.
  10421. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10422. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10423. * @param light The light object generating the shadows.
  10424. * @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.
  10425. */
  10426. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10427. private _initializeGenerator;
  10428. private _initializeShadowMap;
  10429. private _initializeBlurRTTAndPostProcesses;
  10430. private _renderForShadowMap;
  10431. private _renderSubMeshForShadowMap;
  10432. private _applyFilterValues;
  10433. /**
  10434. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10435. * @param onCompiled Callback triggered at the and of the effects compilation
  10436. * @param options Sets of optional options forcing the compilation with different modes
  10437. */
  10438. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10439. useInstances: boolean;
  10440. }>): void;
  10441. /**
  10442. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10443. * @param options Sets of optional options forcing the compilation with different modes
  10444. * @returns A promise that resolves when the compilation completes
  10445. */
  10446. forceCompilationAsync(options?: Partial<{
  10447. useInstances: boolean;
  10448. }>): Promise<void>;
  10449. /**
  10450. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10451. * @param subMesh The submesh we want to render in the shadow map
  10452. * @param useInstances Defines wether will draw in the map using instances
  10453. * @returns true if ready otherwise, false
  10454. */
  10455. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10456. /**
  10457. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10458. * @param defines Defines of the material we want to update
  10459. * @param lightIndex Index of the light in the enabled light list of the material
  10460. */
  10461. prepareDefines(defines: any, lightIndex: number): void;
  10462. /**
  10463. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10464. * defined in the generator but impacting the effect).
  10465. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10466. * @param effect The effect we are binfing the information for
  10467. */
  10468. bindShadowLight(lightIndex: string, effect: Effect): void;
  10469. /**
  10470. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10471. * (eq to shadow prjection matrix * light transform matrix)
  10472. * @returns The transform matrix used to create the shadow map
  10473. */
  10474. getTransformMatrix(): Matrix;
  10475. /**
  10476. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10477. * Cube and 2D textures for instance.
  10478. */
  10479. recreateShadowMap(): void;
  10480. private _disposeBlurPostProcesses;
  10481. private _disposeRTTandPostProcesses;
  10482. /**
  10483. * Disposes the ShadowGenerator.
  10484. * Returns nothing.
  10485. */
  10486. dispose(): void;
  10487. /**
  10488. * Serializes the shadow generator setup to a json object.
  10489. * @returns The serialized JSON object
  10490. */
  10491. serialize(): any;
  10492. /**
  10493. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10494. * @param parsedShadowGenerator The JSON object to parse
  10495. * @param scene The scene to create the shadow map for
  10496. * @returns The parsed shadow generator
  10497. */
  10498. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10499. }
  10500. }
  10501. declare module "babylonjs/Lights/light" {
  10502. import { Nullable } from "babylonjs/types";
  10503. import { Scene } from "babylonjs/scene";
  10504. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10505. import { Node } from "babylonjs/node";
  10506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10507. import { Effect } from "babylonjs/Materials/effect";
  10508. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10509. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10510. /**
  10511. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10512. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10513. * 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.
  10514. */
  10515. export abstract class Light extends Node {
  10516. /**
  10517. * Falloff Default: light is falling off following the material specification:
  10518. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10519. */
  10520. static readonly FALLOFF_DEFAULT: number;
  10521. /**
  10522. * Falloff Physical: light is falling off following the inverse squared distance law.
  10523. */
  10524. static readonly FALLOFF_PHYSICAL: number;
  10525. /**
  10526. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10527. * to enhance interoperability with other engines.
  10528. */
  10529. static readonly FALLOFF_GLTF: number;
  10530. /**
  10531. * Falloff Standard: light is falling off like in the standard material
  10532. * to enhance interoperability with other materials.
  10533. */
  10534. static readonly FALLOFF_STANDARD: number;
  10535. /**
  10536. * If every light affecting the material is in this lightmapMode,
  10537. * material.lightmapTexture adds or multiplies
  10538. * (depends on material.useLightmapAsShadowmap)
  10539. * after every other light calculations.
  10540. */
  10541. static readonly LIGHTMAP_DEFAULT: number;
  10542. /**
  10543. * material.lightmapTexture as only diffuse lighting from this light
  10544. * adds only specular lighting from this light
  10545. * adds dynamic shadows
  10546. */
  10547. static readonly LIGHTMAP_SPECULAR: number;
  10548. /**
  10549. * material.lightmapTexture as only lighting
  10550. * no light calculation from this light
  10551. * only adds dynamic shadows from this light
  10552. */
  10553. static readonly LIGHTMAP_SHADOWSONLY: number;
  10554. /**
  10555. * Each light type uses the default quantity according to its type:
  10556. * point/spot lights use luminous intensity
  10557. * directional lights use illuminance
  10558. */
  10559. static readonly INTENSITYMODE_AUTOMATIC: number;
  10560. /**
  10561. * lumen (lm)
  10562. */
  10563. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10564. /**
  10565. * candela (lm/sr)
  10566. */
  10567. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10568. /**
  10569. * lux (lm/m^2)
  10570. */
  10571. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10572. /**
  10573. * nit (cd/m^2)
  10574. */
  10575. static readonly INTENSITYMODE_LUMINANCE: number;
  10576. /**
  10577. * Light type const id of the point light.
  10578. */
  10579. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10580. /**
  10581. * Light type const id of the directional light.
  10582. */
  10583. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10584. /**
  10585. * Light type const id of the spot light.
  10586. */
  10587. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10588. /**
  10589. * Light type const id of the hemispheric light.
  10590. */
  10591. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10592. /**
  10593. * Diffuse gives the basic color to an object.
  10594. */
  10595. diffuse: Color3;
  10596. /**
  10597. * Specular produces a highlight color on an object.
  10598. * Note: This is note affecting PBR materials.
  10599. */
  10600. specular: Color3;
  10601. /**
  10602. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10603. * falling off base on range or angle.
  10604. * This can be set to any values in Light.FALLOFF_x.
  10605. *
  10606. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10607. * other types of materials.
  10608. */
  10609. falloffType: number;
  10610. /**
  10611. * Strength of the light.
  10612. * Note: By default it is define in the framework own unit.
  10613. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10614. */
  10615. intensity: number;
  10616. private _range;
  10617. protected _inverseSquaredRange: number;
  10618. /**
  10619. * Defines how far from the source the light is impacting in scene units.
  10620. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10621. */
  10622. /**
  10623. * Defines how far from the source the light is impacting in scene units.
  10624. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10625. */
  10626. range: number;
  10627. /**
  10628. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10629. * of light.
  10630. */
  10631. private _photometricScale;
  10632. private _intensityMode;
  10633. /**
  10634. * Gets the photometric scale used to interpret the intensity.
  10635. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10636. */
  10637. /**
  10638. * Sets the photometric scale used to interpret the intensity.
  10639. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10640. */
  10641. intensityMode: number;
  10642. private _radius;
  10643. /**
  10644. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10645. */
  10646. /**
  10647. * sets the light radius used by PBR Materials to simulate soft area lights.
  10648. */
  10649. radius: number;
  10650. private _renderPriority;
  10651. /**
  10652. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10653. * exceeding the number allowed of the materials.
  10654. */
  10655. renderPriority: number;
  10656. private _shadowEnabled;
  10657. /**
  10658. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10659. * the current shadow generator.
  10660. */
  10661. /**
  10662. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10663. * the current shadow generator.
  10664. */
  10665. shadowEnabled: boolean;
  10666. private _includedOnlyMeshes;
  10667. /**
  10668. * Gets the only meshes impacted by this light.
  10669. */
  10670. /**
  10671. * Sets the only meshes impacted by this light.
  10672. */
  10673. includedOnlyMeshes: AbstractMesh[];
  10674. private _excludedMeshes;
  10675. /**
  10676. * Gets the meshes not impacted by this light.
  10677. */
  10678. /**
  10679. * Sets the meshes not impacted by this light.
  10680. */
  10681. excludedMeshes: AbstractMesh[];
  10682. private _excludeWithLayerMask;
  10683. /**
  10684. * Gets the layer id use to find what meshes are not impacted by the light.
  10685. * Inactive if 0
  10686. */
  10687. /**
  10688. * Sets the layer id use to find what meshes are not impacted by the light.
  10689. * Inactive if 0
  10690. */
  10691. excludeWithLayerMask: number;
  10692. private _includeOnlyWithLayerMask;
  10693. /**
  10694. * Gets the layer id use to find what meshes are impacted by the light.
  10695. * Inactive if 0
  10696. */
  10697. /**
  10698. * Sets the layer id use to find what meshes are impacted by the light.
  10699. * Inactive if 0
  10700. */
  10701. includeOnlyWithLayerMask: number;
  10702. private _lightmapMode;
  10703. /**
  10704. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10705. */
  10706. /**
  10707. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10708. */
  10709. lightmapMode: number;
  10710. /**
  10711. * Shadow generator associted to the light.
  10712. * @hidden Internal use only.
  10713. */
  10714. _shadowGenerator: Nullable<IShadowGenerator>;
  10715. /**
  10716. * @hidden Internal use only.
  10717. */
  10718. _excludedMeshesIds: string[];
  10719. /**
  10720. * @hidden Internal use only.
  10721. */
  10722. _includedOnlyMeshesIds: string[];
  10723. /**
  10724. * The current light unifom buffer.
  10725. * @hidden Internal use only.
  10726. */
  10727. _uniformBuffer: UniformBuffer;
  10728. /**
  10729. * Creates a Light object in the scene.
  10730. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10731. * @param name The firendly name of the light
  10732. * @param scene The scene the light belongs too
  10733. */
  10734. constructor(name: string, scene: Scene);
  10735. protected abstract _buildUniformLayout(): void;
  10736. /**
  10737. * Sets the passed Effect "effect" with the Light information.
  10738. * @param effect The effect to update
  10739. * @param lightIndex The index of the light in the effect to update
  10740. * @returns The light
  10741. */
  10742. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10743. /**
  10744. * Returns the string "Light".
  10745. * @returns the class name
  10746. */
  10747. getClassName(): string;
  10748. /** @hidden */
  10749. readonly _isLight: boolean;
  10750. /**
  10751. * Converts the light information to a readable string for debug purpose.
  10752. * @param fullDetails Supports for multiple levels of logging within scene loading
  10753. * @returns the human readable light info
  10754. */
  10755. toString(fullDetails?: boolean): string;
  10756. /** @hidden */
  10757. protected _syncParentEnabledState(): void;
  10758. /**
  10759. * Set the enabled state of this node.
  10760. * @param value - the new enabled state
  10761. */
  10762. setEnabled(value: boolean): void;
  10763. /**
  10764. * Returns the Light associated shadow generator if any.
  10765. * @return the associated shadow generator.
  10766. */
  10767. getShadowGenerator(): Nullable<IShadowGenerator>;
  10768. /**
  10769. * Returns a Vector3, the absolute light position in the World.
  10770. * @returns the world space position of the light
  10771. */
  10772. getAbsolutePosition(): Vector3;
  10773. /**
  10774. * Specifies if the light will affect the passed mesh.
  10775. * @param mesh The mesh to test against the light
  10776. * @return true the mesh is affected otherwise, false.
  10777. */
  10778. canAffectMesh(mesh: AbstractMesh): boolean;
  10779. /**
  10780. * Sort function to order lights for rendering.
  10781. * @param a First Light object to compare to second.
  10782. * @param b Second Light object to compare first.
  10783. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10784. */
  10785. static CompareLightsPriority(a: Light, b: Light): number;
  10786. /**
  10787. * Releases resources associated with this node.
  10788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10790. */
  10791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10792. /**
  10793. * Returns the light type ID (integer).
  10794. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10795. */
  10796. getTypeID(): number;
  10797. /**
  10798. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10799. * @returns the scaled intensity in intensity mode unit
  10800. */
  10801. getScaledIntensity(): number;
  10802. /**
  10803. * Returns a new Light object, named "name", from the current one.
  10804. * @param name The name of the cloned light
  10805. * @returns the new created light
  10806. */
  10807. clone(name: string): Nullable<Light>;
  10808. /**
  10809. * Serializes the current light into a Serialization object.
  10810. * @returns the serialized object.
  10811. */
  10812. serialize(): any;
  10813. /**
  10814. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10815. * This new light is named "name" and added to the passed scene.
  10816. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10817. * @param name The friendly name of the light
  10818. * @param scene The scene the new light will belong to
  10819. * @returns the constructor function
  10820. */
  10821. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10822. /**
  10823. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10824. * @param parsedLight The JSON representation of the light
  10825. * @param scene The scene to create the parsed light in
  10826. * @returns the created light after parsing
  10827. */
  10828. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10829. private _hookArrayForExcluded;
  10830. private _hookArrayForIncludedOnly;
  10831. private _resyncMeshes;
  10832. /**
  10833. * Forces the meshes to update their light related information in their rendering used effects
  10834. * @hidden Internal Use Only
  10835. */
  10836. _markMeshesAsLightDirty(): void;
  10837. /**
  10838. * Recomputes the cached photometric scale if needed.
  10839. */
  10840. private _computePhotometricScale;
  10841. /**
  10842. * Returns the Photometric Scale according to the light type and intensity mode.
  10843. */
  10844. private _getPhotometricScale;
  10845. /**
  10846. * Reorder the light in the scene according to their defined priority.
  10847. * @hidden Internal Use Only
  10848. */
  10849. _reorderLightsInScene(): void;
  10850. /**
  10851. * Prepares the list of defines specific to the light type.
  10852. * @param defines the list of defines
  10853. * @param lightIndex defines the index of the light for the effect
  10854. */
  10855. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10856. }
  10857. }
  10858. declare module "babylonjs/Lights/hemisphericLight" {
  10859. import { Nullable } from "babylonjs/types";
  10860. import { Scene } from "babylonjs/scene";
  10861. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  10862. import { Effect } from "babylonjs/Materials/effect";
  10863. import { Light } from "babylonjs/Lights/light";
  10864. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10865. /**
  10866. * The HemisphericLight simulates the ambient environment light,
  10867. * so the passed direction is the light reflection direction, not the incoming direction.
  10868. */
  10869. export class HemisphericLight extends Light {
  10870. /**
  10871. * The groundColor is the light in the opposite direction to the one specified during creation.
  10872. * 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.
  10873. */
  10874. groundColor: Color3;
  10875. /**
  10876. * The light reflection direction, not the incoming direction.
  10877. */
  10878. direction: Vector3;
  10879. /**
  10880. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  10881. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  10882. * The HemisphericLight can't cast shadows.
  10883. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10884. * @param name The friendly name of the light
  10885. * @param direction The direction of the light reflection
  10886. * @param scene The scene the light belongs to
  10887. */
  10888. constructor(name: string, direction: Vector3, scene: Scene);
  10889. protected _buildUniformLayout(): void;
  10890. /**
  10891. * Returns the string "HemisphericLight".
  10892. * @return The class name
  10893. */
  10894. getClassName(): string;
  10895. /**
  10896. * Sets the HemisphericLight direction towards the passed target (Vector3).
  10897. * Returns the updated direction.
  10898. * @param target The target the direction should point to
  10899. * @return The computed direction
  10900. */
  10901. setDirectionToTarget(target: Vector3): Vector3;
  10902. /**
  10903. * Returns the shadow generator associated to the light.
  10904. * @returns Always null for hemispheric lights because it does not support shadows.
  10905. */
  10906. getShadowGenerator(): Nullable<IShadowGenerator>;
  10907. /**
  10908. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  10909. * @param effect The effect to update
  10910. * @param lightIndex The index of the light in the effect to update
  10911. * @returns The hemispheric light
  10912. */
  10913. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  10914. /**
  10915. * Computes the world matrix of the node
  10916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  10917. * @param useWasUpdatedFlag defines a reserved property
  10918. * @returns the world matrix
  10919. */
  10920. computeWorldMatrix(): Matrix;
  10921. /**
  10922. * Returns the integer 3.
  10923. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10924. */
  10925. getTypeID(): number;
  10926. /**
  10927. * Prepares the list of defines specific to the light type.
  10928. * @param defines the list of defines
  10929. * @param lightIndex defines the index of the light for the effect
  10930. */
  10931. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10932. }
  10933. }
  10934. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  10935. declare module "babylonjs/Cameras/VR/webVRCamera" {
  10936. import { Nullable } from "babylonjs/types";
  10937. import { Observable } from "babylonjs/Misc/observable";
  10938. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  10941. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  10942. import { Node } from "babylonjs/node";
  10943. import { Ray } from "babylonjs/Culling/ray";
  10944. import "babylonjs/Cameras/RigModes/webVRRigMode";
  10945. /**
  10946. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  10947. * IMPORTANT!! The data is right-hand data.
  10948. * @export
  10949. * @interface DevicePose
  10950. */
  10951. export interface DevicePose {
  10952. /**
  10953. * The position of the device, values in array are [x,y,z].
  10954. */
  10955. readonly position: Nullable<Float32Array>;
  10956. /**
  10957. * The linearVelocity of the device, values in array are [x,y,z].
  10958. */
  10959. readonly linearVelocity: Nullable<Float32Array>;
  10960. /**
  10961. * The linearAcceleration of the device, values in array are [x,y,z].
  10962. */
  10963. readonly linearAcceleration: Nullable<Float32Array>;
  10964. /**
  10965. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  10966. */
  10967. readonly orientation: Nullable<Float32Array>;
  10968. /**
  10969. * The angularVelocity of the device, values in array are [x,y,z].
  10970. */
  10971. readonly angularVelocity: Nullable<Float32Array>;
  10972. /**
  10973. * The angularAcceleration of the device, values in array are [x,y,z].
  10974. */
  10975. readonly angularAcceleration: Nullable<Float32Array>;
  10976. }
  10977. /**
  10978. * Interface representing a pose controlled object in Babylon.
  10979. * A pose controlled object has both regular pose values as well as pose values
  10980. * from an external device such as a VR head mounted display
  10981. */
  10982. export interface PoseControlled {
  10983. /**
  10984. * The position of the object in babylon space.
  10985. */
  10986. position: Vector3;
  10987. /**
  10988. * The rotation quaternion of the object in babylon space.
  10989. */
  10990. rotationQuaternion: Quaternion;
  10991. /**
  10992. * The position of the device in babylon space.
  10993. */
  10994. devicePosition?: Vector3;
  10995. /**
  10996. * The rotation quaternion of the device in babylon space.
  10997. */
  10998. deviceRotationQuaternion: Quaternion;
  10999. /**
  11000. * The raw pose coming from the device.
  11001. */
  11002. rawPose: Nullable<DevicePose>;
  11003. /**
  11004. * The scale of the device to be used when translating from device space to babylon space.
  11005. */
  11006. deviceScaleFactor: number;
  11007. /**
  11008. * Updates the poseControlled values based on the input device pose.
  11009. * @param poseData the pose data to update the object with
  11010. */
  11011. updateFromDevice(poseData: DevicePose): void;
  11012. }
  11013. /**
  11014. * Set of options to customize the webVRCamera
  11015. */
  11016. export interface WebVROptions {
  11017. /**
  11018. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  11019. */
  11020. trackPosition?: boolean;
  11021. /**
  11022. * Sets the scale of the vrDevice in babylon space. (default: 1)
  11023. */
  11024. positionScale?: number;
  11025. /**
  11026. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  11027. */
  11028. displayName?: string;
  11029. /**
  11030. * Should the native controller meshes be initialized. (default: true)
  11031. */
  11032. controllerMeshes?: boolean;
  11033. /**
  11034. * Creating a default HemiLight only on controllers. (default: true)
  11035. */
  11036. defaultLightingOnControllers?: boolean;
  11037. /**
  11038. * If you don't want to use the default VR button of the helper. (default: false)
  11039. */
  11040. useCustomVRButton?: boolean;
  11041. /**
  11042. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  11043. */
  11044. customVRButton?: HTMLButtonElement;
  11045. /**
  11046. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  11047. */
  11048. rayLength?: number;
  11049. /**
  11050. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  11051. */
  11052. defaultHeight?: number;
  11053. }
  11054. /**
  11055. * This represents a WebVR camera.
  11056. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  11057. * @example http://doc.babylonjs.com/how_to/webvr_camera
  11058. */
  11059. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  11060. private webVROptions;
  11061. /**
  11062. * @hidden
  11063. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  11064. */
  11065. _vrDevice: any;
  11066. /**
  11067. * The rawPose of the vrDevice.
  11068. */
  11069. rawPose: Nullable<DevicePose>;
  11070. private _onVREnabled;
  11071. private _specsVersion;
  11072. private _attached;
  11073. private _frameData;
  11074. protected _descendants: Array<Node>;
  11075. private _deviceRoomPosition;
  11076. /** @hidden */
  11077. _deviceRoomRotationQuaternion: Quaternion;
  11078. private _standingMatrix;
  11079. /**
  11080. * Represents device position in babylon space.
  11081. */
  11082. devicePosition: Vector3;
  11083. /**
  11084. * Represents device rotation in babylon space.
  11085. */
  11086. deviceRotationQuaternion: Quaternion;
  11087. /**
  11088. * The scale of the device to be used when translating from device space to babylon space.
  11089. */
  11090. deviceScaleFactor: number;
  11091. private _deviceToWorld;
  11092. private _worldToDevice;
  11093. /**
  11094. * References to the webVR controllers for the vrDevice.
  11095. */
  11096. controllers: Array<WebVRController>;
  11097. /**
  11098. * Emits an event when a controller is attached.
  11099. */
  11100. onControllersAttachedObservable: Observable<WebVRController[]>;
  11101. /**
  11102. * Emits an event when a controller's mesh has been loaded;
  11103. */
  11104. onControllerMeshLoadedObservable: Observable<WebVRController>;
  11105. /**
  11106. * Emits an event when the HMD's pose has been updated.
  11107. */
  11108. onPoseUpdatedFromDeviceObservable: Observable<any>;
  11109. private _poseSet;
  11110. /**
  11111. * If the rig cameras be used as parent instead of this camera.
  11112. */
  11113. rigParenting: boolean;
  11114. private _lightOnControllers;
  11115. private _defaultHeight?;
  11116. /**
  11117. * Instantiates a WebVRFreeCamera.
  11118. * @param name The name of the WebVRFreeCamera
  11119. * @param position The starting anchor position for the camera
  11120. * @param scene The scene the camera belongs to
  11121. * @param webVROptions a set of customizable options for the webVRCamera
  11122. */
  11123. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  11124. /**
  11125. * Gets the device distance from the ground in meters.
  11126. * @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.
  11127. */
  11128. deviceDistanceToRoomGround(): number;
  11129. /**
  11130. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11131. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  11132. */
  11133. useStandingMatrix(callback?: (bool: boolean) => void): void;
  11134. /**
  11135. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  11136. * @returns A promise with a boolean set to if the standing matrix is supported.
  11137. */
  11138. useStandingMatrixAsync(): Promise<boolean>;
  11139. /**
  11140. * Disposes the camera
  11141. */
  11142. dispose(): void;
  11143. /**
  11144. * Gets a vrController by name.
  11145. * @param name The name of the controller to retreive
  11146. * @returns the controller matching the name specified or null if not found
  11147. */
  11148. getControllerByName(name: string): Nullable<WebVRController>;
  11149. private _leftController;
  11150. /**
  11151. * The controller corrisponding to the users left hand.
  11152. */
  11153. readonly leftController: Nullable<WebVRController>;
  11154. private _rightController;
  11155. /**
  11156. * The controller corrisponding to the users right hand.
  11157. */
  11158. readonly rightController: Nullable<WebVRController>;
  11159. /**
  11160. * Casts a ray forward from the vrCamera's gaze.
  11161. * @param length Length of the ray (default: 100)
  11162. * @returns the ray corrisponding to the gaze
  11163. */
  11164. getForwardRay(length?: number): Ray;
  11165. /**
  11166. * @hidden
  11167. * Updates the camera based on device's frame data
  11168. */
  11169. _checkInputs(): void;
  11170. /**
  11171. * Updates the poseControlled values based on the input device pose.
  11172. * @param poseData Pose coming from the device
  11173. */
  11174. updateFromDevice(poseData: DevicePose): void;
  11175. private _htmlElementAttached;
  11176. private _detachIfAttached;
  11177. /**
  11178. * WebVR's attach control will start broadcasting frames to the device.
  11179. * Note that in certain browsers (chrome for example) this function must be called
  11180. * within a user-interaction callback. Example:
  11181. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  11182. *
  11183. * @param element html element to attach the vrDevice to
  11184. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  11185. */
  11186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11187. /**
  11188. * Detaches the camera from the html element and disables VR
  11189. *
  11190. * @param element html element to detach from
  11191. */
  11192. detachControl(element: HTMLElement): void;
  11193. /**
  11194. * @returns the name of this class
  11195. */
  11196. getClassName(): string;
  11197. /**
  11198. * Calls resetPose on the vrDisplay
  11199. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  11200. */
  11201. resetToCurrentRotation(): void;
  11202. /**
  11203. * @hidden
  11204. * Updates the rig cameras (left and right eye)
  11205. */
  11206. _updateRigCameras(): void;
  11207. private _workingVector;
  11208. private _oneVector;
  11209. private _workingMatrix;
  11210. private updateCacheCalled;
  11211. private _correctPositionIfNotTrackPosition;
  11212. /**
  11213. * @hidden
  11214. * Updates the cached values of the camera
  11215. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  11216. */
  11217. _updateCache(ignoreParentClass?: boolean): void;
  11218. /**
  11219. * @hidden
  11220. * Get current device position in babylon world
  11221. */
  11222. _computeDevicePosition(): void;
  11223. /**
  11224. * Updates the current device position and rotation in the babylon world
  11225. */
  11226. update(): void;
  11227. /**
  11228. * @hidden
  11229. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  11230. * @returns an identity matrix
  11231. */
  11232. _getViewMatrix(): Matrix;
  11233. private _tmpMatrix;
  11234. /**
  11235. * This function is called by the two RIG cameras.
  11236. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  11237. * @hidden
  11238. */
  11239. _getWebVRViewMatrix(): Matrix;
  11240. /** @hidden */
  11241. _getWebVRProjectionMatrix(): Matrix;
  11242. private _onGamepadConnectedObserver;
  11243. private _onGamepadDisconnectedObserver;
  11244. private _updateCacheWhenTrackingDisabledObserver;
  11245. /**
  11246. * Initializes the controllers and their meshes
  11247. */
  11248. initControllers(): void;
  11249. }
  11250. }
  11251. declare module "babylonjs/PostProcesses/postProcess" {
  11252. import { Nullable } from "babylonjs/types";
  11253. import { SmartArray } from "babylonjs/Misc/smartArray";
  11254. import { Observable } from "babylonjs/Misc/observable";
  11255. import { Color4, Vector2 } from "babylonjs/Maths/math";
  11256. import { Camera } from "babylonjs/Cameras/camera";
  11257. import { Effect } from "babylonjs/Materials/effect";
  11258. import "babylonjs/Shaders/postprocess.vertex";
  11259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11260. import { Engine } from "babylonjs/Engines/engine";
  11261. /**
  11262. * Size options for a post process
  11263. */
  11264. export type PostProcessOptions = {
  11265. width: number;
  11266. height: number;
  11267. };
  11268. /**
  11269. * PostProcess can be used to apply a shader to a texture after it has been rendered
  11270. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  11271. */
  11272. export class PostProcess {
  11273. /** Name of the PostProcess. */
  11274. name: string;
  11275. /**
  11276. * Width of the texture to apply the post process on
  11277. */
  11278. width: number;
  11279. /**
  11280. * Height of the texture to apply the post process on
  11281. */
  11282. height: number;
  11283. /**
  11284. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  11285. * @hidden
  11286. */
  11287. _outputTexture: Nullable<InternalTexture>;
  11288. /**
  11289. * Sampling mode used by the shader
  11290. * See https://doc.babylonjs.com/classes/3.1/texture
  11291. */
  11292. renderTargetSamplingMode: number;
  11293. /**
  11294. * Clear color to use when screen clearing
  11295. */
  11296. clearColor: Color4;
  11297. /**
  11298. * If the buffer needs to be cleared before applying the post process. (default: true)
  11299. * Should be set to false if shader will overwrite all previous pixels.
  11300. */
  11301. autoClear: boolean;
  11302. /**
  11303. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  11304. */
  11305. alphaMode: number;
  11306. /**
  11307. * Sets the setAlphaBlendConstants of the babylon engine
  11308. */
  11309. alphaConstants: Color4;
  11310. /**
  11311. * Animations to be used for the post processing
  11312. */
  11313. animations: import("babylonjs/Animations/animation").Animation[];
  11314. /**
  11315. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  11316. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  11317. */
  11318. enablePixelPerfectMode: boolean;
  11319. /**
  11320. * Force the postprocess to be applied without taking in account viewport
  11321. */
  11322. forceFullscreenViewport: boolean;
  11323. /**
  11324. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  11325. *
  11326. * | Value | Type | Description |
  11327. * | ----- | ----------------------------------- | ----------- |
  11328. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  11329. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  11330. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  11331. *
  11332. */
  11333. scaleMode: number;
  11334. /**
  11335. * Force textures to be a power of two (default: false)
  11336. */
  11337. alwaysForcePOT: boolean;
  11338. private _samples;
  11339. /**
  11340. * Number of sample textures (default: 1)
  11341. */
  11342. samples: number;
  11343. /**
  11344. * Modify the scale of the post process to be the same as the viewport (default: false)
  11345. */
  11346. adaptScaleToCurrentViewport: boolean;
  11347. private _camera;
  11348. private _scene;
  11349. private _engine;
  11350. private _options;
  11351. private _reusable;
  11352. private _textureType;
  11353. /**
  11354. * Smart array of input and output textures for the post process.
  11355. * @hidden
  11356. */
  11357. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  11358. /**
  11359. * The index in _textures that corresponds to the output texture.
  11360. * @hidden
  11361. */
  11362. _currentRenderTextureInd: number;
  11363. private _effect;
  11364. private _samplers;
  11365. private _fragmentUrl;
  11366. private _vertexUrl;
  11367. private _parameters;
  11368. private _scaleRatio;
  11369. protected _indexParameters: any;
  11370. private _shareOutputWithPostProcess;
  11371. private _texelSize;
  11372. private _forcedOutputTexture;
  11373. /**
  11374. * Returns the fragment url or shader name used in the post process.
  11375. * @returns the fragment url or name in the shader store.
  11376. */
  11377. getEffectName(): string;
  11378. /**
  11379. * An event triggered when the postprocess is activated.
  11380. */
  11381. onActivateObservable: Observable<Camera>;
  11382. private _onActivateObserver;
  11383. /**
  11384. * A function that is added to the onActivateObservable
  11385. */
  11386. onActivate: Nullable<(camera: Camera) => void>;
  11387. /**
  11388. * An event triggered when the postprocess changes its size.
  11389. */
  11390. onSizeChangedObservable: Observable<PostProcess>;
  11391. private _onSizeChangedObserver;
  11392. /**
  11393. * A function that is added to the onSizeChangedObservable
  11394. */
  11395. onSizeChanged: (postProcess: PostProcess) => void;
  11396. /**
  11397. * An event triggered when the postprocess applies its effect.
  11398. */
  11399. onApplyObservable: Observable<Effect>;
  11400. private _onApplyObserver;
  11401. /**
  11402. * A function that is added to the onApplyObservable
  11403. */
  11404. onApply: (effect: Effect) => void;
  11405. /**
  11406. * An event triggered before rendering the postprocess
  11407. */
  11408. onBeforeRenderObservable: Observable<Effect>;
  11409. private _onBeforeRenderObserver;
  11410. /**
  11411. * A function that is added to the onBeforeRenderObservable
  11412. */
  11413. onBeforeRender: (effect: Effect) => void;
  11414. /**
  11415. * An event triggered after rendering the postprocess
  11416. */
  11417. onAfterRenderObservable: Observable<Effect>;
  11418. private _onAfterRenderObserver;
  11419. /**
  11420. * A function that is added to the onAfterRenderObservable
  11421. */
  11422. onAfterRender: (efect: Effect) => void;
  11423. /**
  11424. * 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
  11425. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  11426. */
  11427. inputTexture: InternalTexture;
  11428. /**
  11429. * Gets the camera which post process is applied to.
  11430. * @returns The camera the post process is applied to.
  11431. */
  11432. getCamera(): Camera;
  11433. /**
  11434. * Gets the texel size of the postprocess.
  11435. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  11436. */
  11437. readonly texelSize: Vector2;
  11438. /**
  11439. * Creates a new instance PostProcess
  11440. * @param name The name of the PostProcess.
  11441. * @param fragmentUrl The url of the fragment shader to be used.
  11442. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  11443. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  11444. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  11445. * @param camera The camera to apply the render pass to.
  11446. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  11447. * @param engine The engine which the post process will be applied. (default: current engine)
  11448. * @param reusable If the post process can be reused on the same frame. (default: false)
  11449. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  11450. * @param textureType Type of textures used when performing the post process. (default: 0)
  11451. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  11452. * @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
  11453. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  11454. */
  11455. constructor(
  11456. /** Name of the PostProcess. */
  11457. 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);
  11458. /**
  11459. * Gets the engine which this post process belongs to.
  11460. * @returns The engine the post process was enabled with.
  11461. */
  11462. getEngine(): Engine;
  11463. /**
  11464. * The effect that is created when initializing the post process.
  11465. * @returns The created effect corrisponding the the postprocess.
  11466. */
  11467. getEffect(): Effect;
  11468. /**
  11469. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  11470. * @param postProcess The post process to share the output with.
  11471. * @returns This post process.
  11472. */
  11473. shareOutputWith(postProcess: PostProcess): PostProcess;
  11474. /**
  11475. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  11476. * This should be called if the post process that shares output with this post process is disabled/disposed.
  11477. */
  11478. useOwnOutput(): void;
  11479. /**
  11480. * Updates the effect with the current post process compile time values and recompiles the shader.
  11481. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  11482. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  11483. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  11484. * @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
  11485. * @param onCompiled Called when the shader has been compiled.
  11486. * @param onError Called if there is an error when compiling a shader.
  11487. */
  11488. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  11489. /**
  11490. * The post process is reusable if it can be used multiple times within one frame.
  11491. * @returns If the post process is reusable
  11492. */
  11493. isReusable(): boolean;
  11494. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  11495. markTextureDirty(): void;
  11496. /**
  11497. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  11498. * 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.
  11499. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  11500. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  11501. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  11502. * @returns The target texture that was bound to be written to.
  11503. */
  11504. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  11505. /**
  11506. * If the post process is supported.
  11507. */
  11508. readonly isSupported: boolean;
  11509. /**
  11510. * The aspect ratio of the output texture.
  11511. */
  11512. readonly aspectRatio: number;
  11513. /**
  11514. * Get a value indicating if the post-process is ready to be used
  11515. * @returns true if the post-process is ready (shader is compiled)
  11516. */
  11517. isReady(): boolean;
  11518. /**
  11519. * Binds all textures and uniforms to the shader, this will be run on every pass.
  11520. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  11521. */
  11522. apply(): Nullable<Effect>;
  11523. private _disposeTextures;
  11524. /**
  11525. * Disposes the post process.
  11526. * @param camera The camera to dispose the post process on.
  11527. */
  11528. dispose(camera?: Camera): void;
  11529. }
  11530. }
  11531. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  11532. /** @hidden */
  11533. export var kernelBlurVaryingDeclaration: {
  11534. name: string;
  11535. shader: string;
  11536. };
  11537. }
  11538. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  11539. /** @hidden */
  11540. export var kernelBlurFragment: {
  11541. name: string;
  11542. shader: string;
  11543. };
  11544. }
  11545. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  11546. /** @hidden */
  11547. export var kernelBlurFragment2: {
  11548. name: string;
  11549. shader: string;
  11550. };
  11551. }
  11552. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  11553. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  11554. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  11555. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  11556. /** @hidden */
  11557. export var kernelBlurPixelShader: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  11563. /** @hidden */
  11564. export var kernelBlurVertex: {
  11565. name: string;
  11566. shader: string;
  11567. };
  11568. }
  11569. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  11570. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  11571. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  11572. /** @hidden */
  11573. export var kernelBlurVertexShader: {
  11574. name: string;
  11575. shader: string;
  11576. };
  11577. }
  11578. declare module "babylonjs/PostProcesses/blurPostProcess" {
  11579. import { Vector2 } from "babylonjs/Maths/math";
  11580. import { Nullable } from "babylonjs/types";
  11581. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  11582. import { Camera } from "babylonjs/Cameras/camera";
  11583. import { Effect } from "babylonjs/Materials/effect";
  11584. import { Engine } from "babylonjs/Engines/engine";
  11585. import "babylonjs/Shaders/kernelBlur.fragment";
  11586. import "babylonjs/Shaders/kernelBlur.vertex";
  11587. /**
  11588. * The Blur Post Process which blurs an image based on a kernel and direction.
  11589. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  11590. */
  11591. export class BlurPostProcess extends PostProcess {
  11592. /** The direction in which to blur the image. */
  11593. direction: Vector2;
  11594. private blockCompilation;
  11595. protected _kernel: number;
  11596. protected _idealKernel: number;
  11597. protected _packedFloat: boolean;
  11598. private _staticDefines;
  11599. /**
  11600. * Sets the length in pixels of the blur sample region
  11601. */
  11602. /**
  11603. * Gets the length in pixels of the blur sample region
  11604. */
  11605. kernel: number;
  11606. /**
  11607. * Sets wether or not the blur needs to unpack/repack floats
  11608. */
  11609. /**
  11610. * Gets wether or not the blur is unpacking/repacking floats
  11611. */
  11612. packedFloat: boolean;
  11613. /**
  11614. * Creates a new instance BlurPostProcess
  11615. * @param name The name of the effect.
  11616. * @param direction The direction in which to blur the image.
  11617. * @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.
  11618. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  11619. * @param camera The camera to apply the render pass to.
  11620. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  11621. * @param engine The engine which the post process will be applied. (default: current engine)
  11622. * @param reusable If the post process can be reused on the same frame. (default: false)
  11623. * @param textureType Type of textures used when performing the post process. (default: 0)
  11624. * @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)
  11625. */
  11626. constructor(name: string,
  11627. /** The direction in which to blur the image. */
  11628. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  11629. /**
  11630. * Updates the effect with the current post process compile time values and recompiles the shader.
  11631. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  11632. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  11633. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  11634. * @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
  11635. * @param onCompiled Called when the shader has been compiled.
  11636. * @param onError Called if there is an error when compiling a shader.
  11637. */
  11638. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  11639. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  11640. /**
  11641. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  11642. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  11643. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  11644. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  11645. * The gaps between physical kernels are compensated for in the weighting of the samples
  11646. * @param idealKernel Ideal blur kernel.
  11647. * @return Nearest best kernel.
  11648. */
  11649. protected _nearestBestKernel(idealKernel: number): number;
  11650. /**
  11651. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  11652. * @param x The point on the Gaussian distribution to sample.
  11653. * @return the value of the Gaussian function at x.
  11654. */
  11655. protected _gaussianWeight(x: number): number;
  11656. /**
  11657. * Generates a string that can be used as a floating point number in GLSL.
  11658. * @param x Value to print.
  11659. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  11660. * @return GLSL float string.
  11661. */
  11662. protected _glslFloat(x: number, decimalFigures?: number): string;
  11663. }
  11664. }
  11665. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  11666. import { Scene } from "babylonjs/scene";
  11667. import { Plane } from "babylonjs/Maths/math";
  11668. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11669. /**
  11670. * Mirror texture can be used to simulate the view from a mirror in a scene.
  11671. * It will dynamically be rendered every frame to adapt to the camera point of view.
  11672. * You can then easily use it as a reflectionTexture on a flat surface.
  11673. * In case the surface is not a plane, please consider relying on reflection probes.
  11674. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  11675. */
  11676. export class MirrorTexture extends RenderTargetTexture {
  11677. private scene;
  11678. /**
  11679. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  11680. * 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.
  11681. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  11682. */
  11683. mirrorPlane: Plane;
  11684. /**
  11685. * Define the blur ratio used to blur the reflection if needed.
  11686. */
  11687. blurRatio: number;
  11688. /**
  11689. * Define the adaptive blur kernel used to blur the reflection if needed.
  11690. * This will autocompute the closest best match for the `blurKernel`
  11691. */
  11692. adaptiveBlurKernel: number;
  11693. /**
  11694. * Define the blur kernel used to blur the reflection if needed.
  11695. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  11696. */
  11697. blurKernel: number;
  11698. /**
  11699. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  11700. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  11701. */
  11702. blurKernelX: number;
  11703. /**
  11704. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  11705. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  11706. */
  11707. blurKernelY: number;
  11708. private _autoComputeBlurKernel;
  11709. protected _onRatioRescale(): void;
  11710. private _updateGammaSpace;
  11711. private _imageProcessingConfigChangeObserver;
  11712. private _transformMatrix;
  11713. private _mirrorMatrix;
  11714. private _savedViewMatrix;
  11715. private _blurX;
  11716. private _blurY;
  11717. private _adaptiveBlurKernel;
  11718. private _blurKernelX;
  11719. private _blurKernelY;
  11720. private _blurRatio;
  11721. /**
  11722. * Instantiates a Mirror Texture.
  11723. * Mirror texture can be used to simulate the view from a mirror in a scene.
  11724. * It will dynamically be rendered every frame to adapt to the camera point of view.
  11725. * You can then easily use it as a reflectionTexture on a flat surface.
  11726. * In case the surface is not a plane, please consider relying on reflection probes.
  11727. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  11728. * @param name
  11729. * @param size
  11730. * @param scene
  11731. * @param generateMipMaps
  11732. * @param type
  11733. * @param samplingMode
  11734. * @param generateDepthBuffer
  11735. */
  11736. constructor(name: string, size: number | {
  11737. width: number;
  11738. height: number;
  11739. } | {
  11740. ratio: number;
  11741. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  11742. private _preparePostProcesses;
  11743. /**
  11744. * Clone the mirror texture.
  11745. * @returns the cloned texture
  11746. */
  11747. clone(): MirrorTexture;
  11748. /**
  11749. * Serialize the texture to a JSON representation you could use in Parse later on
  11750. * @returns the serialized JSON representation
  11751. */
  11752. serialize(): any;
  11753. /**
  11754. * Dispose the texture and release its associated resources.
  11755. */
  11756. dispose(): void;
  11757. }
  11758. }
  11759. declare module "babylonjs/Materials/Textures/texture" {
  11760. import { Observable } from "babylonjs/Misc/observable";
  11761. import { Nullable } from "babylonjs/types";
  11762. import { Scene } from "babylonjs/scene";
  11763. import { Matrix } from "babylonjs/Maths/math";
  11764. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11765. /**
  11766. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  11767. * @see http://doc.babylonjs.com/babylon101/materials#texture
  11768. */
  11769. export class Texture extends BaseTexture {
  11770. /** @hidden */
  11771. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  11772. /** @hidden */
  11773. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  11774. /** @hidden */
  11775. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  11776. /** nearest is mag = nearest and min = nearest and mip = linear */
  11777. static readonly NEAREST_SAMPLINGMODE: number;
  11778. /** nearest is mag = nearest and min = nearest and mip = linear */
  11779. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  11780. /** Bilinear is mag = linear and min = linear and mip = nearest */
  11781. static readonly BILINEAR_SAMPLINGMODE: number;
  11782. /** Bilinear is mag = linear and min = linear and mip = nearest */
  11783. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  11784. /** Trilinear is mag = linear and min = linear and mip = linear */
  11785. static readonly TRILINEAR_SAMPLINGMODE: number;
  11786. /** Trilinear is mag = linear and min = linear and mip = linear */
  11787. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  11788. /** mag = nearest and min = nearest and mip = nearest */
  11789. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  11790. /** mag = nearest and min = linear and mip = nearest */
  11791. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  11792. /** mag = nearest and min = linear and mip = linear */
  11793. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  11794. /** mag = nearest and min = linear and mip = none */
  11795. static readonly NEAREST_LINEAR: number;
  11796. /** mag = nearest and min = nearest and mip = none */
  11797. static readonly NEAREST_NEAREST: number;
  11798. /** mag = linear and min = nearest and mip = nearest */
  11799. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  11800. /** mag = linear and min = nearest and mip = linear */
  11801. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  11802. /** mag = linear and min = linear and mip = none */
  11803. static readonly LINEAR_LINEAR: number;
  11804. /** mag = linear and min = nearest and mip = none */
  11805. static readonly LINEAR_NEAREST: number;
  11806. /** Explicit coordinates mode */
  11807. static readonly EXPLICIT_MODE: number;
  11808. /** Spherical coordinates mode */
  11809. static readonly SPHERICAL_MODE: number;
  11810. /** Planar coordinates mode */
  11811. static readonly PLANAR_MODE: number;
  11812. /** Cubic coordinates mode */
  11813. static readonly CUBIC_MODE: number;
  11814. /** Projection coordinates mode */
  11815. static readonly PROJECTION_MODE: number;
  11816. /** Inverse Cubic coordinates mode */
  11817. static readonly SKYBOX_MODE: number;
  11818. /** Inverse Cubic coordinates mode */
  11819. static readonly INVCUBIC_MODE: number;
  11820. /** Equirectangular coordinates mode */
  11821. static readonly EQUIRECTANGULAR_MODE: number;
  11822. /** Equirectangular Fixed coordinates mode */
  11823. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  11824. /** Equirectangular Fixed Mirrored coordinates mode */
  11825. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  11826. /** Texture is not repeating outside of 0..1 UVs */
  11827. static readonly CLAMP_ADDRESSMODE: number;
  11828. /** Texture is repeating outside of 0..1 UVs */
  11829. static readonly WRAP_ADDRESSMODE: number;
  11830. /** Texture is repeating and mirrored */
  11831. static readonly MIRROR_ADDRESSMODE: number;
  11832. /**
  11833. * 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
  11834. */
  11835. static UseSerializedUrlIfAny: boolean;
  11836. /**
  11837. * Define the url of the texture.
  11838. */
  11839. url: Nullable<string>;
  11840. /**
  11841. * Define an offset on the texture to offset the u coordinates of the UVs
  11842. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  11843. */
  11844. uOffset: number;
  11845. /**
  11846. * Define an offset on the texture to offset the v coordinates of the UVs
  11847. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  11848. */
  11849. vOffset: number;
  11850. /**
  11851. * Define an offset on the texture to scale the u coordinates of the UVs
  11852. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  11853. */
  11854. uScale: number;
  11855. /**
  11856. * Define an offset on the texture to scale the v coordinates of the UVs
  11857. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  11858. */
  11859. vScale: number;
  11860. /**
  11861. * Define an offset on the texture to rotate around the u coordinates of the UVs
  11862. * @see http://doc.babylonjs.com/how_to/more_materials
  11863. */
  11864. uAng: number;
  11865. /**
  11866. * Define an offset on the texture to rotate around the v coordinates of the UVs
  11867. * @see http://doc.babylonjs.com/how_to/more_materials
  11868. */
  11869. vAng: number;
  11870. /**
  11871. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  11872. * @see http://doc.babylonjs.com/how_to/more_materials
  11873. */
  11874. wAng: number;
  11875. /**
  11876. * Defines the center of rotation (U)
  11877. */
  11878. uRotationCenter: number;
  11879. /**
  11880. * Defines the center of rotation (V)
  11881. */
  11882. vRotationCenter: number;
  11883. /**
  11884. * Defines the center of rotation (W)
  11885. */
  11886. wRotationCenter: number;
  11887. /**
  11888. * Are mip maps generated for this texture or not.
  11889. */
  11890. readonly noMipmap: boolean;
  11891. private _noMipmap;
  11892. /** @hidden */
  11893. _invertY: boolean;
  11894. private _rowGenerationMatrix;
  11895. private _cachedTextureMatrix;
  11896. private _projectionModeMatrix;
  11897. private _t0;
  11898. private _t1;
  11899. private _t2;
  11900. private _cachedUOffset;
  11901. private _cachedVOffset;
  11902. private _cachedUScale;
  11903. private _cachedVScale;
  11904. private _cachedUAng;
  11905. private _cachedVAng;
  11906. private _cachedWAng;
  11907. private _cachedProjectionMatrixId;
  11908. private _cachedCoordinatesMode;
  11909. /** @hidden */
  11910. protected _initialSamplingMode: number;
  11911. /** @hidden */
  11912. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  11913. private _deleteBuffer;
  11914. protected _format: Nullable<number>;
  11915. private _delayedOnLoad;
  11916. private _delayedOnError;
  11917. /**
  11918. * Observable triggered once the texture has been loaded.
  11919. */
  11920. onLoadObservable: Observable<Texture>;
  11921. protected _isBlocking: boolean;
  11922. /**
  11923. * Is the texture preventing material to render while loading.
  11924. * If false, a default texture will be used instead of the loading one during the preparation step.
  11925. */
  11926. isBlocking: boolean;
  11927. /**
  11928. * Get the current sampling mode associated with the texture.
  11929. */
  11930. readonly samplingMode: number;
  11931. /**
  11932. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  11933. */
  11934. readonly invertY: boolean;
  11935. /**
  11936. * Instantiates a new texture.
  11937. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  11938. * @see http://doc.babylonjs.com/babylon101/materials#texture
  11939. * @param url define the url of the picture to load as a texture
  11940. * @param scene define the scene the texture will belong to
  11941. * @param noMipmap define if the texture will require mip maps or not
  11942. * @param invertY define if the texture needs to be inverted on the y axis during loading
  11943. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  11944. * @param onLoad define a callback triggered when the texture has been loaded
  11945. * @param onError define a callback triggered when an error occurred during the loading session
  11946. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  11947. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  11948. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  11949. */
  11950. 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);
  11951. /**
  11952. * Update the url (and optional buffer) of this texture if url was null during construction.
  11953. * @param url the url of the texture
  11954. * @param buffer the buffer of the texture (defaults to null)
  11955. * @param onLoad callback called when the texture is loaded (defaults to null)
  11956. */
  11957. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  11958. /**
  11959. * Finish the loading sequence of a texture flagged as delayed load.
  11960. * @hidden
  11961. */
  11962. delayLoad(): void;
  11963. private _prepareRowForTextureGeneration;
  11964. /**
  11965. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  11966. * @returns the transform matrix of the texture.
  11967. */
  11968. getTextureMatrix(): Matrix;
  11969. /**
  11970. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  11971. * @returns The reflection texture transform
  11972. */
  11973. getReflectionTextureMatrix(): Matrix;
  11974. /**
  11975. * Clones the texture.
  11976. * @returns the cloned texture
  11977. */
  11978. clone(): Texture;
  11979. /**
  11980. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  11981. * @returns The JSON representation of the texture
  11982. */
  11983. serialize(): any;
  11984. /**
  11985. * Get the current class name of the texture useful for serialization or dynamic coding.
  11986. * @returns "Texture"
  11987. */
  11988. getClassName(): string;
  11989. /**
  11990. * Dispose the texture and release its associated resources.
  11991. */
  11992. dispose(): void;
  11993. /**
  11994. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  11995. * @param parsedTexture Define the JSON representation of the texture
  11996. * @param scene Define the scene the parsed texture should be instantiated in
  11997. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  11998. * @returns The parsed texture if successful
  11999. */
  12000. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  12001. /**
  12002. * Creates a texture from its base 64 representation.
  12003. * @param data Define the base64 payload without the data: prefix
  12004. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12005. * @param scene Define the scene the texture should belong to
  12006. * @param noMipmap Forces the texture to not create mip map information if true
  12007. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12008. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12009. * @param onLoad define a callback triggered when the texture has been loaded
  12010. * @param onError define a callback triggered when an error occurred during the loading session
  12011. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12012. * @returns the created texture
  12013. */
  12014. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  12015. /**
  12016. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  12017. * @param data Define the base64 payload without the data: prefix
  12018. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  12019. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  12020. * @param scene Define the scene the texture should belong to
  12021. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  12022. * @param noMipmap Forces the texture to not create mip map information if true
  12023. * @param invertY define if the texture needs to be inverted on the y axis during loading
  12024. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  12025. * @param onLoad define a callback triggered when the texture has been loaded
  12026. * @param onError define a callback triggered when an error occurred during the loading session
  12027. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  12028. * @returns the created texture
  12029. */
  12030. 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;
  12031. }
  12032. }
  12033. declare module "babylonjs/PostProcesses/postProcessManager" {
  12034. import { Nullable } from "babylonjs/types";
  12035. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12036. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  12037. import { Scene } from "babylonjs/scene";
  12038. /**
  12039. * PostProcessManager is used to manage one or more post processes or post process pipelines
  12040. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  12041. */
  12042. export class PostProcessManager {
  12043. private _scene;
  12044. private _indexBuffer;
  12045. private _vertexBuffers;
  12046. /**
  12047. * Creates a new instance PostProcess
  12048. * @param scene The scene that the post process is associated with.
  12049. */
  12050. constructor(scene: Scene);
  12051. private _prepareBuffers;
  12052. private _buildIndexBuffer;
  12053. /**
  12054. * Rebuilds the vertex buffers of the manager.
  12055. * @hidden
  12056. */
  12057. _rebuild(): void;
  12058. /**
  12059. * Prepares a frame to be run through a post process.
  12060. * @param sourceTexture The input texture to the post procesess. (default: null)
  12061. * @param postProcesses An array of post processes to be run. (default: null)
  12062. * @returns True if the post processes were able to be run.
  12063. * @hidden
  12064. */
  12065. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  12066. /**
  12067. * Manually render a set of post processes to a texture.
  12068. * @param postProcesses An array of post processes to be run.
  12069. * @param targetTexture The target texture to render to.
  12070. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  12071. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  12072. * @param lodLevel defines which lod of the texture to render to
  12073. */
  12074. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  12075. /**
  12076. * Finalize the result of the output of the postprocesses.
  12077. * @param doNotPresent If true the result will not be displayed to the screen.
  12078. * @param targetTexture The target texture to render to.
  12079. * @param faceIndex The index of the face to bind the target texture to.
  12080. * @param postProcesses The array of post processes to render.
  12081. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  12082. * @hidden
  12083. */
  12084. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  12085. /**
  12086. * Disposes of the post process manager.
  12087. */
  12088. dispose(): void;
  12089. }
  12090. }
  12091. declare module "babylonjs/sceneComponent" {
  12092. import { Scene } from "babylonjs/scene";
  12093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12094. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12095. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  12096. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  12097. import { Nullable } from "babylonjs/types";
  12098. import { Camera } from "babylonjs/Cameras/camera";
  12099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12100. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12101. import { AbstractScene } from "babylonjs/abstractScene";
  12102. /**
  12103. * Groups all the scene component constants in one place to ease maintenance.
  12104. * @hidden
  12105. */
  12106. export class SceneComponentConstants {
  12107. static readonly NAME_EFFECTLAYER: string;
  12108. static readonly NAME_LAYER: string;
  12109. static readonly NAME_LENSFLARESYSTEM: string;
  12110. static readonly NAME_BOUNDINGBOXRENDERER: string;
  12111. static readonly NAME_PARTICLESYSTEM: string;
  12112. static readonly NAME_GAMEPAD: string;
  12113. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  12114. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  12115. static readonly NAME_DEPTHRENDERER: string;
  12116. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  12117. static readonly NAME_SPRITE: string;
  12118. static readonly NAME_OUTLINERENDERER: string;
  12119. static readonly NAME_PROCEDURALTEXTURE: string;
  12120. static readonly NAME_SHADOWGENERATOR: string;
  12121. static readonly NAME_OCTREE: string;
  12122. static readonly NAME_PHYSICSENGINE: string;
  12123. static readonly NAME_AUDIO: string;
  12124. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  12125. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12126. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  12127. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  12128. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  12129. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  12130. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  12131. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  12132. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  12133. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  12134. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  12135. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  12136. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  12137. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  12138. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  12139. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  12140. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  12141. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  12142. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  12143. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  12144. static readonly STEP_AFTERRENDER_AUDIO: number;
  12145. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  12146. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  12147. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  12148. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  12149. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  12150. static readonly STEP_POINTERMOVE_SPRITE: number;
  12151. static readonly STEP_POINTERDOWN_SPRITE: number;
  12152. static readonly STEP_POINTERUP_SPRITE: number;
  12153. }
  12154. /**
  12155. * This represents a scene component.
  12156. *
  12157. * This is used to decouple the dependency the scene is having on the different workloads like
  12158. * layers, post processes...
  12159. */
  12160. export interface ISceneComponent {
  12161. /**
  12162. * The name of the component. Each component must have a unique name.
  12163. */
  12164. name: string;
  12165. /**
  12166. * The scene the component belongs to.
  12167. */
  12168. scene: Scene;
  12169. /**
  12170. * Register the component to one instance of a scene.
  12171. */
  12172. register(): void;
  12173. /**
  12174. * Rebuilds the elements related to this component in case of
  12175. * context lost for instance.
  12176. */
  12177. rebuild(): void;
  12178. /**
  12179. * Disposes the component and the associated ressources.
  12180. */
  12181. dispose(): void;
  12182. }
  12183. /**
  12184. * This represents a SERIALIZABLE scene component.
  12185. *
  12186. * This extends Scene Component to add Serialization methods on top.
  12187. */
  12188. export interface ISceneSerializableComponent extends ISceneComponent {
  12189. /**
  12190. * Adds all the element from the container to the scene
  12191. * @param container the container holding the elements
  12192. */
  12193. addFromContainer(container: AbstractScene): void;
  12194. /**
  12195. * Removes all the elements in the container from the scene
  12196. * @param container contains the elements to remove
  12197. */
  12198. removeFromContainer(container: AbstractScene): void;
  12199. /**
  12200. * Serializes the component data to the specified json object
  12201. * @param serializationObject The object to serialize to
  12202. */
  12203. serialize(serializationObject: any): void;
  12204. }
  12205. /**
  12206. * Strong typing of a Mesh related stage step action
  12207. */
  12208. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  12209. /**
  12210. * Strong typing of a Evaluate Sub Mesh related stage step action
  12211. */
  12212. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  12213. /**
  12214. * Strong typing of a Active Mesh related stage step action
  12215. */
  12216. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  12217. /**
  12218. * Strong typing of a Camera related stage step action
  12219. */
  12220. export type CameraStageAction = (camera: Camera) => void;
  12221. /**
  12222. * Strong typing of a Render Target related stage step action
  12223. */
  12224. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  12225. /**
  12226. * Strong typing of a RenderingGroup related stage step action
  12227. */
  12228. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  12229. /**
  12230. * Strong typing of a Mesh Render related stage step action
  12231. */
  12232. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  12233. /**
  12234. * Strong typing of a simple stage step action
  12235. */
  12236. export type SimpleStageAction = () => void;
  12237. /**
  12238. * Strong typing of a render target action.
  12239. */
  12240. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  12241. /**
  12242. * Strong typing of a pointer move action.
  12243. */
  12244. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  12245. /**
  12246. * Strong typing of a pointer up/down action.
  12247. */
  12248. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  12249. /**
  12250. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  12251. * @hidden
  12252. */
  12253. export class Stage<T extends Function> extends Array<{
  12254. index: number;
  12255. component: ISceneComponent;
  12256. action: T;
  12257. }> {
  12258. /**
  12259. * Hide ctor from the rest of the world.
  12260. * @param items The items to add.
  12261. */
  12262. private constructor();
  12263. /**
  12264. * Creates a new Stage.
  12265. * @returns A new instance of a Stage
  12266. */
  12267. static Create<T extends Function>(): Stage<T>;
  12268. /**
  12269. * Registers a step in an ordered way in the targeted stage.
  12270. * @param index Defines the position to register the step in
  12271. * @param component Defines the component attached to the step
  12272. * @param action Defines the action to launch during the step
  12273. */
  12274. registerStep(index: number, component: ISceneComponent, action: T): void;
  12275. /**
  12276. * Clears all the steps from the stage.
  12277. */
  12278. clear(): void;
  12279. }
  12280. }
  12281. declare module "babylonjs/Sprites/spriteSceneComponent" {
  12282. import { Nullable } from "babylonjs/types";
  12283. import { Observable } from "babylonjs/Misc/observable";
  12284. import { Scene } from "babylonjs/scene";
  12285. import { Sprite } from "babylonjs/Sprites/sprite";
  12286. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12287. import { Ray } from "babylonjs/Culling/ray";
  12288. import { Camera } from "babylonjs/Cameras/camera";
  12289. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12290. import { ISceneComponent } from "babylonjs/sceneComponent";
  12291. module "babylonjs/scene" {
  12292. interface Scene {
  12293. /** @hidden */
  12294. _pointerOverSprite: Nullable<Sprite>;
  12295. /** @hidden */
  12296. _pickedDownSprite: Nullable<Sprite>;
  12297. /** @hidden */
  12298. _tempSpritePickingRay: Nullable<Ray>;
  12299. /**
  12300. * All of the sprite managers added to this scene
  12301. * @see http://doc.babylonjs.com/babylon101/sprites
  12302. */
  12303. spriteManagers: Array<ISpriteManager>;
  12304. /**
  12305. * An event triggered when sprites rendering is about to start
  12306. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12307. */
  12308. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12309. /**
  12310. * An event triggered when sprites rendering is done
  12311. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12312. */
  12313. onAfterSpritesRenderingObservable: Observable<Scene>;
  12314. /** @hidden */
  12315. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12316. /** Launch a ray to try to pick a sprite in the scene
  12317. * @param x position on screen
  12318. * @param y position on screen
  12319. * @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
  12320. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12321. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12322. * @returns a PickingInfo
  12323. */
  12324. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12325. /** Use the given ray to pick a sprite in the scene
  12326. * @param ray The ray (in world space) to use to pick meshes
  12327. * @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
  12328. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12329. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12330. * @returns a PickingInfo
  12331. */
  12332. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12333. /**
  12334. * Force the sprite under the pointer
  12335. * @param sprite defines the sprite to use
  12336. */
  12337. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12338. /**
  12339. * Gets the sprite under the pointer
  12340. * @returns a Sprite or null if no sprite is under the pointer
  12341. */
  12342. getPointerOverSprite(): Nullable<Sprite>;
  12343. }
  12344. }
  12345. /**
  12346. * Defines the sprite scene component responsible to manage sprites
  12347. * in a given scene.
  12348. */
  12349. export class SpriteSceneComponent implements ISceneComponent {
  12350. /**
  12351. * The component name helpfull to identify the component in the list of scene components.
  12352. */
  12353. readonly name: string;
  12354. /**
  12355. * The scene the component belongs to.
  12356. */
  12357. scene: Scene;
  12358. /** @hidden */
  12359. private _spritePredicate;
  12360. /**
  12361. * Creates a new instance of the component for the given scene
  12362. * @param scene Defines the scene to register the component in
  12363. */
  12364. constructor(scene: Scene);
  12365. /**
  12366. * Registers the component in a given scene
  12367. */
  12368. register(): void;
  12369. /**
  12370. * Rebuilds the elements related to this component in case of
  12371. * context lost for instance.
  12372. */
  12373. rebuild(): void;
  12374. /**
  12375. * Disposes the component and the associated ressources.
  12376. */
  12377. dispose(): void;
  12378. private _pickSpriteButKeepRay;
  12379. private _pointerMove;
  12380. private _pointerDown;
  12381. private _pointerUp;
  12382. }
  12383. }
  12384. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12385. /** @hidden */
  12386. export var fogFragmentDeclaration: {
  12387. name: string;
  12388. shader: string;
  12389. };
  12390. }
  12391. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12392. /** @hidden */
  12393. export var fogFragment: {
  12394. name: string;
  12395. shader: string;
  12396. };
  12397. }
  12398. declare module "babylonjs/Shaders/sprites.fragment" {
  12399. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12400. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12401. /** @hidden */
  12402. export var spritesPixelShader: {
  12403. name: string;
  12404. shader: string;
  12405. };
  12406. }
  12407. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12408. /** @hidden */
  12409. export var fogVertexDeclaration: {
  12410. name: string;
  12411. shader: string;
  12412. };
  12413. }
  12414. declare module "babylonjs/Shaders/sprites.vertex" {
  12415. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12416. /** @hidden */
  12417. export var spritesVertexShader: {
  12418. name: string;
  12419. shader: string;
  12420. };
  12421. }
  12422. declare module "babylonjs/Sprites/spriteManager" {
  12423. import { IDisposable, Scene } from "babylonjs/scene";
  12424. import { Nullable } from "babylonjs/types";
  12425. import { Observable } from "babylonjs/Misc/observable";
  12426. import { Sprite } from "babylonjs/Sprites/sprite";
  12427. import { Ray } from "babylonjs/Culling/ray";
  12428. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12429. import { Camera } from "babylonjs/Cameras/camera";
  12430. import { Texture } from "babylonjs/Materials/Textures/texture";
  12431. import "babylonjs/Shaders/sprites.fragment";
  12432. import "babylonjs/Shaders/sprites.vertex";
  12433. /**
  12434. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12435. */
  12436. export interface ISpriteManager extends IDisposable {
  12437. /**
  12438. * Restricts the camera to viewing objects with the same layerMask.
  12439. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12440. */
  12441. layerMask: number;
  12442. /**
  12443. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12444. */
  12445. isPickable: boolean;
  12446. /**
  12447. * Specifies the rendering group id for this mesh (0 by default)
  12448. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12449. */
  12450. renderingGroupId: number;
  12451. /**
  12452. * Defines the list of sprites managed by the manager.
  12453. */
  12454. sprites: Array<Sprite>;
  12455. /**
  12456. * Tests the intersection of a sprite with a specific ray.
  12457. * @param ray The ray we are sending to test the collision
  12458. * @param camera The camera space we are sending rays in
  12459. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12460. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12461. * @returns picking info or null.
  12462. */
  12463. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12464. /**
  12465. * Renders the list of sprites on screen.
  12466. */
  12467. render(): void;
  12468. }
  12469. /**
  12470. * Class used to manage multiple sprites on the same spritesheet
  12471. * @see http://doc.babylonjs.com/babylon101/sprites
  12472. */
  12473. export class SpriteManager implements ISpriteManager {
  12474. /** defines the manager's name */
  12475. name: string;
  12476. /** Gets the list of sprites */
  12477. sprites: Sprite[];
  12478. /** Gets or sets the rendering group id (0 by default) */
  12479. renderingGroupId: number;
  12480. /** Gets or sets camera layer mask */
  12481. layerMask: number;
  12482. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12483. fogEnabled: boolean;
  12484. /** Gets or sets a boolean indicating if the sprites are pickable */
  12485. isPickable: boolean;
  12486. /** Defines the default width of a cell in the spritesheet */
  12487. cellWidth: number;
  12488. /** Defines the default height of a cell in the spritesheet */
  12489. cellHeight: number;
  12490. /**
  12491. * An event triggered when the manager is disposed.
  12492. */
  12493. onDisposeObservable: Observable<SpriteManager>;
  12494. private _onDisposeObserver;
  12495. /**
  12496. * Callback called when the manager is disposed
  12497. */
  12498. onDispose: () => void;
  12499. private _capacity;
  12500. private _spriteTexture;
  12501. private _epsilon;
  12502. private _scene;
  12503. private _vertexData;
  12504. private _buffer;
  12505. private _vertexBuffers;
  12506. private _indexBuffer;
  12507. private _effectBase;
  12508. private _effectFog;
  12509. /**
  12510. * Gets or sets the spritesheet texture
  12511. */
  12512. texture: Texture;
  12513. /**
  12514. * Creates a new sprite manager
  12515. * @param name defines the manager's name
  12516. * @param imgUrl defines the sprite sheet url
  12517. * @param capacity defines the maximum allowed number of sprites
  12518. * @param cellSize defines the size of a sprite cell
  12519. * @param scene defines the hosting scene
  12520. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12521. * @param samplingMode defines the smapling mode to use with spritesheet
  12522. */
  12523. constructor(
  12524. /** defines the manager's name */
  12525. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12526. private _appendSpriteVertex;
  12527. /**
  12528. * Intersects the sprites with a ray
  12529. * @param ray defines the ray to intersect with
  12530. * @param camera defines the current active camera
  12531. * @param predicate defines a predicate used to select candidate sprites
  12532. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12533. * @returns null if no hit or a PickingInfo
  12534. */
  12535. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12536. /**
  12537. * Render all child sprites
  12538. */
  12539. render(): void;
  12540. /**
  12541. * Release associated resources
  12542. */
  12543. dispose(): void;
  12544. }
  12545. }
  12546. declare module "babylonjs/Materials/Textures/rawTexture" {
  12547. import { Scene } from "babylonjs/scene";
  12548. import { Texture } from "babylonjs/Materials/Textures/texture";
  12549. /**
  12550. * Raw texture can help creating a texture directly from an array of data.
  12551. * This can be super useful if you either get the data from an uncompressed source or
  12552. * if you wish to create your texture pixel by pixel.
  12553. */
  12554. export class RawTexture extends Texture {
  12555. /**
  12556. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12557. */
  12558. format: number;
  12559. private _engine;
  12560. /**
  12561. * Instantiates a new RawTexture.
  12562. * Raw texture can help creating a texture directly from an array of data.
  12563. * This can be super useful if you either get the data from an uncompressed source or
  12564. * if you wish to create your texture pixel by pixel.
  12565. * @param data define the array of data to use to create the texture
  12566. * @param width define the width of the texture
  12567. * @param height define the height of the texture
  12568. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12569. * @param scene define the scene the texture belongs to
  12570. * @param generateMipMaps define whether mip maps should be generated or not
  12571. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12572. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12573. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12574. */
  12575. constructor(data: ArrayBufferView, width: number, height: number,
  12576. /**
  12577. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12578. */
  12579. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12580. /**
  12581. * Updates the texture underlying data.
  12582. * @param data Define the new data of the texture
  12583. */
  12584. update(data: ArrayBufferView): void;
  12585. /**
  12586. * Creates a luminance texture from some data.
  12587. * @param data Define the texture data
  12588. * @param width Define the width of the texture
  12589. * @param height Define the height of the texture
  12590. * @param scene Define the scene the texture belongs to
  12591. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12592. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12593. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12594. * @returns the luminance texture
  12595. */
  12596. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12597. /**
  12598. * Creates a luminance alpha texture from some data.
  12599. * @param data Define the texture data
  12600. * @param width Define the width of the texture
  12601. * @param height Define the height of the texture
  12602. * @param scene Define the scene the texture belongs to
  12603. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12604. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12605. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12606. * @returns the luminance alpha texture
  12607. */
  12608. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12609. /**
  12610. * Creates an alpha texture from some data.
  12611. * @param data Define the texture data
  12612. * @param width Define the width of the texture
  12613. * @param height Define the height of the texture
  12614. * @param scene Define the scene the texture belongs to
  12615. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12616. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12617. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12618. * @returns the alpha texture
  12619. */
  12620. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12621. /**
  12622. * Creates a RGB texture from some data.
  12623. * @param data Define the texture data
  12624. * @param width Define the width of the texture
  12625. * @param height Define the height of the texture
  12626. * @param scene Define the scene the texture belongs to
  12627. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12628. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12629. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12630. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12631. * @returns the RGB alpha texture
  12632. */
  12633. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12634. /**
  12635. * Creates a RGBA texture from some data.
  12636. * @param data Define the texture data
  12637. * @param width Define the width of the texture
  12638. * @param height Define the height of the texture
  12639. * @param scene Define the scene the texture belongs to
  12640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12643. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12644. * @returns the RGBA texture
  12645. */
  12646. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12647. /**
  12648. * Creates a R texture from some data.
  12649. * @param data Define the texture data
  12650. * @param width Define the width of the texture
  12651. * @param height Define the height of the texture
  12652. * @param scene Define the scene the texture belongs to
  12653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12657. * @returns the R texture
  12658. */
  12659. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12660. }
  12661. }
  12662. declare module "babylonjs/Layers/layerSceneComponent" {
  12663. import { Scene } from "babylonjs/scene";
  12664. import { ISceneComponent } from "babylonjs/sceneComponent";
  12665. import { Layer } from "babylonjs/Layers/layer";
  12666. module "babylonjs/abstractScene" {
  12667. interface AbstractScene {
  12668. /**
  12669. * The list of layers (background and foreground) of the scene
  12670. */
  12671. layers: Array<Layer>;
  12672. }
  12673. }
  12674. /**
  12675. * Defines the layer scene component responsible to manage any layers
  12676. * in a given scene.
  12677. */
  12678. export class LayerSceneComponent implements ISceneComponent {
  12679. /**
  12680. * The component name helpfull to identify the component in the list of scene components.
  12681. */
  12682. readonly name: string;
  12683. /**
  12684. * The scene the component belongs to.
  12685. */
  12686. scene: Scene;
  12687. private _engine;
  12688. /**
  12689. * Creates a new instance of the component for the given scene
  12690. * @param scene Defines the scene to register the component in
  12691. */
  12692. constructor(scene: Scene);
  12693. /**
  12694. * Registers the component in a given scene
  12695. */
  12696. register(): void;
  12697. /**
  12698. * Rebuilds the elements related to this component in case of
  12699. * context lost for instance.
  12700. */
  12701. rebuild(): void;
  12702. /**
  12703. * Disposes the component and the associated ressources.
  12704. */
  12705. dispose(): void;
  12706. private _draw;
  12707. private _drawCameraPredicate;
  12708. private _drawCameraBackground;
  12709. private _drawCameraForeground;
  12710. private _drawRenderTargetPredicate;
  12711. private _drawRenderTargetBackground;
  12712. private _drawRenderTargetForeground;
  12713. }
  12714. }
  12715. declare module "babylonjs/Shaders/layer.fragment" {
  12716. /** @hidden */
  12717. export var layerPixelShader: {
  12718. name: string;
  12719. shader: string;
  12720. };
  12721. }
  12722. declare module "babylonjs/Shaders/layer.vertex" {
  12723. /** @hidden */
  12724. export var layerVertexShader: {
  12725. name: string;
  12726. shader: string;
  12727. };
  12728. }
  12729. declare module "babylonjs/Layers/layer" {
  12730. import { Observable } from "babylonjs/Misc/observable";
  12731. import { Nullable } from "babylonjs/types";
  12732. import { Scene } from "babylonjs/scene";
  12733. import { Vector2, Color4 } from "babylonjs/Maths/math";
  12734. import { Texture } from "babylonjs/Materials/Textures/texture";
  12735. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  12736. import "babylonjs/Shaders/layer.fragment";
  12737. import "babylonjs/Shaders/layer.vertex";
  12738. /**
  12739. * This represents a full screen 2d layer.
  12740. * This can be useful to display a picture in the background of your scene for instance.
  12741. * @see https://www.babylonjs-playground.com/#08A2BS#1
  12742. */
  12743. export class Layer {
  12744. /**
  12745. * Define the name of the layer.
  12746. */
  12747. name: string;
  12748. /**
  12749. * Define the texture the layer should display.
  12750. */
  12751. texture: Nullable<Texture>;
  12752. /**
  12753. * Is the layer in background or foreground.
  12754. */
  12755. isBackground: boolean;
  12756. /**
  12757. * Define the color of the layer (instead of texture).
  12758. */
  12759. color: Color4;
  12760. /**
  12761. * Define the scale of the layer in order to zoom in out of the texture.
  12762. */
  12763. scale: Vector2;
  12764. /**
  12765. * Define an offset for the layer in order to shift the texture.
  12766. */
  12767. offset: Vector2;
  12768. /**
  12769. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  12770. */
  12771. alphaBlendingMode: number;
  12772. /**
  12773. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  12774. * Alpha test will not mix with the background color in case of transparency.
  12775. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  12776. */
  12777. alphaTest: boolean;
  12778. /**
  12779. * Define a mask to restrict the layer to only some of the scene cameras.
  12780. */
  12781. layerMask: number;
  12782. /**
  12783. * Define the list of render target the layer is visible into.
  12784. */
  12785. renderTargetTextures: RenderTargetTexture[];
  12786. /**
  12787. * Define if the layer is only used in renderTarget or if it also
  12788. * renders in the main frame buffer of the canvas.
  12789. */
  12790. renderOnlyInRenderTargetTextures: boolean;
  12791. private _scene;
  12792. private _vertexBuffers;
  12793. private _indexBuffer;
  12794. private _effect;
  12795. private _alphaTestEffect;
  12796. /**
  12797. * An event triggered when the layer is disposed.
  12798. */
  12799. onDisposeObservable: Observable<Layer>;
  12800. private _onDisposeObserver;
  12801. /**
  12802. * Back compatibility with callback before the onDisposeObservable existed.
  12803. * The set callback will be triggered when the layer has been disposed.
  12804. */
  12805. onDispose: () => void;
  12806. /**
  12807. * An event triggered before rendering the scene
  12808. */
  12809. onBeforeRenderObservable: Observable<Layer>;
  12810. private _onBeforeRenderObserver;
  12811. /**
  12812. * Back compatibility with callback before the onBeforeRenderObservable existed.
  12813. * The set callback will be triggered just before rendering the layer.
  12814. */
  12815. onBeforeRender: () => void;
  12816. /**
  12817. * An event triggered after rendering the scene
  12818. */
  12819. onAfterRenderObservable: Observable<Layer>;
  12820. private _onAfterRenderObserver;
  12821. /**
  12822. * Back compatibility with callback before the onAfterRenderObservable existed.
  12823. * The set callback will be triggered just after rendering the layer.
  12824. */
  12825. onAfterRender: () => void;
  12826. /**
  12827. * Instantiates a new layer.
  12828. * This represents a full screen 2d layer.
  12829. * This can be useful to display a picture in the background of your scene for instance.
  12830. * @see https://www.babylonjs-playground.com/#08A2BS#1
  12831. * @param name Define the name of the layer in the scene
  12832. * @param imgUrl Define the url of the texture to display in the layer
  12833. * @param scene Define the scene the layer belongs to
  12834. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  12835. * @param color Defines a color for the layer
  12836. */
  12837. constructor(
  12838. /**
  12839. * Define the name of the layer.
  12840. */
  12841. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  12842. private _createIndexBuffer;
  12843. /** @hidden */
  12844. _rebuild(): void;
  12845. /**
  12846. * Renders the layer in the scene.
  12847. */
  12848. render(): void;
  12849. /**
  12850. * Disposes and releases the associated ressources.
  12851. */
  12852. dispose(): void;
  12853. }
  12854. }
  12855. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  12856. import { Scene } from "babylonjs/scene";
  12857. import { ISceneComponent } from "babylonjs/sceneComponent";
  12858. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12859. module "babylonjs/abstractScene" {
  12860. interface AbstractScene {
  12861. /**
  12862. * The list of procedural textures added to the scene
  12863. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12864. */
  12865. proceduralTextures: Array<ProceduralTexture>;
  12866. }
  12867. }
  12868. /**
  12869. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  12870. * in a given scene.
  12871. */
  12872. export class ProceduralTextureSceneComponent implements ISceneComponent {
  12873. /**
  12874. * The component name helpfull to identify the component in the list of scene components.
  12875. */
  12876. readonly name: string;
  12877. /**
  12878. * The scene the component belongs to.
  12879. */
  12880. scene: Scene;
  12881. /**
  12882. * Creates a new instance of the component for the given scene
  12883. * @param scene Defines the scene to register the component in
  12884. */
  12885. constructor(scene: Scene);
  12886. /**
  12887. * Registers the component in a given scene
  12888. */
  12889. register(): void;
  12890. /**
  12891. * Rebuilds the elements related to this component in case of
  12892. * context lost for instance.
  12893. */
  12894. rebuild(): void;
  12895. /**
  12896. * Disposes the component and the associated ressources.
  12897. */
  12898. dispose(): void;
  12899. private _beforeClear;
  12900. }
  12901. }
  12902. declare module "babylonjs/Shaders/procedural.vertex" {
  12903. /** @hidden */
  12904. export var proceduralVertexShader: {
  12905. name: string;
  12906. shader: string;
  12907. };
  12908. }
  12909. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12910. import { Observable } from "babylonjs/Misc/observable";
  12911. import { Nullable } from "babylonjs/types";
  12912. import { Scene } from "babylonjs/scene";
  12913. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  12914. import { Effect } from "babylonjs/Materials/effect";
  12915. import { Texture } from "babylonjs/Materials/Textures/texture";
  12916. import "babylonjs/Shaders/procedural.vertex";
  12917. /**
  12918. * 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.
  12919. * This is the base class of any Procedural texture and contains most of the shareable code.
  12920. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12921. */
  12922. export class ProceduralTexture extends Texture {
  12923. isCube: boolean;
  12924. /**
  12925. * Define if the texture is enabled or not (disabled texture will not render)
  12926. */
  12927. isEnabled: boolean;
  12928. /**
  12929. * Define if the texture must be cleared before rendering (default is true)
  12930. */
  12931. autoClear: boolean;
  12932. /**
  12933. * Callback called when the texture is generated
  12934. */
  12935. onGenerated: () => void;
  12936. /**
  12937. * Event raised when the texture is generated
  12938. */
  12939. onGeneratedObservable: Observable<ProceduralTexture>;
  12940. /** @hidden */
  12941. _generateMipMaps: boolean;
  12942. /** @hidden **/
  12943. _effect: Effect;
  12944. /** @hidden */
  12945. _textures: {
  12946. [key: string]: Texture;
  12947. };
  12948. private _size;
  12949. private _currentRefreshId;
  12950. private _refreshRate;
  12951. private _vertexBuffers;
  12952. private _indexBuffer;
  12953. private _uniforms;
  12954. private _samplers;
  12955. private _fragment;
  12956. private _floats;
  12957. private _ints;
  12958. private _floatsArrays;
  12959. private _colors3;
  12960. private _colors4;
  12961. private _vectors2;
  12962. private _vectors3;
  12963. private _matrices;
  12964. private _fallbackTexture;
  12965. private _fallbackTextureUsed;
  12966. private _engine;
  12967. private _cachedDefines;
  12968. private _contentUpdateId;
  12969. private _contentData;
  12970. /**
  12971. * Instantiates a new procedural texture.
  12972. * 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.
  12973. * This is the base class of any Procedural texture and contains most of the shareable code.
  12974. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12975. * @param name Define the name of the texture
  12976. * @param size Define the size of the texture to create
  12977. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12978. * @param scene Define the scene the texture belongs to
  12979. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12980. * @param generateMipMaps Define if the texture should creates mip maps or not
  12981. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12982. */
  12983. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12984. /**
  12985. * The effect that is created when initializing the post process.
  12986. * @returns The created effect corrisponding the the postprocess.
  12987. */
  12988. getEffect(): Effect;
  12989. /**
  12990. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12991. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12992. */
  12993. getContent(): Nullable<ArrayBufferView>;
  12994. private _createIndexBuffer;
  12995. /** @hidden */
  12996. _rebuild(): void;
  12997. /**
  12998. * Resets the texture in order to recreate its associated resources.
  12999. * This can be called in case of context loss
  13000. */
  13001. reset(): void;
  13002. protected _getDefines(): string;
  13003. /**
  13004. * Is the texture ready to be used ? (rendered at least once)
  13005. * @returns true if ready, otherwise, false.
  13006. */
  13007. isReady(): boolean;
  13008. /**
  13009. * Resets the refresh counter of the texture and start bak from scratch.
  13010. * Could be useful to regenerate the texture if it is setup to render only once.
  13011. */
  13012. resetRefreshCounter(): void;
  13013. /**
  13014. * Set the fragment shader to use in order to render the texture.
  13015. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13016. */
  13017. setFragment(fragment: any): void;
  13018. /**
  13019. * Define the refresh rate of the texture or the rendering frequency.
  13020. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13021. */
  13022. refreshRate: number;
  13023. /** @hidden */
  13024. _shouldRender(): boolean;
  13025. /**
  13026. * Get the size the texture is rendering at.
  13027. * @returns the size (texture is always squared)
  13028. */
  13029. getRenderSize(): number;
  13030. /**
  13031. * Resize the texture to new value.
  13032. * @param size Define the new size the texture should have
  13033. * @param generateMipMaps Define whether the new texture should create mip maps
  13034. */
  13035. resize(size: number, generateMipMaps: boolean): void;
  13036. private _checkUniform;
  13037. /**
  13038. * Set a texture in the shader program used to render.
  13039. * @param name Define the name of the uniform samplers as defined in the shader
  13040. * @param texture Define the texture to bind to this sampler
  13041. * @return the texture itself allowing "fluent" like uniform updates
  13042. */
  13043. setTexture(name: string, texture: Texture): ProceduralTexture;
  13044. /**
  13045. * Set a float in the shader.
  13046. * @param name Define the name of the uniform as defined in the shader
  13047. * @param value Define the value to give to the uniform
  13048. * @return the texture itself allowing "fluent" like uniform updates
  13049. */
  13050. setFloat(name: string, value: number): ProceduralTexture;
  13051. /**
  13052. * Set a int in the shader.
  13053. * @param name Define the name of the uniform as defined in the shader
  13054. * @param value Define the value to give to the uniform
  13055. * @return the texture itself allowing "fluent" like uniform updates
  13056. */
  13057. setInt(name: string, value: number): ProceduralTexture;
  13058. /**
  13059. * Set an array of floats in the shader.
  13060. * @param name Define the name of the uniform as defined in the shader
  13061. * @param value Define the value to give to the uniform
  13062. * @return the texture itself allowing "fluent" like uniform updates
  13063. */
  13064. setFloats(name: string, value: number[]): ProceduralTexture;
  13065. /**
  13066. * Set a vec3 in the shader from a Color3.
  13067. * @param name Define the name of the uniform as defined in the shader
  13068. * @param value Define the value to give to the uniform
  13069. * @return the texture itself allowing "fluent" like uniform updates
  13070. */
  13071. setColor3(name: string, value: Color3): ProceduralTexture;
  13072. /**
  13073. * Set a vec4 in the shader from a Color4.
  13074. * @param name Define the name of the uniform as defined in the shader
  13075. * @param value Define the value to give to the uniform
  13076. * @return the texture itself allowing "fluent" like uniform updates
  13077. */
  13078. setColor4(name: string, value: Color4): ProceduralTexture;
  13079. /**
  13080. * Set a vec2 in the shader from a Vector2.
  13081. * @param name Define the name of the uniform as defined in the shader
  13082. * @param value Define the value to give to the uniform
  13083. * @return the texture itself allowing "fluent" like uniform updates
  13084. */
  13085. setVector2(name: string, value: Vector2): ProceduralTexture;
  13086. /**
  13087. * Set a vec3 in the shader from a Vector3.
  13088. * @param name Define the name of the uniform as defined in the shader
  13089. * @param value Define the value to give to the uniform
  13090. * @return the texture itself allowing "fluent" like uniform updates
  13091. */
  13092. setVector3(name: string, value: Vector3): ProceduralTexture;
  13093. /**
  13094. * Set a mat4 in the shader from a MAtrix.
  13095. * @param name Define the name of the uniform as defined in the shader
  13096. * @param value Define the value to give to the uniform
  13097. * @return the texture itself allowing "fluent" like uniform updates
  13098. */
  13099. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13100. /**
  13101. * Render the texture to its associated render target.
  13102. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13103. */
  13104. render(useCameraPostProcess?: boolean): void;
  13105. /**
  13106. * Clone the texture.
  13107. * @returns the cloned texture
  13108. */
  13109. clone(): ProceduralTexture;
  13110. /**
  13111. * Dispose the texture and release its asoociated resources.
  13112. */
  13113. dispose(): void;
  13114. }
  13115. }
  13116. declare module "babylonjs/Particles/baseParticleSystem" {
  13117. import { Nullable } from "babylonjs/types";
  13118. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  13119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13120. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  13121. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  13122. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13123. import { Scene } from "babylonjs/scene";
  13124. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  13125. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13126. import { Texture } from "babylonjs/Materials/Textures/texture";
  13127. import { Animation } from "babylonjs/Animations/animation";
  13128. /**
  13129. * This represents the base class for particle system in Babylon.
  13130. * 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.
  13131. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13132. * @example https://doc.babylonjs.com/babylon101/particles
  13133. */
  13134. export class BaseParticleSystem {
  13135. /**
  13136. * Source color is added to the destination color without alpha affecting the result
  13137. */
  13138. static BLENDMODE_ONEONE: number;
  13139. /**
  13140. * Blend current color and particle color using particle’s alpha
  13141. */
  13142. static BLENDMODE_STANDARD: number;
  13143. /**
  13144. * Add current color and particle color multiplied by particle’s alpha
  13145. */
  13146. static BLENDMODE_ADD: number;
  13147. /**
  13148. * Multiply current color with particle color
  13149. */
  13150. static BLENDMODE_MULTIPLY: number;
  13151. /**
  13152. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13153. */
  13154. static BLENDMODE_MULTIPLYADD: number;
  13155. /**
  13156. * List of animations used by the particle system.
  13157. */
  13158. animations: Animation[];
  13159. /**
  13160. * The id of the Particle system.
  13161. */
  13162. id: string;
  13163. /**
  13164. * The friendly name of the Particle system.
  13165. */
  13166. name: string;
  13167. /**
  13168. * The rendering group used by the Particle system to chose when to render.
  13169. */
  13170. renderingGroupId: number;
  13171. /**
  13172. * The emitter represents the Mesh or position we are attaching the particle system to.
  13173. */
  13174. emitter: Nullable<AbstractMesh | Vector3>;
  13175. /**
  13176. * The maximum number of particles to emit per frame
  13177. */
  13178. emitRate: number;
  13179. /**
  13180. * If you want to launch only a few particles at once, that can be done, as well.
  13181. */
  13182. manualEmitCount: number;
  13183. /**
  13184. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13185. */
  13186. updateSpeed: number;
  13187. /**
  13188. * The amount of time the particle system is running (depends of the overall update speed).
  13189. */
  13190. targetStopDuration: number;
  13191. /**
  13192. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13193. */
  13194. disposeOnStop: boolean;
  13195. /**
  13196. * Minimum power of emitting particles.
  13197. */
  13198. minEmitPower: number;
  13199. /**
  13200. * Maximum power of emitting particles.
  13201. */
  13202. maxEmitPower: number;
  13203. /**
  13204. * Minimum life time of emitting particles.
  13205. */
  13206. minLifeTime: number;
  13207. /**
  13208. * Maximum life time of emitting particles.
  13209. */
  13210. maxLifeTime: number;
  13211. /**
  13212. * Minimum Size of emitting particles.
  13213. */
  13214. minSize: number;
  13215. /**
  13216. * Maximum Size of emitting particles.
  13217. */
  13218. maxSize: number;
  13219. /**
  13220. * Minimum scale of emitting particles on X axis.
  13221. */
  13222. minScaleX: number;
  13223. /**
  13224. * Maximum scale of emitting particles on X axis.
  13225. */
  13226. maxScaleX: number;
  13227. /**
  13228. * Minimum scale of emitting particles on Y axis.
  13229. */
  13230. minScaleY: number;
  13231. /**
  13232. * Maximum scale of emitting particles on Y axis.
  13233. */
  13234. maxScaleY: number;
  13235. /**
  13236. * Gets or sets the minimal initial rotation in radians.
  13237. */
  13238. minInitialRotation: number;
  13239. /**
  13240. * Gets or sets the maximal initial rotation in radians.
  13241. */
  13242. maxInitialRotation: number;
  13243. /**
  13244. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13245. */
  13246. minAngularSpeed: number;
  13247. /**
  13248. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13249. */
  13250. maxAngularSpeed: number;
  13251. /**
  13252. * The texture used to render each particle. (this can be a spritesheet)
  13253. */
  13254. particleTexture: Nullable<Texture>;
  13255. /**
  13256. * The layer mask we are rendering the particles through.
  13257. */
  13258. layerMask: number;
  13259. /**
  13260. * This can help using your own shader to render the particle system.
  13261. * The according effect will be created
  13262. */
  13263. customShader: any;
  13264. /**
  13265. * By default particle system starts as soon as they are created. This prevents the
  13266. * automatic start to happen and let you decide when to start emitting particles.
  13267. */
  13268. preventAutoStart: boolean;
  13269. private _noiseTexture;
  13270. /**
  13271. * Gets or sets a texture used to add random noise to particle positions
  13272. */
  13273. noiseTexture: Nullable<ProceduralTexture>;
  13274. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13275. noiseStrength: Vector3;
  13276. /**
  13277. * Callback triggered when the particle animation is ending.
  13278. */
  13279. onAnimationEnd: Nullable<() => void>;
  13280. /**
  13281. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  13282. */
  13283. blendMode: number;
  13284. /**
  13285. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  13286. * to override the particles.
  13287. */
  13288. forceDepthWrite: boolean;
  13289. /** 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 */
  13290. preWarmCycles: number;
  13291. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  13292. preWarmStepOffset: number;
  13293. /**
  13294. * 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)
  13295. */
  13296. spriteCellChangeSpeed: number;
  13297. /**
  13298. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13299. */
  13300. startSpriteCellID: number;
  13301. /**
  13302. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13303. */
  13304. endSpriteCellID: number;
  13305. /**
  13306. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13307. */
  13308. spriteCellWidth: number;
  13309. /**
  13310. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13311. */
  13312. spriteCellHeight: number;
  13313. /**
  13314. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13315. */
  13316. spriteRandomStartCell: boolean;
  13317. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13318. translationPivot: Vector2;
  13319. /** @hidden */
  13320. protected _isAnimationSheetEnabled: boolean;
  13321. /**
  13322. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13323. */
  13324. beginAnimationOnStart: boolean;
  13325. /**
  13326. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13327. */
  13328. beginAnimationFrom: number;
  13329. /**
  13330. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13331. */
  13332. beginAnimationTo: number;
  13333. /**
  13334. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13335. */
  13336. beginAnimationLoop: boolean;
  13337. /**
  13338. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  13339. */
  13340. isAnimationSheetEnabled: boolean;
  13341. /**
  13342. * Get hosting scene
  13343. * @returns the scene
  13344. */
  13345. getScene(): Scene;
  13346. /**
  13347. * You can use gravity if you want to give an orientation to your particles.
  13348. */
  13349. gravity: Vector3;
  13350. protected _colorGradients: Nullable<Array<ColorGradient>>;
  13351. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  13352. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  13353. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  13354. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  13355. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  13356. protected _dragGradients: Nullable<Array<FactorGradient>>;
  13357. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  13358. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  13359. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  13360. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  13361. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  13362. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  13363. /**
  13364. * Defines the delay in milliseconds before starting the system (0 by default)
  13365. */
  13366. startDelay: number;
  13367. /**
  13368. * Gets the current list of drag gradients.
  13369. * You must use addDragGradient and removeDragGradient to udpate this list
  13370. * @returns the list of drag gradients
  13371. */
  13372. getDragGradients(): Nullable<Array<FactorGradient>>;
  13373. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13374. limitVelocityDamping: number;
  13375. /**
  13376. * Gets the current list of limit velocity gradients.
  13377. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13378. * @returns the list of limit velocity gradients
  13379. */
  13380. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13381. /**
  13382. * Gets the current list of color gradients.
  13383. * You must use addColorGradient and removeColorGradient to udpate this list
  13384. * @returns the list of color gradients
  13385. */
  13386. getColorGradients(): Nullable<Array<ColorGradient>>;
  13387. /**
  13388. * Gets the current list of size gradients.
  13389. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13390. * @returns the list of size gradients
  13391. */
  13392. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13393. /**
  13394. * Gets the current list of color remap gradients.
  13395. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13396. * @returns the list of color remap gradients
  13397. */
  13398. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13399. /**
  13400. * Gets the current list of alpha remap gradients.
  13401. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13402. * @returns the list of alpha remap gradients
  13403. */
  13404. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13405. /**
  13406. * Gets the current list of life time gradients.
  13407. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13408. * @returns the list of life time gradients
  13409. */
  13410. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13411. /**
  13412. * Gets the current list of angular speed gradients.
  13413. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13414. * @returns the list of angular speed gradients
  13415. */
  13416. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13417. /**
  13418. * Gets the current list of velocity gradients.
  13419. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13420. * @returns the list of velocity gradients
  13421. */
  13422. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13423. /**
  13424. * Gets the current list of start size gradients.
  13425. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13426. * @returns the list of start size gradients
  13427. */
  13428. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13429. /**
  13430. * Gets the current list of emit rate gradients.
  13431. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13432. * @returns the list of emit rate gradients
  13433. */
  13434. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13435. /**
  13436. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13437. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13438. */
  13439. direction1: Vector3;
  13440. /**
  13441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13442. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13443. */
  13444. direction2: Vector3;
  13445. /**
  13446. * 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.
  13447. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13448. */
  13449. minEmitBox: Vector3;
  13450. /**
  13451. * 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.
  13452. * This only works when particleEmitterTyps is a BoxParticleEmitter
  13453. */
  13454. maxEmitBox: Vector3;
  13455. /**
  13456. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13457. */
  13458. color1: Color4;
  13459. /**
  13460. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  13461. */
  13462. color2: Color4;
  13463. /**
  13464. * Color the particle will have at the end of its lifetime
  13465. */
  13466. colorDead: Color4;
  13467. /**
  13468. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  13469. */
  13470. textureMask: Color4;
  13471. /**
  13472. * The particle emitter type defines the emitter used by the particle system.
  13473. * It can be for example box, sphere, or cone...
  13474. */
  13475. particleEmitterType: IParticleEmitterType;
  13476. /** @hidden */
  13477. _isSubEmitter: boolean;
  13478. /**
  13479. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13480. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13481. */
  13482. billboardMode: number;
  13483. protected _isBillboardBased: boolean;
  13484. /**
  13485. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13486. */
  13487. isBillboardBased: boolean;
  13488. /**
  13489. * The scene the particle system belongs to.
  13490. */
  13491. protected _scene: Scene;
  13492. /**
  13493. * Local cache of defines for image processing.
  13494. */
  13495. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  13496. /**
  13497. * Default configuration related to image processing available in the standard Material.
  13498. */
  13499. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  13500. /**
  13501. * Gets the image processing configuration used either in this material.
  13502. */
  13503. /**
  13504. * Sets the Default image processing configuration used either in the this material.
  13505. *
  13506. * If sets to null, the scene one is in use.
  13507. */
  13508. imageProcessingConfiguration: ImageProcessingConfiguration;
  13509. /**
  13510. * Attaches a new image processing configuration to the Standard Material.
  13511. * @param configuration
  13512. */
  13513. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  13514. /** @hidden */
  13515. protected _reset(): void;
  13516. /** @hidden */
  13517. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  13518. /**
  13519. * Instantiates a particle system.
  13520. * 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.
  13521. * @param name The name of the particle system
  13522. */
  13523. constructor(name: string);
  13524. /**
  13525. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13526. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13527. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13528. * @returns the emitter
  13529. */
  13530. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13531. /**
  13532. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13533. * @param radius The radius of the hemisphere to emit from
  13534. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13535. * @returns the emitter
  13536. */
  13537. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  13538. /**
  13539. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13540. * @param radius The radius of the sphere to emit from
  13541. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13542. * @returns the emitter
  13543. */
  13544. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  13545. /**
  13546. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13547. * @param radius The radius of the sphere to emit from
  13548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13550. * @returns the emitter
  13551. */
  13552. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  13553. /**
  13554. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13555. * @param radius The radius of the emission cylinder
  13556. * @param height The height of the emission cylinder
  13557. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13558. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13559. * @returns the emitter
  13560. */
  13561. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  13562. /**
  13563. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13564. * @param radius The radius of the cylinder to emit from
  13565. * @param height The height of the emission cylinder
  13566. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13567. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13568. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13569. * @returns the emitter
  13570. */
  13571. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  13572. /**
  13573. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13574. * @param radius The radius of the cone to emit from
  13575. * @param angle The base angle of the cone
  13576. * @returns the emitter
  13577. */
  13578. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  13579. /**
  13580. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13581. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13582. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13583. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13584. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13585. * @returns the emitter
  13586. */
  13587. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13588. }
  13589. }
  13590. declare module "babylonjs/Particles/subEmitter" {
  13591. import { Scene } from "babylonjs/scene";
  13592. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13593. /**
  13594. * Type of sub emitter
  13595. */
  13596. export enum SubEmitterType {
  13597. /**
  13598. * Attached to the particle over it's lifetime
  13599. */
  13600. ATTACHED = 0,
  13601. /**
  13602. * Created when the particle dies
  13603. */
  13604. END = 1
  13605. }
  13606. /**
  13607. * Sub emitter class used to emit particles from an existing particle
  13608. */
  13609. export class SubEmitter {
  13610. /**
  13611. * the particle system to be used by the sub emitter
  13612. */
  13613. particleSystem: ParticleSystem;
  13614. /**
  13615. * Type of the submitter (Default: END)
  13616. */
  13617. type: SubEmitterType;
  13618. /**
  13619. * 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)
  13620. * Note: This only is supported when using an emitter of type Mesh
  13621. */
  13622. inheritDirection: boolean;
  13623. /**
  13624. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  13625. */
  13626. inheritedVelocityAmount: number;
  13627. /**
  13628. * Creates a sub emitter
  13629. * @param particleSystem the particle system to be used by the sub emitter
  13630. */
  13631. constructor(
  13632. /**
  13633. * the particle system to be used by the sub emitter
  13634. */
  13635. particleSystem: ParticleSystem);
  13636. /**
  13637. * Clones the sub emitter
  13638. * @returns the cloned sub emitter
  13639. */
  13640. clone(): SubEmitter;
  13641. /**
  13642. * Serialize current object to a JSON object
  13643. * @returns the serialized object
  13644. */
  13645. serialize(): any;
  13646. /** @hidden */
  13647. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  13648. /**
  13649. * Creates a new SubEmitter from a serialized JSON version
  13650. * @param serializationObject defines the JSON object to read from
  13651. * @param scene defines the hosting scene
  13652. * @param rootUrl defines the rootUrl for data loading
  13653. * @returns a new SubEmitter
  13654. */
  13655. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  13656. /** Release associated resources */
  13657. dispose(): void;
  13658. }
  13659. }
  13660. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  13661. /** @hidden */
  13662. export var clipPlaneFragmentDeclaration: {
  13663. name: string;
  13664. shader: string;
  13665. };
  13666. }
  13667. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  13668. /** @hidden */
  13669. export var imageProcessingDeclaration: {
  13670. name: string;
  13671. shader: string;
  13672. };
  13673. }
  13674. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  13675. /** @hidden */
  13676. export var imageProcessingFunctions: {
  13677. name: string;
  13678. shader: string;
  13679. };
  13680. }
  13681. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  13682. /** @hidden */
  13683. export var clipPlaneFragment: {
  13684. name: string;
  13685. shader: string;
  13686. };
  13687. }
  13688. declare module "babylonjs/Shaders/particles.fragment" {
  13689. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  13690. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  13691. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  13692. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  13693. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  13694. /** @hidden */
  13695. export var particlesPixelShader: {
  13696. name: string;
  13697. shader: string;
  13698. };
  13699. }
  13700. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  13701. /** @hidden */
  13702. export var clipPlaneVertexDeclaration: {
  13703. name: string;
  13704. shader: string;
  13705. };
  13706. }
  13707. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  13708. /** @hidden */
  13709. export var clipPlaneVertex: {
  13710. name: string;
  13711. shader: string;
  13712. };
  13713. }
  13714. declare module "babylonjs/Shaders/particles.vertex" {
  13715. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  13716. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  13717. /** @hidden */
  13718. export var particlesVertexShader: {
  13719. name: string;
  13720. shader: string;
  13721. };
  13722. }
  13723. declare module "babylonjs/Particles/particleSystem" {
  13724. import { Nullable } from "babylonjs/types";
  13725. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  13726. import { Observable } from "babylonjs/Misc/observable";
  13727. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  13728. import { Effect } from "babylonjs/Materials/effect";
  13729. import { Scene, IDisposable } from "babylonjs/scene";
  13730. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  13731. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  13732. import { Particle } from "babylonjs/Particles/particle";
  13733. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13734. import "babylonjs/Shaders/particles.fragment";
  13735. import "babylonjs/Shaders/particles.vertex";
  13736. /**
  13737. * This represents a particle system in Babylon.
  13738. * 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.
  13739. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13740. * @example https://doc.babylonjs.com/babylon101/particles
  13741. */
  13742. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  13743. /**
  13744. * Billboard mode will only apply to Y axis
  13745. */
  13746. static readonly BILLBOARDMODE_Y: number;
  13747. /**
  13748. * Billboard mode will apply to all axes
  13749. */
  13750. static readonly BILLBOARDMODE_ALL: number;
  13751. /**
  13752. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  13753. */
  13754. static readonly BILLBOARDMODE_STRETCHED: number;
  13755. /**
  13756. * This function can be defined to provide custom update for active particles.
  13757. * This function will be called instead of regular update (age, position, color, etc.).
  13758. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  13759. */
  13760. updateFunction: (particles: Particle[]) => void;
  13761. private _emitterWorldMatrix;
  13762. /**
  13763. * This function can be defined to specify initial direction for every new particle.
  13764. * It by default use the emitterType defined function
  13765. */
  13766. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  13767. /**
  13768. * This function can be defined to specify initial position for every new particle.
  13769. * It by default use the emitterType defined function
  13770. */
  13771. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  13772. /**
  13773. * @hidden
  13774. */
  13775. _inheritedVelocityOffset: Vector3;
  13776. /**
  13777. * An event triggered when the system is disposed
  13778. */
  13779. onDisposeObservable: Observable<ParticleSystem>;
  13780. private _onDisposeObserver;
  13781. /**
  13782. * Sets a callback that will be triggered when the system is disposed
  13783. */
  13784. onDispose: () => void;
  13785. private _particles;
  13786. private _epsilon;
  13787. private _capacity;
  13788. private _stockParticles;
  13789. private _newPartsExcess;
  13790. private _vertexData;
  13791. private _vertexBuffer;
  13792. private _vertexBuffers;
  13793. private _spriteBuffer;
  13794. private _indexBuffer;
  13795. private _effect;
  13796. private _customEffect;
  13797. private _cachedDefines;
  13798. private _scaledColorStep;
  13799. private _colorDiff;
  13800. private _scaledDirection;
  13801. private _scaledGravity;
  13802. private _currentRenderId;
  13803. private _alive;
  13804. private _useInstancing;
  13805. private _started;
  13806. private _stopped;
  13807. private _actualFrame;
  13808. private _scaledUpdateSpeed;
  13809. private _vertexBufferSize;
  13810. /** @hidden */
  13811. _currentEmitRateGradient: Nullable<FactorGradient>;
  13812. /** @hidden */
  13813. _currentEmitRate1: number;
  13814. /** @hidden */
  13815. _currentEmitRate2: number;
  13816. /** @hidden */
  13817. _currentStartSizeGradient: Nullable<FactorGradient>;
  13818. /** @hidden */
  13819. _currentStartSize1: number;
  13820. /** @hidden */
  13821. _currentStartSize2: number;
  13822. private readonly _rawTextureWidth;
  13823. private _rampGradientsTexture;
  13824. private _useRampGradients;
  13825. /** Gets or sets a boolean indicating that ramp gradients must be used
  13826. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13827. */
  13828. useRampGradients: boolean;
  13829. /**
  13830. * 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.
  13831. * 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: [])
  13832. */
  13833. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13834. private _subEmitters;
  13835. /**
  13836. * @hidden
  13837. * If the particle systems emitter should be disposed when the particle system is disposed
  13838. */
  13839. _disposeEmitterOnDispose: boolean;
  13840. /**
  13841. * The current active Sub-systems, this property is used by the root particle system only.
  13842. */
  13843. activeSubSystems: Array<ParticleSystem>;
  13844. private _rootParticleSystem;
  13845. /**
  13846. * Gets the current list of active particles
  13847. */
  13848. readonly particles: Particle[];
  13849. /**
  13850. * Returns the string "ParticleSystem"
  13851. * @returns a string containing the class name
  13852. */
  13853. getClassName(): string;
  13854. /**
  13855. * Instantiates a particle system.
  13856. * 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.
  13857. * @param name The name of the particle system
  13858. * @param capacity The max number of particles alive at the same time
  13859. * @param scene The scene the particle system belongs to
  13860. * @param customEffect a custom effect used to change the way particles are rendered by default
  13861. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13862. * @param epsilon Offset used to render the particles
  13863. */
  13864. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13865. private _addFactorGradient;
  13866. private _removeFactorGradient;
  13867. /**
  13868. * Adds a new life time gradient
  13869. * @param gradient defines the gradient to use (between 0 and 1)
  13870. * @param factor defines the life time factor to affect to the specified gradient
  13871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13872. * @returns the current particle system
  13873. */
  13874. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13875. /**
  13876. * Remove a specific life time gradient
  13877. * @param gradient defines the gradient to remove
  13878. * @returns the current particle system
  13879. */
  13880. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13881. /**
  13882. * Adds a new size gradient
  13883. * @param gradient defines the gradient to use (between 0 and 1)
  13884. * @param factor defines the size factor to affect to the specified gradient
  13885. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13886. * @returns the current particle system
  13887. */
  13888. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13889. /**
  13890. * Remove a specific size gradient
  13891. * @param gradient defines the gradient to remove
  13892. * @returns the current particle system
  13893. */
  13894. removeSizeGradient(gradient: number): IParticleSystem;
  13895. /**
  13896. * Adds a new color remap gradient
  13897. * @param gradient defines the gradient to use (between 0 and 1)
  13898. * @param min defines the color remap minimal range
  13899. * @param max defines the color remap maximal range
  13900. * @returns the current particle system
  13901. */
  13902. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13903. /**
  13904. * Remove a specific color remap gradient
  13905. * @param gradient defines the gradient to remove
  13906. * @returns the current particle system
  13907. */
  13908. removeColorRemapGradient(gradient: number): IParticleSystem;
  13909. /**
  13910. * Adds a new alpha remap gradient
  13911. * @param gradient defines the gradient to use (between 0 and 1)
  13912. * @param min defines the alpha remap minimal range
  13913. * @param max defines the alpha remap maximal range
  13914. * @returns the current particle system
  13915. */
  13916. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13917. /**
  13918. * Remove a specific alpha remap gradient
  13919. * @param gradient defines the gradient to remove
  13920. * @returns the current particle system
  13921. */
  13922. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13923. /**
  13924. * Adds a new angular speed gradient
  13925. * @param gradient defines the gradient to use (between 0 and 1)
  13926. * @param factor defines the angular speed to affect to the specified gradient
  13927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13928. * @returns the current particle system
  13929. */
  13930. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13931. /**
  13932. * Remove a specific angular speed gradient
  13933. * @param gradient defines the gradient to remove
  13934. * @returns the current particle system
  13935. */
  13936. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13937. /**
  13938. * Adds a new velocity gradient
  13939. * @param gradient defines the gradient to use (between 0 and 1)
  13940. * @param factor defines the velocity to affect to the specified gradient
  13941. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13942. * @returns the current particle system
  13943. */
  13944. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13945. /**
  13946. * Remove a specific velocity gradient
  13947. * @param gradient defines the gradient to remove
  13948. * @returns the current particle system
  13949. */
  13950. removeVelocityGradient(gradient: number): IParticleSystem;
  13951. /**
  13952. * Adds a new limit velocity gradient
  13953. * @param gradient defines the gradient to use (between 0 and 1)
  13954. * @param factor defines the limit velocity value to affect to the specified gradient
  13955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13956. * @returns the current particle system
  13957. */
  13958. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13959. /**
  13960. * Remove a specific limit velocity gradient
  13961. * @param gradient defines the gradient to remove
  13962. * @returns the current particle system
  13963. */
  13964. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13965. /**
  13966. * Adds a new drag gradient
  13967. * @param gradient defines the gradient to use (between 0 and 1)
  13968. * @param factor defines the drag value to affect to the specified gradient
  13969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13970. * @returns the current particle system
  13971. */
  13972. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13973. /**
  13974. * Remove a specific drag gradient
  13975. * @param gradient defines the gradient to remove
  13976. * @returns the current particle system
  13977. */
  13978. removeDragGradient(gradient: number): IParticleSystem;
  13979. /**
  13980. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13981. * @param gradient defines the gradient to use (between 0 and 1)
  13982. * @param factor defines the emit rate value to affect to the specified gradient
  13983. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13984. * @returns the current particle system
  13985. */
  13986. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13987. /**
  13988. * Remove a specific emit rate gradient
  13989. * @param gradient defines the gradient to remove
  13990. * @returns the current particle system
  13991. */
  13992. removeEmitRateGradient(gradient: number): IParticleSystem;
  13993. /**
  13994. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13995. * @param gradient defines the gradient to use (between 0 and 1)
  13996. * @param factor defines the start size value to affect to the specified gradient
  13997. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13998. * @returns the current particle system
  13999. */
  14000. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14001. /**
  14002. * Remove a specific start size gradient
  14003. * @param gradient defines the gradient to remove
  14004. * @returns the current particle system
  14005. */
  14006. removeStartSizeGradient(gradient: number): IParticleSystem;
  14007. private _createRampGradientTexture;
  14008. /**
  14009. * Gets the current list of ramp gradients.
  14010. * You must use addRampGradient and removeRampGradient to udpate this list
  14011. * @returns the list of ramp gradients
  14012. */
  14013. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14014. /**
  14015. * Adds a new ramp gradient used to remap particle colors
  14016. * @param gradient defines the gradient to use (between 0 and 1)
  14017. * @param color defines the color to affect to the specified gradient
  14018. * @returns the current particle system
  14019. */
  14020. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14021. /**
  14022. * Remove a specific ramp gradient
  14023. * @param gradient defines the gradient to remove
  14024. * @returns the current particle system
  14025. */
  14026. removeRampGradient(gradient: number): ParticleSystem;
  14027. /**
  14028. * Adds a new color gradient
  14029. * @param gradient defines the gradient to use (between 0 and 1)
  14030. * @param color1 defines the color to affect to the specified gradient
  14031. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14032. * @returns this particle system
  14033. */
  14034. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14035. /**
  14036. * Remove a specific color gradient
  14037. * @param gradient defines the gradient to remove
  14038. * @returns this particle system
  14039. */
  14040. removeColorGradient(gradient: number): IParticleSystem;
  14041. private _fetchR;
  14042. protected _reset(): void;
  14043. private _resetEffect;
  14044. private _createVertexBuffers;
  14045. private _createIndexBuffer;
  14046. /**
  14047. * Gets the maximum number of particles active at the same time.
  14048. * @returns The max number of active particles.
  14049. */
  14050. getCapacity(): number;
  14051. /**
  14052. * Gets whether there are still active particles in the system.
  14053. * @returns True if it is alive, otherwise false.
  14054. */
  14055. isAlive(): boolean;
  14056. /**
  14057. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14058. * @returns True if it has been started, otherwise false.
  14059. */
  14060. isStarted(): boolean;
  14061. private _prepareSubEmitterInternalArray;
  14062. /**
  14063. * Starts the particle system and begins to emit
  14064. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14065. */
  14066. start(delay?: number): void;
  14067. /**
  14068. * Stops the particle system.
  14069. * @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.
  14070. */
  14071. stop(stopSubEmitters?: boolean): void;
  14072. /**
  14073. * Remove all active particles
  14074. */
  14075. reset(): void;
  14076. /**
  14077. * @hidden (for internal use only)
  14078. */
  14079. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14080. /**
  14081. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14082. * Its lifetime will start back at 0.
  14083. */
  14084. recycleParticle: (particle: Particle) => void;
  14085. private _stopSubEmitters;
  14086. private _createParticle;
  14087. private _removeFromRoot;
  14088. private _emitFromParticle;
  14089. private _update;
  14090. /** @hidden */
  14091. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14092. /** @hidden */
  14093. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14094. /** @hidden */
  14095. private _getEffect;
  14096. /**
  14097. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14098. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14099. */
  14100. animate(preWarmOnly?: boolean): void;
  14101. private _appendParticleVertices;
  14102. /**
  14103. * Rebuilds the particle system.
  14104. */
  14105. rebuild(): void;
  14106. /**
  14107. * Is this system ready to be used/rendered
  14108. * @return true if the system is ready
  14109. */
  14110. isReady(): boolean;
  14111. private _render;
  14112. /**
  14113. * Renders the particle system in its current state.
  14114. * @returns the current number of particles
  14115. */
  14116. render(): number;
  14117. /**
  14118. * Disposes the particle system and free the associated resources
  14119. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14120. */
  14121. dispose(disposeTexture?: boolean): void;
  14122. /**
  14123. * Clones the particle system.
  14124. * @param name The name of the cloned object
  14125. * @param newEmitter The new emitter to use
  14126. * @returns the cloned particle system
  14127. */
  14128. clone(name: string, newEmitter: any): ParticleSystem;
  14129. /**
  14130. * Serializes the particle system to a JSON object.
  14131. * @returns the JSON object
  14132. */
  14133. serialize(): any;
  14134. /** @hidden */
  14135. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14136. /** @hidden */
  14137. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14138. /**
  14139. * Parses a JSON object to create a particle system.
  14140. * @param parsedParticleSystem The JSON object to parse
  14141. * @param scene The scene to create the particle system in
  14142. * @param rootUrl The root url to use to load external dependencies like texture
  14143. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14144. * @returns the Parsed particle system
  14145. */
  14146. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14147. }
  14148. }
  14149. declare module "babylonjs/Particles/particle" {
  14150. import { Nullable } from "babylonjs/types";
  14151. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  14152. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14153. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  14154. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  14155. /**
  14156. * A particle represents one of the element emitted by a particle system.
  14157. * This is mainly define by its coordinates, direction, velocity and age.
  14158. */
  14159. export class Particle {
  14160. /**
  14161. * The particle system the particle belongs to.
  14162. */
  14163. particleSystem: ParticleSystem;
  14164. private static _Count;
  14165. /**
  14166. * Unique ID of the particle
  14167. */
  14168. id: number;
  14169. /**
  14170. * The world position of the particle in the scene.
  14171. */
  14172. position: Vector3;
  14173. /**
  14174. * The world direction of the particle in the scene.
  14175. */
  14176. direction: Vector3;
  14177. /**
  14178. * The color of the particle.
  14179. */
  14180. color: Color4;
  14181. /**
  14182. * The color change of the particle per step.
  14183. */
  14184. colorStep: Color4;
  14185. /**
  14186. * Defines how long will the life of the particle be.
  14187. */
  14188. lifeTime: number;
  14189. /**
  14190. * The current age of the particle.
  14191. */
  14192. age: number;
  14193. /**
  14194. * The current size of the particle.
  14195. */
  14196. size: number;
  14197. /**
  14198. * The current scale of the particle.
  14199. */
  14200. scale: Vector2;
  14201. /**
  14202. * The current angle of the particle.
  14203. */
  14204. angle: number;
  14205. /**
  14206. * Defines how fast is the angle changing.
  14207. */
  14208. angularSpeed: number;
  14209. /**
  14210. * Defines the cell index used by the particle to be rendered from a sprite.
  14211. */
  14212. cellIndex: number;
  14213. /**
  14214. * The information required to support color remapping
  14215. */
  14216. remapData: Vector4;
  14217. /** @hidden */
  14218. _randomCellOffset?: number;
  14219. /** @hidden */
  14220. _initialDirection: Nullable<Vector3>;
  14221. /** @hidden */
  14222. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14223. /** @hidden */
  14224. _initialStartSpriteCellID: number;
  14225. /** @hidden */
  14226. _initialEndSpriteCellID: number;
  14227. /** @hidden */
  14228. _currentColorGradient: Nullable<ColorGradient>;
  14229. /** @hidden */
  14230. _currentColor1: Color4;
  14231. /** @hidden */
  14232. _currentColor2: Color4;
  14233. /** @hidden */
  14234. _currentSizeGradient: Nullable<FactorGradient>;
  14235. /** @hidden */
  14236. _currentSize1: number;
  14237. /** @hidden */
  14238. _currentSize2: number;
  14239. /** @hidden */
  14240. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  14241. /** @hidden */
  14242. _currentAngularSpeed1: number;
  14243. /** @hidden */
  14244. _currentAngularSpeed2: number;
  14245. /** @hidden */
  14246. _currentVelocityGradient: Nullable<FactorGradient>;
  14247. /** @hidden */
  14248. _currentVelocity1: number;
  14249. /** @hidden */
  14250. _currentVelocity2: number;
  14251. /** @hidden */
  14252. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  14253. /** @hidden */
  14254. _currentLimitVelocity1: number;
  14255. /** @hidden */
  14256. _currentLimitVelocity2: number;
  14257. /** @hidden */
  14258. _currentDragGradient: Nullable<FactorGradient>;
  14259. /** @hidden */
  14260. _currentDrag1: number;
  14261. /** @hidden */
  14262. _currentDrag2: number;
  14263. /** @hidden */
  14264. _randomNoiseCoordinates1: Vector3;
  14265. /** @hidden */
  14266. _randomNoiseCoordinates2: Vector3;
  14267. /**
  14268. * Creates a new instance Particle
  14269. * @param particleSystem the particle system the particle belongs to
  14270. */
  14271. constructor(
  14272. /**
  14273. * The particle system the particle belongs to.
  14274. */
  14275. particleSystem: ParticleSystem);
  14276. private updateCellInfoFromSystem;
  14277. /**
  14278. * Defines how the sprite cell index is updated for the particle
  14279. */
  14280. updateCellIndex(): void;
  14281. /** @hidden */
  14282. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14283. /** @hidden */
  14284. _inheritParticleInfoToSubEmitters(): void;
  14285. /** @hidden */
  14286. _reset(): void;
  14287. /**
  14288. * Copy the properties of particle to another one.
  14289. * @param other the particle to copy the information to.
  14290. */
  14291. copyTo(other: Particle): void;
  14292. }
  14293. }
  14294. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  14295. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14296. import { Effect } from "babylonjs/Materials/effect";
  14297. import { Particle } from "babylonjs/Particles/particle";
  14298. /**
  14299. * Particle emitter represents a volume emitting particles.
  14300. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14301. */
  14302. export interface IParticleEmitterType {
  14303. /**
  14304. * Called by the particle System when the direction is computed for the created particle.
  14305. * @param worldMatrix is the world matrix of the particle system
  14306. * @param directionToUpdate is the direction vector to update with the result
  14307. * @param particle is the particle we are computed the direction for
  14308. */
  14309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14310. /**
  14311. * Called by the particle System when the position is computed for the created particle.
  14312. * @param worldMatrix is the world matrix of the particle system
  14313. * @param positionToUpdate is the position vector to update with the result
  14314. * @param particle is the particle we are computed the position for
  14315. */
  14316. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14317. /**
  14318. * Clones the current emitter and returns a copy of it
  14319. * @returns the new emitter
  14320. */
  14321. clone(): IParticleEmitterType;
  14322. /**
  14323. * Called by the GPUParticleSystem to setup the update shader
  14324. * @param effect defines the update shader
  14325. */
  14326. applyToShader(effect: Effect): void;
  14327. /**
  14328. * Returns a string to use to update the GPU particles update shader
  14329. * @returns the effect defines string
  14330. */
  14331. getEffectDefines(): string;
  14332. /**
  14333. * Returns a string representing the class name
  14334. * @returns a string containing the class name
  14335. */
  14336. getClassName(): string;
  14337. /**
  14338. * Serializes the particle system to a JSON object.
  14339. * @returns the JSON object
  14340. */
  14341. serialize(): any;
  14342. /**
  14343. * Parse properties from a JSON object
  14344. * @param serializationObject defines the JSON object
  14345. */
  14346. parse(serializationObject: any): void;
  14347. }
  14348. }
  14349. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  14350. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14351. import { Effect } from "babylonjs/Materials/effect";
  14352. import { Particle } from "babylonjs/Particles/particle";
  14353. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14354. /**
  14355. * Particle emitter emitting particles from the inside of a box.
  14356. * It emits the particles randomly between 2 given directions.
  14357. */
  14358. export class BoxParticleEmitter implements IParticleEmitterType {
  14359. /**
  14360. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14361. */
  14362. direction1: Vector3;
  14363. /**
  14364. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14365. */
  14366. direction2: Vector3;
  14367. /**
  14368. * 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.
  14369. */
  14370. minEmitBox: Vector3;
  14371. /**
  14372. * 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.
  14373. */
  14374. maxEmitBox: Vector3;
  14375. /**
  14376. * Creates a new instance BoxParticleEmitter
  14377. */
  14378. constructor();
  14379. /**
  14380. * Called by the particle System when the direction is computed for the created particle.
  14381. * @param worldMatrix is the world matrix of the particle system
  14382. * @param directionToUpdate is the direction vector to update with the result
  14383. * @param particle is the particle we are computed the direction for
  14384. */
  14385. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14386. /**
  14387. * Called by the particle System when the position is computed for the created particle.
  14388. * @param worldMatrix is the world matrix of the particle system
  14389. * @param positionToUpdate is the position vector to update with the result
  14390. * @param particle is the particle we are computed the position for
  14391. */
  14392. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14393. /**
  14394. * Clones the current emitter and returns a copy of it
  14395. * @returns the new emitter
  14396. */
  14397. clone(): BoxParticleEmitter;
  14398. /**
  14399. * Called by the GPUParticleSystem to setup the update shader
  14400. * @param effect defines the update shader
  14401. */
  14402. applyToShader(effect: Effect): void;
  14403. /**
  14404. * Returns a string to use to update the GPU particles update shader
  14405. * @returns a string containng the defines string
  14406. */
  14407. getEffectDefines(): string;
  14408. /**
  14409. * Returns the string "BoxParticleEmitter"
  14410. * @returns a string containing the class name
  14411. */
  14412. getClassName(): string;
  14413. /**
  14414. * Serializes the particle system to a JSON object.
  14415. * @returns the JSON object
  14416. */
  14417. serialize(): any;
  14418. /**
  14419. * Parse properties from a JSON object
  14420. * @param serializationObject defines the JSON object
  14421. */
  14422. parse(serializationObject: any): void;
  14423. }
  14424. }
  14425. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  14426. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14427. import { Effect } from "babylonjs/Materials/effect";
  14428. import { Particle } from "babylonjs/Particles/particle";
  14429. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14430. /**
  14431. * Particle emitter emitting particles from the inside of a cone.
  14432. * It emits the particles alongside the cone volume from the base to the particle.
  14433. * The emission direction might be randomized.
  14434. */
  14435. export class ConeParticleEmitter implements IParticleEmitterType {
  14436. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14437. directionRandomizer: number;
  14438. private _radius;
  14439. private _angle;
  14440. private _height;
  14441. /**
  14442. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  14443. */
  14444. radiusRange: number;
  14445. /**
  14446. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  14447. */
  14448. heightRange: number;
  14449. /**
  14450. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  14451. */
  14452. emitFromSpawnPointOnly: boolean;
  14453. /**
  14454. * Gets or sets the radius of the emission cone
  14455. */
  14456. radius: number;
  14457. /**
  14458. * Gets or sets the angle of the emission cone
  14459. */
  14460. angle: number;
  14461. private _buildHeight;
  14462. /**
  14463. * Creates a new instance ConeParticleEmitter
  14464. * @param radius the radius of the emission cone (1 by default)
  14465. * @param angle the cone base angle (PI by default)
  14466. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  14467. */
  14468. constructor(radius?: number, angle?: number,
  14469. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  14470. directionRandomizer?: number);
  14471. /**
  14472. * Called by the particle System when the direction is computed for the created particle.
  14473. * @param worldMatrix is the world matrix of the particle system
  14474. * @param directionToUpdate is the direction vector to update with the result
  14475. * @param particle is the particle we are computed the direction for
  14476. */
  14477. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14478. /**
  14479. * Called by the particle System when the position is computed for the created particle.
  14480. * @param worldMatrix is the world matrix of the particle system
  14481. * @param positionToUpdate is the position vector to update with the result
  14482. * @param particle is the particle we are computed the position for
  14483. */
  14484. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14485. /**
  14486. * Clones the current emitter and returns a copy of it
  14487. * @returns the new emitter
  14488. */
  14489. clone(): ConeParticleEmitter;
  14490. /**
  14491. * Called by the GPUParticleSystem to setup the update shader
  14492. * @param effect defines the update shader
  14493. */
  14494. applyToShader(effect: Effect): void;
  14495. /**
  14496. * Returns a string to use to update the GPU particles update shader
  14497. * @returns a string containng the defines string
  14498. */
  14499. getEffectDefines(): string;
  14500. /**
  14501. * Returns the string "ConeParticleEmitter"
  14502. * @returns a string containing the class name
  14503. */
  14504. getClassName(): string;
  14505. /**
  14506. * Serializes the particle system to a JSON object.
  14507. * @returns the JSON object
  14508. */
  14509. serialize(): any;
  14510. /**
  14511. * Parse properties from a JSON object
  14512. * @param serializationObject defines the JSON object
  14513. */
  14514. parse(serializationObject: any): void;
  14515. }
  14516. }
  14517. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  14518. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14519. import { Effect } from "babylonjs/Materials/effect";
  14520. import { Particle } from "babylonjs/Particles/particle";
  14521. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14522. /**
  14523. * Particle emitter emitting particles from the inside of a cylinder.
  14524. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  14525. */
  14526. export class CylinderParticleEmitter implements IParticleEmitterType {
  14527. /**
  14528. * The radius of the emission cylinder.
  14529. */
  14530. radius: number;
  14531. /**
  14532. * The height of the emission cylinder.
  14533. */
  14534. height: number;
  14535. /**
  14536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14537. */
  14538. radiusRange: number;
  14539. /**
  14540. * How much to randomize the particle direction [0-1].
  14541. */
  14542. directionRandomizer: number;
  14543. /**
  14544. * Creates a new instance CylinderParticleEmitter
  14545. * @param radius the radius of the emission cylinder (1 by default)
  14546. * @param height the height of the emission cylinder (1 by default)
  14547. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14548. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14549. */
  14550. constructor(
  14551. /**
  14552. * The radius of the emission cylinder.
  14553. */
  14554. radius?: number,
  14555. /**
  14556. * The height of the emission cylinder.
  14557. */
  14558. height?: number,
  14559. /**
  14560. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14561. */
  14562. radiusRange?: number,
  14563. /**
  14564. * How much to randomize the particle direction [0-1].
  14565. */
  14566. directionRandomizer?: number);
  14567. /**
  14568. * Called by the particle System when the direction is computed for the created particle.
  14569. * @param worldMatrix is the world matrix of the particle system
  14570. * @param directionToUpdate is the direction vector to update with the result
  14571. * @param particle is the particle we are computed the direction for
  14572. */
  14573. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14574. /**
  14575. * Called by the particle System when the position is computed for the created particle.
  14576. * @param worldMatrix is the world matrix of the particle system
  14577. * @param positionToUpdate is the position vector to update with the result
  14578. * @param particle is the particle we are computed the position for
  14579. */
  14580. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14581. /**
  14582. * Clones the current emitter and returns a copy of it
  14583. * @returns the new emitter
  14584. */
  14585. clone(): CylinderParticleEmitter;
  14586. /**
  14587. * Called by the GPUParticleSystem to setup the update shader
  14588. * @param effect defines the update shader
  14589. */
  14590. applyToShader(effect: Effect): void;
  14591. /**
  14592. * Returns a string to use to update the GPU particles update shader
  14593. * @returns a string containng the defines string
  14594. */
  14595. getEffectDefines(): string;
  14596. /**
  14597. * Returns the string "CylinderParticleEmitter"
  14598. * @returns a string containing the class name
  14599. */
  14600. getClassName(): string;
  14601. /**
  14602. * Serializes the particle system to a JSON object.
  14603. * @returns the JSON object
  14604. */
  14605. serialize(): any;
  14606. /**
  14607. * Parse properties from a JSON object
  14608. * @param serializationObject defines the JSON object
  14609. */
  14610. parse(serializationObject: any): void;
  14611. }
  14612. /**
  14613. * Particle emitter emitting particles from the inside of a cylinder.
  14614. * It emits the particles randomly between two vectors.
  14615. */
  14616. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  14617. /**
  14618. * The min limit of the emission direction.
  14619. */
  14620. direction1: Vector3;
  14621. /**
  14622. * The max limit of the emission direction.
  14623. */
  14624. direction2: Vector3;
  14625. /**
  14626. * Creates a new instance CylinderDirectedParticleEmitter
  14627. * @param radius the radius of the emission cylinder (1 by default)
  14628. * @param height the height of the emission cylinder (1 by default)
  14629. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14630. * @param direction1 the min limit of the emission direction (up vector by default)
  14631. * @param direction2 the max limit of the emission direction (up vector by default)
  14632. */
  14633. constructor(radius?: number, height?: number, radiusRange?: number,
  14634. /**
  14635. * The min limit of the emission direction.
  14636. */
  14637. direction1?: Vector3,
  14638. /**
  14639. * The max limit of the emission direction.
  14640. */
  14641. direction2?: Vector3);
  14642. /**
  14643. * Called by the particle System when the direction is computed for the created particle.
  14644. * @param worldMatrix is the world matrix of the particle system
  14645. * @param directionToUpdate is the direction vector to update with the result
  14646. * @param particle is the particle we are computed the direction for
  14647. */
  14648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14649. /**
  14650. * Clones the current emitter and returns a copy of it
  14651. * @returns the new emitter
  14652. */
  14653. clone(): CylinderDirectedParticleEmitter;
  14654. /**
  14655. * Called by the GPUParticleSystem to setup the update shader
  14656. * @param effect defines the update shader
  14657. */
  14658. applyToShader(effect: Effect): void;
  14659. /**
  14660. * Returns a string to use to update the GPU particles update shader
  14661. * @returns a string containng the defines string
  14662. */
  14663. getEffectDefines(): string;
  14664. /**
  14665. * Returns the string "CylinderDirectedParticleEmitter"
  14666. * @returns a string containing the class name
  14667. */
  14668. getClassName(): string;
  14669. /**
  14670. * Serializes the particle system to a JSON object.
  14671. * @returns the JSON object
  14672. */
  14673. serialize(): any;
  14674. /**
  14675. * Parse properties from a JSON object
  14676. * @param serializationObject defines the JSON object
  14677. */
  14678. parse(serializationObject: any): void;
  14679. }
  14680. }
  14681. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  14682. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14683. import { Effect } from "babylonjs/Materials/effect";
  14684. import { Particle } from "babylonjs/Particles/particle";
  14685. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14686. /**
  14687. * Particle emitter emitting particles from the inside of a hemisphere.
  14688. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  14689. */
  14690. export class HemisphericParticleEmitter implements IParticleEmitterType {
  14691. /**
  14692. * The radius of the emission hemisphere.
  14693. */
  14694. radius: number;
  14695. /**
  14696. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14697. */
  14698. radiusRange: number;
  14699. /**
  14700. * How much to randomize the particle direction [0-1].
  14701. */
  14702. directionRandomizer: number;
  14703. /**
  14704. * Creates a new instance HemisphericParticleEmitter
  14705. * @param radius the radius of the emission hemisphere (1 by default)
  14706. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14707. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14708. */
  14709. constructor(
  14710. /**
  14711. * The radius of the emission hemisphere.
  14712. */
  14713. radius?: number,
  14714. /**
  14715. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14716. */
  14717. radiusRange?: number,
  14718. /**
  14719. * How much to randomize the particle direction [0-1].
  14720. */
  14721. directionRandomizer?: number);
  14722. /**
  14723. * Called by the particle System when the direction is computed for the created particle.
  14724. * @param worldMatrix is the world matrix of the particle system
  14725. * @param directionToUpdate is the direction vector to update with the result
  14726. * @param particle is the particle we are computed the direction for
  14727. */
  14728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14729. /**
  14730. * Called by the particle System when the position is computed for the created particle.
  14731. * @param worldMatrix is the world matrix of the particle system
  14732. * @param positionToUpdate is the position vector to update with the result
  14733. * @param particle is the particle we are computed the position for
  14734. */
  14735. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14736. /**
  14737. * Clones the current emitter and returns a copy of it
  14738. * @returns the new emitter
  14739. */
  14740. clone(): HemisphericParticleEmitter;
  14741. /**
  14742. * Called by the GPUParticleSystem to setup the update shader
  14743. * @param effect defines the update shader
  14744. */
  14745. applyToShader(effect: Effect): void;
  14746. /**
  14747. * Returns a string to use to update the GPU particles update shader
  14748. * @returns a string containng the defines string
  14749. */
  14750. getEffectDefines(): string;
  14751. /**
  14752. * Returns the string "HemisphericParticleEmitter"
  14753. * @returns a string containing the class name
  14754. */
  14755. getClassName(): string;
  14756. /**
  14757. * Serializes the particle system to a JSON object.
  14758. * @returns the JSON object
  14759. */
  14760. serialize(): any;
  14761. /**
  14762. * Parse properties from a JSON object
  14763. * @param serializationObject defines the JSON object
  14764. */
  14765. parse(serializationObject: any): void;
  14766. }
  14767. }
  14768. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14769. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14770. import { Effect } from "babylonjs/Materials/effect";
  14771. import { Particle } from "babylonjs/Particles/particle";
  14772. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14773. /**
  14774. * Particle emitter emitting particles from a point.
  14775. * It emits the particles randomly between 2 given directions.
  14776. */
  14777. export class PointParticleEmitter implements IParticleEmitterType {
  14778. /**
  14779. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14780. */
  14781. direction1: Vector3;
  14782. /**
  14783. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14784. */
  14785. direction2: Vector3;
  14786. /**
  14787. * Creates a new instance PointParticleEmitter
  14788. */
  14789. constructor();
  14790. /**
  14791. * Called by the particle System when the direction is computed for the created particle.
  14792. * @param worldMatrix is the world matrix of the particle system
  14793. * @param directionToUpdate is the direction vector to update with the result
  14794. * @param particle is the particle we are computed the direction for
  14795. */
  14796. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14797. /**
  14798. * Called by the particle System when the position is computed for the created particle.
  14799. * @param worldMatrix is the world matrix of the particle system
  14800. * @param positionToUpdate is the position vector to update with the result
  14801. * @param particle is the particle we are computed the position for
  14802. */
  14803. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14804. /**
  14805. * Clones the current emitter and returns a copy of it
  14806. * @returns the new emitter
  14807. */
  14808. clone(): PointParticleEmitter;
  14809. /**
  14810. * Called by the GPUParticleSystem to setup the update shader
  14811. * @param effect defines the update shader
  14812. */
  14813. applyToShader(effect: Effect): void;
  14814. /**
  14815. * Returns a string to use to update the GPU particles update shader
  14816. * @returns a string containng the defines string
  14817. */
  14818. getEffectDefines(): string;
  14819. /**
  14820. * Returns the string "PointParticleEmitter"
  14821. * @returns a string containing the class name
  14822. */
  14823. getClassName(): string;
  14824. /**
  14825. * Serializes the particle system to a JSON object.
  14826. * @returns the JSON object
  14827. */
  14828. serialize(): any;
  14829. /**
  14830. * Parse properties from a JSON object
  14831. * @param serializationObject defines the JSON object
  14832. */
  14833. parse(serializationObject: any): void;
  14834. }
  14835. }
  14836. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14837. import { Vector3, Matrix } from "babylonjs/Maths/math";
  14838. import { Effect } from "babylonjs/Materials/effect";
  14839. import { Particle } from "babylonjs/Particles/particle";
  14840. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14841. /**
  14842. * Particle emitter emitting particles from the inside of a sphere.
  14843. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14844. */
  14845. export class SphereParticleEmitter implements IParticleEmitterType {
  14846. /**
  14847. * The radius of the emission sphere.
  14848. */
  14849. radius: number;
  14850. /**
  14851. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14852. */
  14853. radiusRange: number;
  14854. /**
  14855. * How much to randomize the particle direction [0-1].
  14856. */
  14857. directionRandomizer: number;
  14858. /**
  14859. * Creates a new instance SphereParticleEmitter
  14860. * @param radius the radius of the emission sphere (1 by default)
  14861. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14862. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14863. */
  14864. constructor(
  14865. /**
  14866. * The radius of the emission sphere.
  14867. */
  14868. radius?: number,
  14869. /**
  14870. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14871. */
  14872. radiusRange?: number,
  14873. /**
  14874. * How much to randomize the particle direction [0-1].
  14875. */
  14876. directionRandomizer?: number);
  14877. /**
  14878. * Called by the particle System when the direction is computed for the created particle.
  14879. * @param worldMatrix is the world matrix of the particle system
  14880. * @param directionToUpdate is the direction vector to update with the result
  14881. * @param particle is the particle we are computed the direction for
  14882. */
  14883. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14884. /**
  14885. * Called by the particle System when the position is computed for the created particle.
  14886. * @param worldMatrix is the world matrix of the particle system
  14887. * @param positionToUpdate is the position vector to update with the result
  14888. * @param particle is the particle we are computed the position for
  14889. */
  14890. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14891. /**
  14892. * Clones the current emitter and returns a copy of it
  14893. * @returns the new emitter
  14894. */
  14895. clone(): SphereParticleEmitter;
  14896. /**
  14897. * Called by the GPUParticleSystem to setup the update shader
  14898. * @param effect defines the update shader
  14899. */
  14900. applyToShader(effect: Effect): void;
  14901. /**
  14902. * Returns a string to use to update the GPU particles update shader
  14903. * @returns a string containng the defines string
  14904. */
  14905. getEffectDefines(): string;
  14906. /**
  14907. * Returns the string "SphereParticleEmitter"
  14908. * @returns a string containing the class name
  14909. */
  14910. getClassName(): string;
  14911. /**
  14912. * Serializes the particle system to a JSON object.
  14913. * @returns the JSON object
  14914. */
  14915. serialize(): any;
  14916. /**
  14917. * Parse properties from a JSON object
  14918. * @param serializationObject defines the JSON object
  14919. */
  14920. parse(serializationObject: any): void;
  14921. }
  14922. /**
  14923. * Particle emitter emitting particles from the inside of a sphere.
  14924. * It emits the particles randomly between two vectors.
  14925. */
  14926. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14927. /**
  14928. * The min limit of the emission direction.
  14929. */
  14930. direction1: Vector3;
  14931. /**
  14932. * The max limit of the emission direction.
  14933. */
  14934. direction2: Vector3;
  14935. /**
  14936. * Creates a new instance SphereDirectedParticleEmitter
  14937. * @param radius the radius of the emission sphere (1 by default)
  14938. * @param direction1 the min limit of the emission direction (up vector by default)
  14939. * @param direction2 the max limit of the emission direction (up vector by default)
  14940. */
  14941. constructor(radius?: number,
  14942. /**
  14943. * The min limit of the emission direction.
  14944. */
  14945. direction1?: Vector3,
  14946. /**
  14947. * The max limit of the emission direction.
  14948. */
  14949. direction2?: Vector3);
  14950. /**
  14951. * Called by the particle System when the direction is computed for the created particle.
  14952. * @param worldMatrix is the world matrix of the particle system
  14953. * @param directionToUpdate is the direction vector to update with the result
  14954. * @param particle is the particle we are computed the direction for
  14955. */
  14956. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14957. /**
  14958. * Clones the current emitter and returns a copy of it
  14959. * @returns the new emitter
  14960. */
  14961. clone(): SphereDirectedParticleEmitter;
  14962. /**
  14963. * Called by the GPUParticleSystem to setup the update shader
  14964. * @param effect defines the update shader
  14965. */
  14966. applyToShader(effect: Effect): void;
  14967. /**
  14968. * Returns a string to use to update the GPU particles update shader
  14969. * @returns a string containng the defines string
  14970. */
  14971. getEffectDefines(): string;
  14972. /**
  14973. * Returns the string "SphereDirectedParticleEmitter"
  14974. * @returns a string containing the class name
  14975. */
  14976. getClassName(): string;
  14977. /**
  14978. * Serializes the particle system to a JSON object.
  14979. * @returns the JSON object
  14980. */
  14981. serialize(): any;
  14982. /**
  14983. * Parse properties from a JSON object
  14984. * @param serializationObject defines the JSON object
  14985. */
  14986. parse(serializationObject: any): void;
  14987. }
  14988. }
  14989. declare module "babylonjs/Particles/EmitterTypes/index" {
  14990. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14991. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14992. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14993. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14994. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14995. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14996. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14997. }
  14998. declare module "babylonjs/Particles/IParticleSystem" {
  14999. import { Nullable } from "babylonjs/types";
  15000. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  15001. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15002. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15003. import { Texture } from "babylonjs/Materials/Textures/texture";
  15004. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  15005. import { Scene } from "babylonjs/scene";
  15006. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15007. import { Animation } from "babylonjs/Animations/animation";
  15008. /**
  15009. * Interface representing a particle system in Babylon.js.
  15010. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15011. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15012. */
  15013. export interface IParticleSystem {
  15014. /**
  15015. * List of animations used by the particle system.
  15016. */
  15017. animations: Animation[];
  15018. /**
  15019. * The id of the Particle system.
  15020. */
  15021. id: string;
  15022. /**
  15023. * The name of the Particle system.
  15024. */
  15025. name: string;
  15026. /**
  15027. * The emitter represents the Mesh or position we are attaching the particle system to.
  15028. */
  15029. emitter: Nullable<AbstractMesh | Vector3>;
  15030. /**
  15031. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15032. */
  15033. isBillboardBased: boolean;
  15034. /**
  15035. * The rendering group used by the Particle system to chose when to render.
  15036. */
  15037. renderingGroupId: number;
  15038. /**
  15039. * The layer mask we are rendering the particles through.
  15040. */
  15041. layerMask: number;
  15042. /**
  15043. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15044. */
  15045. updateSpeed: number;
  15046. /**
  15047. * The amount of time the particle system is running (depends of the overall update speed).
  15048. */
  15049. targetStopDuration: number;
  15050. /**
  15051. * The texture used to render each particle. (this can be a spritesheet)
  15052. */
  15053. particleTexture: Nullable<Texture>;
  15054. /**
  15055. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15056. */
  15057. blendMode: number;
  15058. /**
  15059. * Minimum life time of emitting particles.
  15060. */
  15061. minLifeTime: number;
  15062. /**
  15063. * Maximum life time of emitting particles.
  15064. */
  15065. maxLifeTime: number;
  15066. /**
  15067. * Minimum Size of emitting particles.
  15068. */
  15069. minSize: number;
  15070. /**
  15071. * Maximum Size of emitting particles.
  15072. */
  15073. maxSize: number;
  15074. /**
  15075. * Minimum scale of emitting particles on X axis.
  15076. */
  15077. minScaleX: number;
  15078. /**
  15079. * Maximum scale of emitting particles on X axis.
  15080. */
  15081. maxScaleX: number;
  15082. /**
  15083. * Minimum scale of emitting particles on Y axis.
  15084. */
  15085. minScaleY: number;
  15086. /**
  15087. * Maximum scale of emitting particles on Y axis.
  15088. */
  15089. maxScaleY: number;
  15090. /**
  15091. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15092. */
  15093. color1: Color4;
  15094. /**
  15095. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15096. */
  15097. color2: Color4;
  15098. /**
  15099. * Color the particle will have at the end of its lifetime.
  15100. */
  15101. colorDead: Color4;
  15102. /**
  15103. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15104. */
  15105. emitRate: number;
  15106. /**
  15107. * You can use gravity if you want to give an orientation to your particles.
  15108. */
  15109. gravity: Vector3;
  15110. /**
  15111. * Minimum power of emitting particles.
  15112. */
  15113. minEmitPower: number;
  15114. /**
  15115. * Maximum power of emitting particles.
  15116. */
  15117. maxEmitPower: number;
  15118. /**
  15119. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15120. */
  15121. minAngularSpeed: number;
  15122. /**
  15123. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15124. */
  15125. maxAngularSpeed: number;
  15126. /**
  15127. * Gets or sets the minimal initial rotation in radians.
  15128. */
  15129. minInitialRotation: number;
  15130. /**
  15131. * Gets or sets the maximal initial rotation in radians.
  15132. */
  15133. maxInitialRotation: number;
  15134. /**
  15135. * The particle emitter type defines the emitter used by the particle system.
  15136. * It can be for example box, sphere, or cone...
  15137. */
  15138. particleEmitterType: Nullable<IParticleEmitterType>;
  15139. /**
  15140. * Defines the delay in milliseconds before starting the system (0 by default)
  15141. */
  15142. startDelay: number;
  15143. /**
  15144. * 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
  15145. */
  15146. preWarmCycles: number;
  15147. /**
  15148. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15149. */
  15150. preWarmStepOffset: number;
  15151. /**
  15152. * 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)
  15153. */
  15154. spriteCellChangeSpeed: number;
  15155. /**
  15156. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15157. */
  15158. startSpriteCellID: number;
  15159. /**
  15160. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15161. */
  15162. endSpriteCellID: number;
  15163. /**
  15164. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15165. */
  15166. spriteCellWidth: number;
  15167. /**
  15168. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15169. */
  15170. spriteCellHeight: number;
  15171. /**
  15172. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15173. */
  15174. spriteRandomStartCell: boolean;
  15175. /**
  15176. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15177. */
  15178. isAnimationSheetEnabled: boolean;
  15179. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15180. translationPivot: Vector2;
  15181. /**
  15182. * Gets or sets a texture used to add random noise to particle positions
  15183. */
  15184. noiseTexture: Nullable<BaseTexture>;
  15185. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15186. noiseStrength: Vector3;
  15187. /**
  15188. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15189. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15190. */
  15191. billboardMode: number;
  15192. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15193. limitVelocityDamping: number;
  15194. /**
  15195. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15196. */
  15197. beginAnimationOnStart: boolean;
  15198. /**
  15199. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15200. */
  15201. beginAnimationFrom: number;
  15202. /**
  15203. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15204. */
  15205. beginAnimationTo: number;
  15206. /**
  15207. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15208. */
  15209. beginAnimationLoop: boolean;
  15210. /**
  15211. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15212. */
  15213. disposeOnStop: boolean;
  15214. /**
  15215. * Gets the maximum number of particles active at the same time.
  15216. * @returns The max number of active particles.
  15217. */
  15218. getCapacity(): number;
  15219. /**
  15220. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15221. * @returns True if it has been started, otherwise false.
  15222. */
  15223. isStarted(): boolean;
  15224. /**
  15225. * Animates the particle system for this frame.
  15226. */
  15227. animate(): void;
  15228. /**
  15229. * Renders the particle system in its current state.
  15230. * @returns the current number of particles
  15231. */
  15232. render(): number;
  15233. /**
  15234. * Dispose the particle system and frees its associated resources.
  15235. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15236. */
  15237. dispose(disposeTexture?: boolean): void;
  15238. /**
  15239. * Clones the particle system.
  15240. * @param name The name of the cloned object
  15241. * @param newEmitter The new emitter to use
  15242. * @returns the cloned particle system
  15243. */
  15244. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15245. /**
  15246. * Serializes the particle system to a JSON object.
  15247. * @returns the JSON object
  15248. */
  15249. serialize(): any;
  15250. /**
  15251. * Rebuild the particle system
  15252. */
  15253. rebuild(): void;
  15254. /**
  15255. * Starts the particle system and begins to emit
  15256. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15257. */
  15258. start(delay?: number): void;
  15259. /**
  15260. * Stops the particle system.
  15261. */
  15262. stop(): void;
  15263. /**
  15264. * Remove all active particles
  15265. */
  15266. reset(): void;
  15267. /**
  15268. * Is this system ready to be used/rendered
  15269. * @return true if the system is ready
  15270. */
  15271. isReady(): boolean;
  15272. /**
  15273. * Adds a new color gradient
  15274. * @param gradient defines the gradient to use (between 0 and 1)
  15275. * @param color1 defines the color to affect to the specified gradient
  15276. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15277. * @returns the current particle system
  15278. */
  15279. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15280. /**
  15281. * Remove a specific color gradient
  15282. * @param gradient defines the gradient to remove
  15283. * @returns the current particle system
  15284. */
  15285. removeColorGradient(gradient: number): IParticleSystem;
  15286. /**
  15287. * Adds a new size gradient
  15288. * @param gradient defines the gradient to use (between 0 and 1)
  15289. * @param factor defines the size factor to affect to the specified gradient
  15290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15291. * @returns the current particle system
  15292. */
  15293. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15294. /**
  15295. * Remove a specific size gradient
  15296. * @param gradient defines the gradient to remove
  15297. * @returns the current particle system
  15298. */
  15299. removeSizeGradient(gradient: number): IParticleSystem;
  15300. /**
  15301. * Gets the current list of color gradients.
  15302. * You must use addColorGradient and removeColorGradient to udpate this list
  15303. * @returns the list of color gradients
  15304. */
  15305. getColorGradients(): Nullable<Array<ColorGradient>>;
  15306. /**
  15307. * Gets the current list of size gradients.
  15308. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15309. * @returns the list of size gradients
  15310. */
  15311. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15312. /**
  15313. * Gets the current list of angular speed gradients.
  15314. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15315. * @returns the list of angular speed gradients
  15316. */
  15317. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15318. /**
  15319. * Adds a new angular speed gradient
  15320. * @param gradient defines the gradient to use (between 0 and 1)
  15321. * @param factor defines the angular speed to affect to the specified gradient
  15322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15323. * @returns the current particle system
  15324. */
  15325. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15326. /**
  15327. * Remove a specific angular speed gradient
  15328. * @param gradient defines the gradient to remove
  15329. * @returns the current particle system
  15330. */
  15331. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15332. /**
  15333. * Gets the current list of velocity gradients.
  15334. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15335. * @returns the list of velocity gradients
  15336. */
  15337. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15338. /**
  15339. * Adds a new velocity gradient
  15340. * @param gradient defines the gradient to use (between 0 and 1)
  15341. * @param factor defines the velocity to affect to the specified gradient
  15342. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15343. * @returns the current particle system
  15344. */
  15345. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15346. /**
  15347. * Remove a specific velocity gradient
  15348. * @param gradient defines the gradient to remove
  15349. * @returns the current particle system
  15350. */
  15351. removeVelocityGradient(gradient: number): IParticleSystem;
  15352. /**
  15353. * Gets the current list of limit velocity gradients.
  15354. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15355. * @returns the list of limit velocity gradients
  15356. */
  15357. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15358. /**
  15359. * Adds a new limit velocity gradient
  15360. * @param gradient defines the gradient to use (between 0 and 1)
  15361. * @param factor defines the limit velocity to affect to the specified gradient
  15362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15363. * @returns the current particle system
  15364. */
  15365. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15366. /**
  15367. * Remove a specific limit velocity gradient
  15368. * @param gradient defines the gradient to remove
  15369. * @returns the current particle system
  15370. */
  15371. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15372. /**
  15373. * Adds a new drag gradient
  15374. * @param gradient defines the gradient to use (between 0 and 1)
  15375. * @param factor defines the drag to affect to the specified gradient
  15376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15377. * @returns the current particle system
  15378. */
  15379. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15380. /**
  15381. * Remove a specific drag gradient
  15382. * @param gradient defines the gradient to remove
  15383. * @returns the current particle system
  15384. */
  15385. removeDragGradient(gradient: number): IParticleSystem;
  15386. /**
  15387. * Gets the current list of drag gradients.
  15388. * You must use addDragGradient and removeDragGradient to udpate this list
  15389. * @returns the list of drag gradients
  15390. */
  15391. getDragGradients(): Nullable<Array<FactorGradient>>;
  15392. /**
  15393. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15394. * @param gradient defines the gradient to use (between 0 and 1)
  15395. * @param factor defines the emit rate to affect to the specified gradient
  15396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15397. * @returns the current particle system
  15398. */
  15399. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15400. /**
  15401. * Remove a specific emit rate gradient
  15402. * @param gradient defines the gradient to remove
  15403. * @returns the current particle system
  15404. */
  15405. removeEmitRateGradient(gradient: number): IParticleSystem;
  15406. /**
  15407. * Gets the current list of emit rate gradients.
  15408. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15409. * @returns the list of emit rate gradients
  15410. */
  15411. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15412. /**
  15413. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15414. * @param gradient defines the gradient to use (between 0 and 1)
  15415. * @param factor defines the start size to affect to the specified gradient
  15416. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15417. * @returns the current particle system
  15418. */
  15419. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15420. /**
  15421. * Remove a specific start size gradient
  15422. * @param gradient defines the gradient to remove
  15423. * @returns the current particle system
  15424. */
  15425. removeStartSizeGradient(gradient: number): IParticleSystem;
  15426. /**
  15427. * Gets the current list of start size gradients.
  15428. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15429. * @returns the list of start size gradients
  15430. */
  15431. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15432. /**
  15433. * Adds a new life time gradient
  15434. * @param gradient defines the gradient to use (between 0 and 1)
  15435. * @param factor defines the life time factor to affect to the specified gradient
  15436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15437. * @returns the current particle system
  15438. */
  15439. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15440. /**
  15441. * Remove a specific life time gradient
  15442. * @param gradient defines the gradient to remove
  15443. * @returns the current particle system
  15444. */
  15445. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15446. /**
  15447. * Gets the current list of life time gradients.
  15448. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15449. * @returns the list of life time gradients
  15450. */
  15451. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15452. /**
  15453. * Gets the current list of color gradients.
  15454. * You must use addColorGradient and removeColorGradient to udpate this list
  15455. * @returns the list of color gradients
  15456. */
  15457. getColorGradients(): Nullable<Array<ColorGradient>>;
  15458. /**
  15459. * Adds a new ramp gradient used to remap particle colors
  15460. * @param gradient defines the gradient to use (between 0 and 1)
  15461. * @param color defines the color to affect to the specified gradient
  15462. * @returns the current particle system
  15463. */
  15464. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15465. /**
  15466. * Gets the current list of ramp gradients.
  15467. * You must use addRampGradient and removeRampGradient to udpate this list
  15468. * @returns the list of ramp gradients
  15469. */
  15470. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15471. /** Gets or sets a boolean indicating that ramp gradients must be used
  15472. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15473. */
  15474. useRampGradients: boolean;
  15475. /**
  15476. * Adds a new color remap gradient
  15477. * @param gradient defines the gradient to use (between 0 and 1)
  15478. * @param min defines the color remap minimal range
  15479. * @param max defines the color remap maximal range
  15480. * @returns the current particle system
  15481. */
  15482. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15483. /**
  15484. * Gets the current list of color remap gradients.
  15485. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15486. * @returns the list of color remap gradients
  15487. */
  15488. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15489. /**
  15490. * Adds a new alpha remap gradient
  15491. * @param gradient defines the gradient to use (between 0 and 1)
  15492. * @param min defines the alpha remap minimal range
  15493. * @param max defines the alpha remap maximal range
  15494. * @returns the current particle system
  15495. */
  15496. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15497. /**
  15498. * Gets the current list of alpha remap gradients.
  15499. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15500. * @returns the list of alpha remap gradients
  15501. */
  15502. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15503. /**
  15504. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15505. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15506. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15507. * @returns the emitter
  15508. */
  15509. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15510. /**
  15511. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15512. * @param radius The radius of the hemisphere to emit from
  15513. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15514. * @returns the emitter
  15515. */
  15516. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15517. /**
  15518. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15519. * @param radius The radius of the sphere to emit from
  15520. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15521. * @returns the emitter
  15522. */
  15523. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15524. /**
  15525. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15526. * @param radius The radius of the sphere to emit from
  15527. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15528. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15529. * @returns the emitter
  15530. */
  15531. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15532. /**
  15533. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15534. * @param radius The radius of the emission cylinder
  15535. * @param height The height of the emission cylinder
  15536. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15537. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15538. * @returns the emitter
  15539. */
  15540. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15541. /**
  15542. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15543. * @param radius The radius of the cylinder to emit from
  15544. * @param height The height of the emission cylinder
  15545. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15546. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15547. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15548. * @returns the emitter
  15549. */
  15550. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15551. /**
  15552. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15553. * @param radius The radius of the cone to emit from
  15554. * @param angle The base angle of the cone
  15555. * @returns the emitter
  15556. */
  15557. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15558. /**
  15559. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15562. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15563. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15564. * @returns the emitter
  15565. */
  15566. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15567. /**
  15568. * Get hosting scene
  15569. * @returns the scene
  15570. */
  15571. getScene(): Scene;
  15572. }
  15573. }
  15574. declare module "babylonjs/Meshes/instancedMesh" {
  15575. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15576. import { Vector3 } from "babylonjs/Maths/math";
  15577. import { Camera } from "babylonjs/Cameras/camera";
  15578. import { Node } from "babylonjs/node";
  15579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15580. import { Mesh } from "babylonjs/Meshes/mesh";
  15581. import { Material } from "babylonjs/Materials/material";
  15582. import { Skeleton } from "babylonjs/Bones/skeleton";
  15583. /**
  15584. * Creates an instance based on a source mesh.
  15585. */
  15586. export class InstancedMesh extends AbstractMesh {
  15587. private _sourceMesh;
  15588. private _currentLOD;
  15589. /** @hidden */
  15590. _indexInSourceMeshInstanceArray: number;
  15591. constructor(name: string, source: Mesh);
  15592. /**
  15593. * Returns the string "InstancedMesh".
  15594. */
  15595. getClassName(): string;
  15596. /**
  15597. * If the source mesh receives shadows
  15598. */
  15599. readonly receiveShadows: boolean;
  15600. /**
  15601. * The material of the source mesh
  15602. */
  15603. readonly material: Nullable<Material>;
  15604. /**
  15605. * Visibility of the source mesh
  15606. */
  15607. readonly visibility: number;
  15608. /**
  15609. * Skeleton of the source mesh
  15610. */
  15611. readonly skeleton: Nullable<Skeleton>;
  15612. /**
  15613. * Rendering ground id of the source mesh
  15614. */
  15615. renderingGroupId: number;
  15616. /**
  15617. * Returns the total number of vertices (integer).
  15618. */
  15619. getTotalVertices(): number;
  15620. /**
  15621. * Returns a positive integer : the total number of indices in this mesh geometry.
  15622. * @returns the numner of indices or zero if the mesh has no geometry.
  15623. */
  15624. getTotalIndices(): number;
  15625. /**
  15626. * The source mesh of the instance
  15627. */
  15628. readonly sourceMesh: Mesh;
  15629. /**
  15630. * Is this node ready to be used/rendered
  15631. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15632. * @return {boolean} is it ready
  15633. */
  15634. isReady(completeCheck?: boolean): boolean;
  15635. /**
  15636. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15637. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15638. * @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.
  15639. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15640. */
  15641. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15642. /**
  15643. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15644. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15645. * The `data` are either a numeric array either a Float32Array.
  15646. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15647. * 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).
  15648. * Note that a new underlying VertexBuffer object is created each call.
  15649. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15650. *
  15651. * Possible `kind` values :
  15652. * - VertexBuffer.PositionKind
  15653. * - VertexBuffer.UVKind
  15654. * - VertexBuffer.UV2Kind
  15655. * - VertexBuffer.UV3Kind
  15656. * - VertexBuffer.UV4Kind
  15657. * - VertexBuffer.UV5Kind
  15658. * - VertexBuffer.UV6Kind
  15659. * - VertexBuffer.ColorKind
  15660. * - VertexBuffer.MatricesIndicesKind
  15661. * - VertexBuffer.MatricesIndicesExtraKind
  15662. * - VertexBuffer.MatricesWeightsKind
  15663. * - VertexBuffer.MatricesWeightsExtraKind
  15664. *
  15665. * Returns the Mesh.
  15666. */
  15667. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  15668. /**
  15669. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15670. * If the mesh has no geometry, it is simply returned as it is.
  15671. * The `data` are either a numeric array either a Float32Array.
  15672. * No new underlying VertexBuffer object is created.
  15673. * 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.
  15674. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15675. *
  15676. * Possible `kind` values :
  15677. * - VertexBuffer.PositionKind
  15678. * - VertexBuffer.UVKind
  15679. * - VertexBuffer.UV2Kind
  15680. * - VertexBuffer.UV3Kind
  15681. * - VertexBuffer.UV4Kind
  15682. * - VertexBuffer.UV5Kind
  15683. * - VertexBuffer.UV6Kind
  15684. * - VertexBuffer.ColorKind
  15685. * - VertexBuffer.MatricesIndicesKind
  15686. * - VertexBuffer.MatricesIndicesExtraKind
  15687. * - VertexBuffer.MatricesWeightsKind
  15688. * - VertexBuffer.MatricesWeightsExtraKind
  15689. *
  15690. * Returns the Mesh.
  15691. */
  15692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15693. /**
  15694. * Sets the mesh indices.
  15695. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15696. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15697. * This method creates a new index buffer each call.
  15698. * Returns the Mesh.
  15699. */
  15700. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15701. /**
  15702. * Boolean : True if the mesh owns the requested kind of data.
  15703. */
  15704. isVerticesDataPresent(kind: string): boolean;
  15705. /**
  15706. * Returns an array of indices (IndicesArray).
  15707. */
  15708. getIndices(): Nullable<IndicesArray>;
  15709. readonly _positions: Nullable<Vector3[]>;
  15710. /**
  15711. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15712. * This means the mesh underlying bounding box and sphere are recomputed.
  15713. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15714. * @returns the current mesh
  15715. */
  15716. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15717. /** @hidden */
  15718. _preActivate(): InstancedMesh;
  15719. /** @hidden */
  15720. _activate(renderId: number): InstancedMesh;
  15721. /**
  15722. * Returns the current associated LOD AbstractMesh.
  15723. */
  15724. getLOD(camera: Camera): AbstractMesh;
  15725. /** @hidden */
  15726. _syncSubMeshes(): InstancedMesh;
  15727. /** @hidden */
  15728. _generatePointsArray(): boolean;
  15729. /**
  15730. * Creates a new InstancedMesh from the current mesh.
  15731. * - name (string) : the cloned mesh name
  15732. * - newParent (optional Node) : the optional Node to parent the clone to.
  15733. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15734. *
  15735. * Returns the clone.
  15736. */
  15737. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  15738. /**
  15739. * Disposes the InstancedMesh.
  15740. * Returns nothing.
  15741. */
  15742. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15743. }
  15744. }
  15745. declare module "babylonjs/Materials/shaderMaterial" {
  15746. import { Scene } from "babylonjs/scene";
  15747. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  15748. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15749. import { Mesh } from "babylonjs/Meshes/mesh";
  15750. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15751. import { Texture } from "babylonjs/Materials/Textures/texture";
  15752. import { Material } from "babylonjs/Materials/material";
  15753. /**
  15754. * Defines the options associated with the creation of a shader material.
  15755. */
  15756. export interface IShaderMaterialOptions {
  15757. /**
  15758. * Does the material work in alpha blend mode
  15759. */
  15760. needAlphaBlending: boolean;
  15761. /**
  15762. * Does the material work in alpha test mode
  15763. */
  15764. needAlphaTesting: boolean;
  15765. /**
  15766. * The list of attribute names used in the shader
  15767. */
  15768. attributes: string[];
  15769. /**
  15770. * The list of unifrom names used in the shader
  15771. */
  15772. uniforms: string[];
  15773. /**
  15774. * The list of UBO names used in the shader
  15775. */
  15776. uniformBuffers: string[];
  15777. /**
  15778. * The list of sampler names used in the shader
  15779. */
  15780. samplers: string[];
  15781. /**
  15782. * The list of defines used in the shader
  15783. */
  15784. defines: string[];
  15785. }
  15786. /**
  15787. * 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.
  15788. *
  15789. * This returned material effects how the mesh will look based on the code in the shaders.
  15790. *
  15791. * @see http://doc.babylonjs.com/how_to/shader_material
  15792. */
  15793. export class ShaderMaterial extends Material {
  15794. private _shaderPath;
  15795. private _options;
  15796. private _textures;
  15797. private _textureArrays;
  15798. private _floats;
  15799. private _ints;
  15800. private _floatsArrays;
  15801. private _colors3;
  15802. private _colors3Arrays;
  15803. private _colors4;
  15804. private _vectors2;
  15805. private _vectors3;
  15806. private _vectors4;
  15807. private _matrices;
  15808. private _matrices3x3;
  15809. private _matrices2x2;
  15810. private _vectors2Arrays;
  15811. private _vectors3Arrays;
  15812. private _cachedWorldViewMatrix;
  15813. private _renderId;
  15814. /**
  15815. * Instantiate a new shader material.
  15816. * 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.
  15817. * This returned material effects how the mesh will look based on the code in the shaders.
  15818. * @see http://doc.babylonjs.com/how_to/shader_material
  15819. * @param name Define the name of the material in the scene
  15820. * @param scene Define the scene the material belongs to
  15821. * @param shaderPath Defines the route to the shader code in one of three ways:
  15822. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15823. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  15824. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15825. * @param options Define the options used to create the shader
  15826. */
  15827. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15828. /**
  15829. * Gets the current class name of the material e.g. "ShaderMaterial"
  15830. * Mainly use in serialization.
  15831. * @returns the class name
  15832. */
  15833. getClassName(): string;
  15834. /**
  15835. * Specifies if the material will require alpha blending
  15836. * @returns a boolean specifying if alpha blending is needed
  15837. */
  15838. needAlphaBlending(): boolean;
  15839. /**
  15840. * Specifies if this material should be rendered in alpha test mode
  15841. * @returns a boolean specifying if an alpha test is needed.
  15842. */
  15843. needAlphaTesting(): boolean;
  15844. private _checkUniform;
  15845. /**
  15846. * Set a texture in the shader.
  15847. * @param name Define the name of the uniform samplers as defined in the shader
  15848. * @param texture Define the texture to bind to this sampler
  15849. * @return the material itself allowing "fluent" like uniform updates
  15850. */
  15851. setTexture(name: string, texture: Texture): ShaderMaterial;
  15852. /**
  15853. * Set a texture array in the shader.
  15854. * @param name Define the name of the uniform sampler array as defined in the shader
  15855. * @param textures Define the list of textures to bind to this sampler
  15856. * @return the material itself allowing "fluent" like uniform updates
  15857. */
  15858. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15859. /**
  15860. * Set a float in the shader.
  15861. * @param name Define the name of the uniform as defined in the shader
  15862. * @param value Define the value to give to the uniform
  15863. * @return the material itself allowing "fluent" like uniform updates
  15864. */
  15865. setFloat(name: string, value: number): ShaderMaterial;
  15866. /**
  15867. * Set a int in the shader.
  15868. * @param name Define the name of the uniform as defined in the shader
  15869. * @param value Define the value to give to the uniform
  15870. * @return the material itself allowing "fluent" like uniform updates
  15871. */
  15872. setInt(name: string, value: number): ShaderMaterial;
  15873. /**
  15874. * Set an array of floats in the shader.
  15875. * @param name Define the name of the uniform as defined in the shader
  15876. * @param value Define the value to give to the uniform
  15877. * @return the material itself allowing "fluent" like uniform updates
  15878. */
  15879. setFloats(name: string, value: number[]): ShaderMaterial;
  15880. /**
  15881. * Set a vec3 in the shader from a Color3.
  15882. * @param name Define the name of the uniform as defined in the shader
  15883. * @param value Define the value to give to the uniform
  15884. * @return the material itself allowing "fluent" like uniform updates
  15885. */
  15886. setColor3(name: string, value: Color3): ShaderMaterial;
  15887. /**
  15888. * Set a vec3 array in the shader from a Color3 array.
  15889. * @param name Define the name of the uniform as defined in the shader
  15890. * @param value Define the value to give to the uniform
  15891. * @return the material itself allowing "fluent" like uniform updates
  15892. */
  15893. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15894. /**
  15895. * Set a vec4 in the shader from a Color4.
  15896. * @param name Define the name of the uniform as defined in the shader
  15897. * @param value Define the value to give to the uniform
  15898. * @return the material itself allowing "fluent" like uniform updates
  15899. */
  15900. setColor4(name: string, value: Color4): ShaderMaterial;
  15901. /**
  15902. * Set a vec2 in the shader from a Vector2.
  15903. * @param name Define the name of the uniform as defined in the shader
  15904. * @param value Define the value to give to the uniform
  15905. * @return the material itself allowing "fluent" like uniform updates
  15906. */
  15907. setVector2(name: string, value: Vector2): ShaderMaterial;
  15908. /**
  15909. * Set a vec3 in the shader from a Vector3.
  15910. * @param name Define the name of the uniform as defined in the shader
  15911. * @param value Define the value to give to the uniform
  15912. * @return the material itself allowing "fluent" like uniform updates
  15913. */
  15914. setVector3(name: string, value: Vector3): ShaderMaterial;
  15915. /**
  15916. * Set a vec4 in the shader from a Vector4.
  15917. * @param name Define the name of the uniform as defined in the shader
  15918. * @param value Define the value to give to the uniform
  15919. * @return the material itself allowing "fluent" like uniform updates
  15920. */
  15921. setVector4(name: string, value: Vector4): ShaderMaterial;
  15922. /**
  15923. * Set a mat4 in the shader from a Matrix.
  15924. * @param name Define the name of the uniform as defined in the shader
  15925. * @param value Define the value to give to the uniform
  15926. * @return the material itself allowing "fluent" like uniform updates
  15927. */
  15928. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15929. /**
  15930. * Set a mat3 in the shader from a Float32Array.
  15931. * @param name Define the name of the uniform as defined in the shader
  15932. * @param value Define the value to give to the uniform
  15933. * @return the material itself allowing "fluent" like uniform updates
  15934. */
  15935. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15936. /**
  15937. * Set a mat2 in the shader from a Float32Array.
  15938. * @param name Define the name of the uniform as defined in the shader
  15939. * @param value Define the value to give to the uniform
  15940. * @return the material itself allowing "fluent" like uniform updates
  15941. */
  15942. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15943. /**
  15944. * Set a vec2 array in the shader from a number array.
  15945. * @param name Define the name of the uniform as defined in the shader
  15946. * @param value Define the value to give to the uniform
  15947. * @return the material itself allowing "fluent" like uniform updates
  15948. */
  15949. setArray2(name: string, value: number[]): ShaderMaterial;
  15950. /**
  15951. * Set a vec3 array in the shader from a number array.
  15952. * @param name Define the name of the uniform as defined in the shader
  15953. * @param value Define the value to give to the uniform
  15954. * @return the material itself allowing "fluent" like uniform updates
  15955. */
  15956. setArray3(name: string, value: number[]): ShaderMaterial;
  15957. private _checkCache;
  15958. /**
  15959. * Checks if the material is ready to render the requested mesh
  15960. * @param mesh Define the mesh to render
  15961. * @param useInstances Define whether or not the material is used with instances
  15962. * @returns true if ready, otherwise false
  15963. */
  15964. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15965. /**
  15966. * Binds the world matrix to the material
  15967. * @param world defines the world transformation matrix
  15968. */
  15969. bindOnlyWorldMatrix(world: Matrix): void;
  15970. /**
  15971. * Binds the material to the mesh
  15972. * @param world defines the world transformation matrix
  15973. * @param mesh defines the mesh to bind the material to
  15974. */
  15975. bind(world: Matrix, mesh?: Mesh): void;
  15976. /**
  15977. * Gets the active textures from the material
  15978. * @returns an array of textures
  15979. */
  15980. getActiveTextures(): BaseTexture[];
  15981. /**
  15982. * Specifies if the material uses a texture
  15983. * @param texture defines the texture to check against the material
  15984. * @returns a boolean specifying if the material uses the texture
  15985. */
  15986. hasTexture(texture: BaseTexture): boolean;
  15987. /**
  15988. * Makes a duplicate of the material, and gives it a new name
  15989. * @param name defines the new name for the duplicated material
  15990. * @returns the cloned material
  15991. */
  15992. clone(name: string): ShaderMaterial;
  15993. /**
  15994. * Disposes the material
  15995. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15996. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15997. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15998. */
  15999. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16000. /**
  16001. * Serializes this material in a JSON representation
  16002. * @returns the serialized material object
  16003. */
  16004. serialize(): any;
  16005. /**
  16006. * Creates a shader material from parsed shader material data
  16007. * @param source defines the JSON represnetation of the material
  16008. * @param scene defines the hosting scene
  16009. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16010. * @returns a new material
  16011. */
  16012. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16013. }
  16014. }
  16015. declare module "babylonjs/Shaders/color.fragment" {
  16016. /** @hidden */
  16017. export var colorPixelShader: {
  16018. name: string;
  16019. shader: string;
  16020. };
  16021. }
  16022. declare module "babylonjs/Shaders/color.vertex" {
  16023. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  16024. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  16025. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  16026. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  16027. /** @hidden */
  16028. export var colorVertexShader: {
  16029. name: string;
  16030. shader: string;
  16031. };
  16032. }
  16033. declare module "babylonjs/Meshes/linesMesh" {
  16034. import { Nullable } from "babylonjs/types";
  16035. import { Scene } from "babylonjs/scene";
  16036. import { Color3 } from "babylonjs/Maths/math";
  16037. import { Node } from "babylonjs/node";
  16038. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16039. import { Mesh } from "babylonjs/Meshes/mesh";
  16040. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  16041. import { Effect } from "babylonjs/Materials/effect";
  16042. import { Material } from "babylonjs/Materials/material";
  16043. import "babylonjs/Shaders/color.fragment";
  16044. import "babylonjs/Shaders/color.vertex";
  16045. /**
  16046. * Line mesh
  16047. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16048. */
  16049. export class LinesMesh extends Mesh {
  16050. /**
  16051. * If vertex color should be applied to the mesh
  16052. */
  16053. useVertexColor?: boolean | undefined;
  16054. /**
  16055. * If vertex alpha should be applied to the mesh
  16056. */
  16057. useVertexAlpha?: boolean | undefined;
  16058. /**
  16059. * Color of the line (Default: White)
  16060. */
  16061. color: Color3;
  16062. /**
  16063. * Alpha of the line (Default: 1)
  16064. */
  16065. alpha: number;
  16066. /**
  16067. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16068. * This margin is expressed in world space coordinates, so its value may vary.
  16069. * Default value is 0.1
  16070. */
  16071. intersectionThreshold: number;
  16072. private _colorShader;
  16073. /**
  16074. * Creates a new LinesMesh
  16075. * @param name defines the name
  16076. * @param scene defines the hosting scene
  16077. * @param parent defines the parent mesh if any
  16078. * @param source defines the optional source LinesMesh used to clone data from
  16079. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16080. * When false, achieved by calling a clone(), also passing False.
  16081. * This will make creation of children, recursive.
  16082. * @param useVertexColor defines if this LinesMesh supports vertex color
  16083. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16084. */
  16085. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16086. /**
  16087. * If vertex color should be applied to the mesh
  16088. */
  16089. useVertexColor?: boolean | undefined,
  16090. /**
  16091. * If vertex alpha should be applied to the mesh
  16092. */
  16093. useVertexAlpha?: boolean | undefined);
  16094. /**
  16095. * Returns the string "LineMesh"
  16096. */
  16097. getClassName(): string;
  16098. /**
  16099. * @hidden
  16100. */
  16101. /**
  16102. * @hidden
  16103. */
  16104. material: Material;
  16105. /**
  16106. * @hidden
  16107. */
  16108. readonly checkCollisions: boolean;
  16109. /** @hidden */
  16110. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16111. /** @hidden */
  16112. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16113. /**
  16114. * Disposes of the line mesh
  16115. * @param doNotRecurse If children should be disposed
  16116. */
  16117. dispose(doNotRecurse?: boolean): void;
  16118. /**
  16119. * Returns a new LineMesh object cloned from the current one.
  16120. */
  16121. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16122. /**
  16123. * Creates a new InstancedLinesMesh object from the mesh model.
  16124. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16125. * @param name defines the name of the new instance
  16126. * @returns a new InstancedLinesMesh
  16127. */
  16128. createInstance(name: string): InstancedLinesMesh;
  16129. }
  16130. /**
  16131. * Creates an instance based on a source LinesMesh
  16132. */
  16133. export class InstancedLinesMesh extends InstancedMesh {
  16134. /**
  16135. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16136. * This margin is expressed in world space coordinates, so its value may vary.
  16137. * Initilized with the intersectionThreshold value of the source LinesMesh
  16138. */
  16139. intersectionThreshold: number;
  16140. constructor(name: string, source: LinesMesh);
  16141. /**
  16142. * Returns the string "InstancedLinesMesh".
  16143. */
  16144. getClassName(): string;
  16145. }
  16146. }
  16147. declare module "babylonjs/Shaders/line.fragment" {
  16148. /** @hidden */
  16149. export var linePixelShader: {
  16150. name: string;
  16151. shader: string;
  16152. };
  16153. }
  16154. declare module "babylonjs/Shaders/line.vertex" {
  16155. /** @hidden */
  16156. export var lineVertexShader: {
  16157. name: string;
  16158. shader: string;
  16159. };
  16160. }
  16161. declare module "babylonjs/Rendering/edgesRenderer" {
  16162. import { Nullable } from "babylonjs/types";
  16163. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16164. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16165. import { Vector3 } from "babylonjs/Maths/math";
  16166. import { IDisposable } from "babylonjs/scene";
  16167. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16168. import "babylonjs/Shaders/line.fragment";
  16169. import "babylonjs/Shaders/line.vertex";
  16170. module "babylonjs/Meshes/abstractMesh" {
  16171. interface AbstractMesh {
  16172. /**
  16173. * Disables the mesh edge rendering mode
  16174. * @returns the currentAbstractMesh
  16175. */
  16176. disableEdgesRendering(): AbstractMesh;
  16177. /**
  16178. * Enables the edge rendering mode on the mesh.
  16179. * This mode makes the mesh edges visible
  16180. * @param epsilon defines the maximal distance between two angles to detect a face
  16181. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16182. * @returns the currentAbstractMesh
  16183. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16184. */
  16185. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16186. /**
  16187. * Gets the edgesRenderer associated with the mesh
  16188. */
  16189. edgesRenderer: Nullable<EdgesRenderer>;
  16190. }
  16191. }
  16192. module "babylonjs/Meshes/linesMesh" {
  16193. interface LinesMesh {
  16194. /**
  16195. * Enables the edge rendering mode on the mesh.
  16196. * This mode makes the mesh edges visible
  16197. * @param epsilon defines the maximal distance between two angles to detect a face
  16198. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16199. * @returns the currentAbstractMesh
  16200. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16201. */
  16202. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16203. }
  16204. }
  16205. module "babylonjs/Meshes/linesMesh" {
  16206. interface InstancedLinesMesh {
  16207. /**
  16208. * Enables the edge rendering mode on the mesh.
  16209. * This mode makes the mesh edges visible
  16210. * @param epsilon defines the maximal distance between two angles to detect a face
  16211. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16212. * @returns the current InstancedLinesMesh
  16213. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16214. */
  16215. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16216. }
  16217. }
  16218. /**
  16219. * Defines the minimum contract an Edges renderer should follow.
  16220. */
  16221. export interface IEdgesRenderer extends IDisposable {
  16222. /**
  16223. * Gets or sets a boolean indicating if the edgesRenderer is active
  16224. */
  16225. isEnabled: boolean;
  16226. /**
  16227. * Renders the edges of the attached mesh,
  16228. */
  16229. render(): void;
  16230. /**
  16231. * Checks wether or not the edges renderer is ready to render.
  16232. * @return true if ready, otherwise false.
  16233. */
  16234. isReady(): boolean;
  16235. }
  16236. /**
  16237. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16238. */
  16239. export class EdgesRenderer implements IEdgesRenderer {
  16240. /**
  16241. * Define the size of the edges with an orthographic camera
  16242. */
  16243. edgesWidthScalerForOrthographic: number;
  16244. /**
  16245. * Define the size of the edges with a perspective camera
  16246. */
  16247. edgesWidthScalerForPerspective: number;
  16248. protected _source: AbstractMesh;
  16249. protected _linesPositions: number[];
  16250. protected _linesNormals: number[];
  16251. protected _linesIndices: number[];
  16252. protected _epsilon: number;
  16253. protected _indicesCount: number;
  16254. protected _lineShader: ShaderMaterial;
  16255. protected _ib: WebGLBuffer;
  16256. protected _buffers: {
  16257. [key: string]: Nullable<VertexBuffer>;
  16258. };
  16259. protected _checkVerticesInsteadOfIndices: boolean;
  16260. private _meshRebuildObserver;
  16261. private _meshDisposeObserver;
  16262. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16263. isEnabled: boolean;
  16264. /**
  16265. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16266. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16267. * @param source Mesh used to create edges
  16268. * @param epsilon sum of angles in adjacency to check for edge
  16269. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16270. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16271. */
  16272. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16273. protected _prepareRessources(): void;
  16274. /** @hidden */
  16275. _rebuild(): void;
  16276. /**
  16277. * Releases the required resources for the edges renderer
  16278. */
  16279. dispose(): void;
  16280. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16281. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16282. /**
  16283. * Checks if the pair of p0 and p1 is en edge
  16284. * @param faceIndex
  16285. * @param edge
  16286. * @param faceNormals
  16287. * @param p0
  16288. * @param p1
  16289. * @private
  16290. */
  16291. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16292. /**
  16293. * push line into the position, normal and index buffer
  16294. * @protected
  16295. */
  16296. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16297. /**
  16298. * Generates lines edges from adjacencjes
  16299. * @private
  16300. */
  16301. _generateEdgesLines(): void;
  16302. /**
  16303. * Checks wether or not the edges renderer is ready to render.
  16304. * @return true if ready, otherwise false.
  16305. */
  16306. isReady(): boolean;
  16307. /**
  16308. * Renders the edges of the attached mesh,
  16309. */
  16310. render(): void;
  16311. }
  16312. /**
  16313. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16314. */
  16315. export class LineEdgesRenderer extends EdgesRenderer {
  16316. /**
  16317. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16318. * @param source LineMesh used to generate edges
  16319. * @param epsilon not important (specified angle for edge detection)
  16320. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16321. */
  16322. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16323. /**
  16324. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16325. */
  16326. _generateEdgesLines(): void;
  16327. }
  16328. }
  16329. declare module "babylonjs/Rendering/renderingGroup" {
  16330. import { SmartArray } from "babylonjs/Misc/smartArray";
  16331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16333. import { Nullable } from "babylonjs/types";
  16334. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16335. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16336. import { Material } from "babylonjs/Materials/material";
  16337. import { Scene } from "babylonjs/scene";
  16338. /**
  16339. * This represents the object necessary to create a rendering group.
  16340. * This is exclusively used and created by the rendering manager.
  16341. * To modify the behavior, you use the available helpers in your scene or meshes.
  16342. * @hidden
  16343. */
  16344. export class RenderingGroup {
  16345. index: number;
  16346. private _scene;
  16347. private _opaqueSubMeshes;
  16348. private _transparentSubMeshes;
  16349. private _alphaTestSubMeshes;
  16350. private _depthOnlySubMeshes;
  16351. private _particleSystems;
  16352. private _spriteManagers;
  16353. private _opaqueSortCompareFn;
  16354. private _alphaTestSortCompareFn;
  16355. private _transparentSortCompareFn;
  16356. private _renderOpaque;
  16357. private _renderAlphaTest;
  16358. private _renderTransparent;
  16359. private _edgesRenderers;
  16360. onBeforeTransparentRendering: () => void;
  16361. /**
  16362. * Set the opaque sort comparison function.
  16363. * If null the sub meshes will be render in the order they were created
  16364. */
  16365. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16366. /**
  16367. * Set the alpha test sort comparison function.
  16368. * If null the sub meshes will be render in the order they were created
  16369. */
  16370. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16371. /**
  16372. * Set the transparent sort comparison function.
  16373. * If null the sub meshes will be render in the order they were created
  16374. */
  16375. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16376. /**
  16377. * Creates a new rendering group.
  16378. * @param index The rendering group index
  16379. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16380. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16381. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16382. */
  16383. 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>);
  16384. /**
  16385. * Render all the sub meshes contained in the group.
  16386. * @param customRenderFunction Used to override the default render behaviour of the group.
  16387. * @returns true if rendered some submeshes.
  16388. */
  16389. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16390. /**
  16391. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16392. * @param subMeshes The submeshes to render
  16393. */
  16394. private renderOpaqueSorted;
  16395. /**
  16396. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16397. * @param subMeshes The submeshes to render
  16398. */
  16399. private renderAlphaTestSorted;
  16400. /**
  16401. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16402. * @param subMeshes The submeshes to render
  16403. */
  16404. private renderTransparentSorted;
  16405. /**
  16406. * Renders the submeshes in a specified order.
  16407. * @param subMeshes The submeshes to sort before render
  16408. * @param sortCompareFn The comparison function use to sort
  16409. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16410. * @param transparent Specifies to activate blending if true
  16411. */
  16412. private static renderSorted;
  16413. /**
  16414. * Renders the submeshes in the order they were dispatched (no sort applied).
  16415. * @param subMeshes The submeshes to render
  16416. */
  16417. private static renderUnsorted;
  16418. /**
  16419. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16420. * are rendered back to front if in the same alpha index.
  16421. *
  16422. * @param a The first submesh
  16423. * @param b The second submesh
  16424. * @returns The result of the comparison
  16425. */
  16426. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16427. /**
  16428. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16429. * are rendered back to front.
  16430. *
  16431. * @param a The first submesh
  16432. * @param b The second submesh
  16433. * @returns The result of the comparison
  16434. */
  16435. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16436. /**
  16437. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16438. * are rendered front to back (prevent overdraw).
  16439. *
  16440. * @param a The first submesh
  16441. * @param b The second submesh
  16442. * @returns The result of the comparison
  16443. */
  16444. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16445. /**
  16446. * Resets the different lists of submeshes to prepare a new frame.
  16447. */
  16448. prepare(): void;
  16449. dispose(): void;
  16450. /**
  16451. * Inserts the submesh in its correct queue depending on its material.
  16452. * @param subMesh The submesh to dispatch
  16453. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16454. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16455. */
  16456. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16457. dispatchSprites(spriteManager: ISpriteManager): void;
  16458. dispatchParticles(particleSystem: IParticleSystem): void;
  16459. private _renderParticles;
  16460. private _renderSprites;
  16461. }
  16462. }
  16463. declare module "babylonjs/Rendering/renderingManager" {
  16464. import { Nullable } from "babylonjs/types";
  16465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16467. import { SmartArray } from "babylonjs/Misc/smartArray";
  16468. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16469. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16470. import { Material } from "babylonjs/Materials/material";
  16471. import { Scene } from "babylonjs/scene";
  16472. import { Camera } from "babylonjs/Cameras/camera";
  16473. /**
  16474. * Interface describing the different options available in the rendering manager
  16475. * regarding Auto Clear between groups.
  16476. */
  16477. export interface IRenderingManagerAutoClearSetup {
  16478. /**
  16479. * Defines whether or not autoclear is enable.
  16480. */
  16481. autoClear: boolean;
  16482. /**
  16483. * Defines whether or not to autoclear the depth buffer.
  16484. */
  16485. depth: boolean;
  16486. /**
  16487. * Defines whether or not to autoclear the stencil buffer.
  16488. */
  16489. stencil: boolean;
  16490. }
  16491. /**
  16492. * This class is used by the onRenderingGroupObservable
  16493. */
  16494. export class RenderingGroupInfo {
  16495. /**
  16496. * The Scene that being rendered
  16497. */
  16498. scene: Scene;
  16499. /**
  16500. * The camera currently used for the rendering pass
  16501. */
  16502. camera: Nullable<Camera>;
  16503. /**
  16504. * The ID of the renderingGroup being processed
  16505. */
  16506. renderingGroupId: number;
  16507. }
  16508. /**
  16509. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16510. * It is enable to manage the different groups as well as the different necessary sort functions.
  16511. * This should not be used directly aside of the few static configurations
  16512. */
  16513. export class RenderingManager {
  16514. /**
  16515. * The max id used for rendering groups (not included)
  16516. */
  16517. static MAX_RENDERINGGROUPS: number;
  16518. /**
  16519. * The min id used for rendering groups (included)
  16520. */
  16521. static MIN_RENDERINGGROUPS: number;
  16522. /**
  16523. * Used to globally prevent autoclearing scenes.
  16524. */
  16525. static AUTOCLEAR: boolean;
  16526. /**
  16527. * @hidden
  16528. */
  16529. _useSceneAutoClearSetup: boolean;
  16530. private _scene;
  16531. private _renderingGroups;
  16532. private _depthStencilBufferAlreadyCleaned;
  16533. private _autoClearDepthStencil;
  16534. private _customOpaqueSortCompareFn;
  16535. private _customAlphaTestSortCompareFn;
  16536. private _customTransparentSortCompareFn;
  16537. private _renderingGroupInfo;
  16538. /**
  16539. * Instantiates a new rendering group for a particular scene
  16540. * @param scene Defines the scene the groups belongs to
  16541. */
  16542. constructor(scene: Scene);
  16543. private _clearDepthStencilBuffer;
  16544. /**
  16545. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16546. * @hidden
  16547. */
  16548. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16549. /**
  16550. * Resets the different information of the group to prepare a new frame
  16551. * @hidden
  16552. */
  16553. reset(): void;
  16554. /**
  16555. * Dispose and release the group and its associated resources.
  16556. * @hidden
  16557. */
  16558. dispose(): void;
  16559. /**
  16560. * Clear the info related to rendering groups preventing retention points during dispose.
  16561. */
  16562. freeRenderingGroups(): void;
  16563. private _prepareRenderingGroup;
  16564. /**
  16565. * Add a sprite manager to the rendering manager in order to render it this frame.
  16566. * @param spriteManager Define the sprite manager to render
  16567. */
  16568. dispatchSprites(spriteManager: ISpriteManager): void;
  16569. /**
  16570. * Add a particle system to the rendering manager in order to render it this frame.
  16571. * @param particleSystem Define the particle system to render
  16572. */
  16573. dispatchParticles(particleSystem: IParticleSystem): void;
  16574. /**
  16575. * Add a submesh to the manager in order to render it this frame
  16576. * @param subMesh The submesh to dispatch
  16577. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16578. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16579. */
  16580. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16581. /**
  16582. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16583. * This allowed control for front to back rendering or reversly depending of the special needs.
  16584. *
  16585. * @param renderingGroupId The rendering group id corresponding to its index
  16586. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16587. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16588. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16589. */
  16590. 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;
  16591. /**
  16592. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16593. *
  16594. * @param renderingGroupId The rendering group id corresponding to its index
  16595. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16596. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16597. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16598. */
  16599. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16600. /**
  16601. * Gets the current auto clear configuration for one rendering group of the rendering
  16602. * manager.
  16603. * @param index the rendering group index to get the information for
  16604. * @returns The auto clear setup for the requested rendering group
  16605. */
  16606. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16607. }
  16608. }
  16609. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  16610. import { Observable } from "babylonjs/Misc/observable";
  16611. import { SmartArray } from "babylonjs/Misc/smartArray";
  16612. import { Nullable } from "babylonjs/types";
  16613. import { Camera } from "babylonjs/Cameras/camera";
  16614. import { Scene } from "babylonjs/scene";
  16615. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  16616. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16618. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16619. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16620. import { Texture } from "babylonjs/Materials/Textures/texture";
  16621. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16622. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  16623. import { Engine } from "babylonjs/Engines/engine";
  16624. /**
  16625. * This Helps creating a texture that will be created from a camera in your scene.
  16626. * It is basically a dynamic texture that could be used to create special effects for instance.
  16627. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  16628. */
  16629. export class RenderTargetTexture extends Texture {
  16630. isCube: boolean;
  16631. /**
  16632. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  16633. */
  16634. static readonly REFRESHRATE_RENDER_ONCE: number;
  16635. /**
  16636. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  16637. */
  16638. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  16639. /**
  16640. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  16641. * the central point of your effect and can save a lot of performances.
  16642. */
  16643. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  16644. /**
  16645. * Use this predicate to dynamically define the list of mesh you want to render.
  16646. * If set, the renderList property will be overwritten.
  16647. */
  16648. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  16649. private _renderList;
  16650. /**
  16651. * Use this list to define the list of mesh you want to render.
  16652. */
  16653. renderList: Nullable<Array<AbstractMesh>>;
  16654. private _hookArray;
  16655. /**
  16656. * Define if particles should be rendered in your texture.
  16657. */
  16658. renderParticles: boolean;
  16659. /**
  16660. * Define if sprites should be rendered in your texture.
  16661. */
  16662. renderSprites: boolean;
  16663. /**
  16664. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  16665. */
  16666. coordinatesMode: number;
  16667. /**
  16668. * Define the camera used to render the texture.
  16669. */
  16670. activeCamera: Nullable<Camera>;
  16671. /**
  16672. * Override the render function of the texture with your own one.
  16673. */
  16674. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  16675. /**
  16676. * Define if camera post processes should be use while rendering the texture.
  16677. */
  16678. useCameraPostProcesses: boolean;
  16679. /**
  16680. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  16681. */
  16682. ignoreCameraViewport: boolean;
  16683. private _postProcessManager;
  16684. private _postProcesses;
  16685. private _resizeObserver;
  16686. /**
  16687. * An event triggered when the texture is unbind.
  16688. */
  16689. onBeforeBindObservable: Observable<RenderTargetTexture>;
  16690. /**
  16691. * An event triggered when the texture is unbind.
  16692. */
  16693. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  16694. private _onAfterUnbindObserver;
  16695. /**
  16696. * Set a after unbind callback in the texture.
  16697. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  16698. */
  16699. onAfterUnbind: () => void;
  16700. /**
  16701. * An event triggered before rendering the texture
  16702. */
  16703. onBeforeRenderObservable: Observable<number>;
  16704. private _onBeforeRenderObserver;
  16705. /**
  16706. * Set a before render callback in the texture.
  16707. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  16708. */
  16709. onBeforeRender: (faceIndex: number) => void;
  16710. /**
  16711. * An event triggered after rendering the texture
  16712. */
  16713. onAfterRenderObservable: Observable<number>;
  16714. private _onAfterRenderObserver;
  16715. /**
  16716. * Set a after render callback in the texture.
  16717. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  16718. */
  16719. onAfterRender: (faceIndex: number) => void;
  16720. /**
  16721. * An event triggered after the texture clear
  16722. */
  16723. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  16724. private _onClearObserver;
  16725. /**
  16726. * Set a clear callback in the texture.
  16727. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  16728. */
  16729. onClear: (Engine: Engine) => void;
  16730. /**
  16731. * Define the clear color of the Render Target if it should be different from the scene.
  16732. */
  16733. clearColor: Color4;
  16734. protected _size: number | {
  16735. width: number;
  16736. height: number;
  16737. };
  16738. protected _initialSizeParameter: number | {
  16739. width: number;
  16740. height: number;
  16741. } | {
  16742. ratio: number;
  16743. };
  16744. protected _sizeRatio: Nullable<number>;
  16745. /** @hidden */
  16746. _generateMipMaps: boolean;
  16747. protected _renderingManager: RenderingManager;
  16748. /** @hidden */
  16749. _waitingRenderList: string[];
  16750. protected _doNotChangeAspectRatio: boolean;
  16751. protected _currentRefreshId: number;
  16752. protected _refreshRate: number;
  16753. protected _textureMatrix: Matrix;
  16754. protected _samples: number;
  16755. protected _renderTargetOptions: RenderTargetCreationOptions;
  16756. /**
  16757. * Gets render target creation options that were used.
  16758. */
  16759. readonly renderTargetOptions: RenderTargetCreationOptions;
  16760. protected _engine: Engine;
  16761. protected _onRatioRescale(): void;
  16762. /**
  16763. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  16764. * It must define where the camera used to render the texture is set
  16765. */
  16766. boundingBoxPosition: Vector3;
  16767. private _boundingBoxSize;
  16768. /**
  16769. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  16770. * When defined, the cubemap will switch to local mode
  16771. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  16772. * @example https://www.babylonjs-playground.com/#RNASML
  16773. */
  16774. boundingBoxSize: Vector3;
  16775. /**
  16776. * In case the RTT has been created with a depth texture, get the associated
  16777. * depth texture.
  16778. * Otherwise, return null.
  16779. */
  16780. depthStencilTexture: Nullable<InternalTexture>;
  16781. /**
  16782. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  16783. * or used a shadow, depth texture...
  16784. * @param name The friendly name of the texture
  16785. * @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)
  16786. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  16787. * @param generateMipMaps True if mip maps need to be generated after render.
  16788. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  16789. * @param type The type of the buffer in the RTT (int, half float, float...)
  16790. * @param isCube True if a cube texture needs to be created
  16791. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  16792. * @param generateDepthBuffer True to generate a depth buffer
  16793. * @param generateStencilBuffer True to generate a stencil buffer
  16794. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  16795. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  16796. * @param delayAllocation if the texture allocation should be delayed (default: false)
  16797. */
  16798. constructor(name: string, size: number | {
  16799. width: number;
  16800. height: number;
  16801. } | {
  16802. ratio: number;
  16803. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  16804. /**
  16805. * Creates a depth stencil texture.
  16806. * This is only available in WebGL 2 or with the depth texture extension available.
  16807. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  16808. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  16809. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  16810. */
  16811. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  16812. private _processSizeParameter;
  16813. /**
  16814. * Define the number of samples to use in case of MSAA.
  16815. * It defaults to one meaning no MSAA has been enabled.
  16816. */
  16817. samples: number;
  16818. /**
  16819. * Resets the refresh counter of the texture and start bak from scratch.
  16820. * Could be useful to regenerate the texture if it is setup to render only once.
  16821. */
  16822. resetRefreshCounter(): void;
  16823. /**
  16824. * Define the refresh rate of the texture or the rendering frequency.
  16825. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16826. */
  16827. refreshRate: number;
  16828. /**
  16829. * Adds a post process to the render target rendering passes.
  16830. * @param postProcess define the post process to add
  16831. */
  16832. addPostProcess(postProcess: PostProcess): void;
  16833. /**
  16834. * Clear all the post processes attached to the render target
  16835. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  16836. */
  16837. clearPostProcesses(dispose?: boolean): void;
  16838. /**
  16839. * Remove one of the post process from the list of attached post processes to the texture
  16840. * @param postProcess define the post process to remove from the list
  16841. */
  16842. removePostProcess(postProcess: PostProcess): void;
  16843. /** @hidden */
  16844. _shouldRender(): boolean;
  16845. /**
  16846. * Gets the actual render size of the texture.
  16847. * @returns the width of the render size
  16848. */
  16849. getRenderSize(): number;
  16850. /**
  16851. * Gets the actual render width of the texture.
  16852. * @returns the width of the render size
  16853. */
  16854. getRenderWidth(): number;
  16855. /**
  16856. * Gets the actual render height of the texture.
  16857. * @returns the height of the render size
  16858. */
  16859. getRenderHeight(): number;
  16860. /**
  16861. * Get if the texture can be rescaled or not.
  16862. */
  16863. readonly canRescale: boolean;
  16864. /**
  16865. * Resize the texture using a ratio.
  16866. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  16867. */
  16868. scale(ratio: number): void;
  16869. /**
  16870. * Get the texture reflection matrix used to rotate/transform the reflection.
  16871. * @returns the reflection matrix
  16872. */
  16873. getReflectionTextureMatrix(): Matrix;
  16874. /**
  16875. * Resize the texture to a new desired size.
  16876. * Be carrefull as it will recreate all the data in the new texture.
  16877. * @param size Define the new size. It can be:
  16878. * - a number for squared texture,
  16879. * - an object containing { width: number, height: number }
  16880. * - or an object containing a ratio { ratio: number }
  16881. */
  16882. resize(size: number | {
  16883. width: number;
  16884. height: number;
  16885. } | {
  16886. ratio: number;
  16887. }): void;
  16888. /**
  16889. * Renders all the objects from the render list into the texture.
  16890. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  16891. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  16892. */
  16893. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  16894. private _bestReflectionRenderTargetDimension;
  16895. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  16896. private renderToTarget;
  16897. /**
  16898. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16899. * This allowed control for front to back rendering or reversly depending of the special needs.
  16900. *
  16901. * @param renderingGroupId The rendering group id corresponding to its index
  16902. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16903. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16904. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16905. */
  16906. 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;
  16907. /**
  16908. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16909. *
  16910. * @param renderingGroupId The rendering group id corresponding to its index
  16911. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16912. */
  16913. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  16914. /**
  16915. * Clones the texture.
  16916. * @returns the cloned texture
  16917. */
  16918. clone(): RenderTargetTexture;
  16919. /**
  16920. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16921. * @returns The JSON representation of the texture
  16922. */
  16923. serialize(): any;
  16924. /**
  16925. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  16926. */
  16927. disposeFramebufferObjects(): void;
  16928. /**
  16929. * Dispose the texture and release its associated resources.
  16930. */
  16931. dispose(): void;
  16932. /** @hidden */
  16933. _rebuild(): void;
  16934. /**
  16935. * Clear the info related to rendering groups preventing retention point in material dispose.
  16936. */
  16937. freeRenderingGroups(): void;
  16938. }
  16939. }
  16940. declare module "babylonjs/Materials/material" {
  16941. import { IAnimatable } from "babylonjs/Misc/tools";
  16942. import { SmartArray } from "babylonjs/Misc/smartArray";
  16943. import { Observable } from "babylonjs/Misc/observable";
  16944. import { Nullable } from "babylonjs/types";
  16945. import { Scene } from "babylonjs/scene";
  16946. import { Matrix } from "babylonjs/Maths/math";
  16947. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  16948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16949. import { Mesh } from "babylonjs/Meshes/mesh";
  16950. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  16951. import { Effect } from "babylonjs/Materials/effect";
  16952. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16954. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16955. import { Animation } from "babylonjs/Animations/animation";
  16956. /**
  16957. * Base class for the main features of a material in Babylon.js
  16958. */
  16959. export class Material implements IAnimatable {
  16960. /**
  16961. * Returns the triangle fill mode
  16962. */
  16963. static readonly TriangleFillMode: number;
  16964. /**
  16965. * Returns the wireframe mode
  16966. */
  16967. static readonly WireFrameFillMode: number;
  16968. /**
  16969. * Returns the point fill mode
  16970. */
  16971. static readonly PointFillMode: number;
  16972. /**
  16973. * Returns the point list draw mode
  16974. */
  16975. static readonly PointListDrawMode: number;
  16976. /**
  16977. * Returns the line list draw mode
  16978. */
  16979. static readonly LineListDrawMode: number;
  16980. /**
  16981. * Returns the line loop draw mode
  16982. */
  16983. static readonly LineLoopDrawMode: number;
  16984. /**
  16985. * Returns the line strip draw mode
  16986. */
  16987. static readonly LineStripDrawMode: number;
  16988. /**
  16989. * Returns the triangle strip draw mode
  16990. */
  16991. static readonly TriangleStripDrawMode: number;
  16992. /**
  16993. * Returns the triangle fan draw mode
  16994. */
  16995. static readonly TriangleFanDrawMode: number;
  16996. /**
  16997. * Stores the clock-wise side orientation
  16998. */
  16999. static readonly ClockWiseSideOrientation: number;
  17000. /**
  17001. * Stores the counter clock-wise side orientation
  17002. */
  17003. static readonly CounterClockWiseSideOrientation: number;
  17004. /**
  17005. * The dirty texture flag value
  17006. */
  17007. static readonly TextureDirtyFlag: number;
  17008. /**
  17009. * The dirty light flag value
  17010. */
  17011. static readonly LightDirtyFlag: number;
  17012. /**
  17013. * The dirty fresnel flag value
  17014. */
  17015. static readonly FresnelDirtyFlag: number;
  17016. /**
  17017. * The dirty attribute flag value
  17018. */
  17019. static readonly AttributesDirtyFlag: number;
  17020. /**
  17021. * The dirty misc flag value
  17022. */
  17023. static readonly MiscDirtyFlag: number;
  17024. /**
  17025. * The all dirty flag value
  17026. */
  17027. static readonly AllDirtyFlag: number;
  17028. /**
  17029. * The ID of the material
  17030. */
  17031. id: string;
  17032. /**
  17033. * Gets or sets the unique id of the material
  17034. */
  17035. uniqueId: number;
  17036. /**
  17037. * The name of the material
  17038. */
  17039. name: string;
  17040. /**
  17041. * Gets or sets user defined metadata
  17042. */
  17043. metadata: any;
  17044. /**
  17045. * For internal use only. Please do not use.
  17046. */
  17047. reservedDataStore: any;
  17048. /**
  17049. * Specifies if the ready state should be checked on each call
  17050. */
  17051. checkReadyOnEveryCall: boolean;
  17052. /**
  17053. * Specifies if the ready state should be checked once
  17054. */
  17055. checkReadyOnlyOnce: boolean;
  17056. /**
  17057. * The state of the material
  17058. */
  17059. state: string;
  17060. /**
  17061. * The alpha value of the material
  17062. */
  17063. protected _alpha: number;
  17064. /**
  17065. * Sets the alpha value of the material
  17066. */
  17067. /**
  17068. * Gets the alpha value of the material
  17069. */
  17070. alpha: number;
  17071. /**
  17072. * Specifies if back face culling is enabled
  17073. */
  17074. protected _backFaceCulling: boolean;
  17075. /**
  17076. * Sets the back-face culling state
  17077. */
  17078. /**
  17079. * Gets the back-face culling state
  17080. */
  17081. backFaceCulling: boolean;
  17082. /**
  17083. * Stores the value for side orientation
  17084. */
  17085. sideOrientation: number;
  17086. /**
  17087. * Callback triggered when the material is compiled
  17088. */
  17089. onCompiled: (effect: Effect) => void;
  17090. /**
  17091. * Callback triggered when an error occurs
  17092. */
  17093. onError: (effect: Effect, errors: string) => void;
  17094. /**
  17095. * Callback triggered to get the render target textures
  17096. */
  17097. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  17098. /**
  17099. * Gets a boolean indicating that current material needs to register RTT
  17100. */
  17101. readonly hasRenderTargetTextures: boolean;
  17102. /**
  17103. * Specifies if the material should be serialized
  17104. */
  17105. doNotSerialize: boolean;
  17106. /**
  17107. * @hidden
  17108. */
  17109. _storeEffectOnSubMeshes: boolean;
  17110. /**
  17111. * Stores the animations for the material
  17112. */
  17113. animations: Array<Animation>;
  17114. /**
  17115. * An event triggered when the material is disposed
  17116. */
  17117. onDisposeObservable: Observable<Material>;
  17118. /**
  17119. * An observer which watches for dispose events
  17120. */
  17121. private _onDisposeObserver;
  17122. private _onUnBindObservable;
  17123. /**
  17124. * Called during a dispose event
  17125. */
  17126. onDispose: () => void;
  17127. private _onBindObservable;
  17128. /**
  17129. * An event triggered when the material is bound
  17130. */
  17131. readonly onBindObservable: Observable<AbstractMesh>;
  17132. /**
  17133. * An observer which watches for bind events
  17134. */
  17135. private _onBindObserver;
  17136. /**
  17137. * Called during a bind event
  17138. */
  17139. onBind: (Mesh: AbstractMesh) => void;
  17140. /**
  17141. * An event triggered when the material is unbound
  17142. */
  17143. readonly onUnBindObservable: Observable<Material>;
  17144. /**
  17145. * Stores the value of the alpha mode
  17146. */
  17147. private _alphaMode;
  17148. /**
  17149. * Sets the value of the alpha mode.
  17150. *
  17151. * | Value | Type | Description |
  17152. * | --- | --- | --- |
  17153. * | 0 | ALPHA_DISABLE | |
  17154. * | 1 | ALPHA_ADD | |
  17155. * | 2 | ALPHA_COMBINE | |
  17156. * | 3 | ALPHA_SUBTRACT | |
  17157. * | 4 | ALPHA_MULTIPLY | |
  17158. * | 5 | ALPHA_MAXIMIZED | |
  17159. * | 6 | ALPHA_ONEONE | |
  17160. * | 7 | ALPHA_PREMULTIPLIED | |
  17161. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  17162. * | 9 | ALPHA_INTERPOLATE | |
  17163. * | 10 | ALPHA_SCREENMODE | |
  17164. *
  17165. */
  17166. /**
  17167. * Gets the value of the alpha mode
  17168. */
  17169. alphaMode: number;
  17170. /**
  17171. * Stores the state of the need depth pre-pass value
  17172. */
  17173. private _needDepthPrePass;
  17174. /**
  17175. * Sets the need depth pre-pass value
  17176. */
  17177. /**
  17178. * Gets the depth pre-pass value
  17179. */
  17180. needDepthPrePass: boolean;
  17181. /**
  17182. * Specifies if depth writing should be disabled
  17183. */
  17184. disableDepthWrite: boolean;
  17185. /**
  17186. * Specifies if depth writing should be forced
  17187. */
  17188. forceDepthWrite: boolean;
  17189. /**
  17190. * Specifies if there should be a separate pass for culling
  17191. */
  17192. separateCullingPass: boolean;
  17193. /**
  17194. * Stores the state specifing if fog should be enabled
  17195. */
  17196. private _fogEnabled;
  17197. /**
  17198. * Sets the state for enabling fog
  17199. */
  17200. /**
  17201. * Gets the value of the fog enabled state
  17202. */
  17203. fogEnabled: boolean;
  17204. /**
  17205. * Stores the size of points
  17206. */
  17207. pointSize: number;
  17208. /**
  17209. * Stores the z offset value
  17210. */
  17211. zOffset: number;
  17212. /**
  17213. * Gets a value specifying if wireframe mode is enabled
  17214. */
  17215. /**
  17216. * Sets the state of wireframe mode
  17217. */
  17218. wireframe: boolean;
  17219. /**
  17220. * Gets the value specifying if point clouds are enabled
  17221. */
  17222. /**
  17223. * Sets the state of point cloud mode
  17224. */
  17225. pointsCloud: boolean;
  17226. /**
  17227. * Gets the material fill mode
  17228. */
  17229. /**
  17230. * Sets the material fill mode
  17231. */
  17232. fillMode: number;
  17233. /**
  17234. * @hidden
  17235. * Stores the effects for the material
  17236. */
  17237. _effect: Nullable<Effect>;
  17238. /**
  17239. * @hidden
  17240. * Specifies if the material was previously ready
  17241. */
  17242. _wasPreviouslyReady: boolean;
  17243. /**
  17244. * Specifies if uniform buffers should be used
  17245. */
  17246. private _useUBO;
  17247. /**
  17248. * Stores a reference to the scene
  17249. */
  17250. private _scene;
  17251. /**
  17252. * Stores the fill mode state
  17253. */
  17254. private _fillMode;
  17255. /**
  17256. * Specifies if the depth write state should be cached
  17257. */
  17258. private _cachedDepthWriteState;
  17259. /**
  17260. * Stores the uniform buffer
  17261. */
  17262. protected _uniformBuffer: UniformBuffer;
  17263. /** @hidden */
  17264. _indexInSceneMaterialArray: number;
  17265. /** @hidden */
  17266. meshMap: Nullable<{
  17267. [id: string]: AbstractMesh | undefined;
  17268. }>;
  17269. /**
  17270. * Creates a material instance
  17271. * @param name defines the name of the material
  17272. * @param scene defines the scene to reference
  17273. * @param doNotAdd specifies if the material should be added to the scene
  17274. */
  17275. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  17276. /**
  17277. * Returns a string representation of the current material
  17278. * @param fullDetails defines a boolean indicating which levels of logging is desired
  17279. * @returns a string with material information
  17280. */
  17281. toString(fullDetails?: boolean): string;
  17282. /**
  17283. * Gets the class name of the material
  17284. * @returns a string with the class name of the material
  17285. */
  17286. getClassName(): string;
  17287. /**
  17288. * Specifies if updates for the material been locked
  17289. */
  17290. readonly isFrozen: boolean;
  17291. /**
  17292. * Locks updates for the material
  17293. */
  17294. freeze(): void;
  17295. /**
  17296. * Unlocks updates for the material
  17297. */
  17298. unfreeze(): void;
  17299. /**
  17300. * Specifies if the material is ready to be used
  17301. * @param mesh defines the mesh to check
  17302. * @param useInstances specifies if instances should be used
  17303. * @returns a boolean indicating if the material is ready to be used
  17304. */
  17305. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17306. /**
  17307. * Specifies that the submesh is ready to be used
  17308. * @param mesh defines the mesh to check
  17309. * @param subMesh defines which submesh to check
  17310. * @param useInstances specifies that instances should be used
  17311. * @returns a boolean indicating that the submesh is ready or not
  17312. */
  17313. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17314. /**
  17315. * Returns the material effect
  17316. * @returns the effect associated with the material
  17317. */
  17318. getEffect(): Nullable<Effect>;
  17319. /**
  17320. * Returns the current scene
  17321. * @returns a Scene
  17322. */
  17323. getScene(): Scene;
  17324. /**
  17325. * Specifies if the material will require alpha blending
  17326. * @returns a boolean specifying if alpha blending is needed
  17327. */
  17328. needAlphaBlending(): boolean;
  17329. /**
  17330. * Specifies if the mesh will require alpha blending
  17331. * @param mesh defines the mesh to check
  17332. * @returns a boolean specifying if alpha blending is needed for the mesh
  17333. */
  17334. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  17335. /**
  17336. * Specifies if this material should be rendered in alpha test mode
  17337. * @returns a boolean specifying if an alpha test is needed.
  17338. */
  17339. needAlphaTesting(): boolean;
  17340. /**
  17341. * Gets the texture used for the alpha test
  17342. * @returns the texture to use for alpha testing
  17343. */
  17344. getAlphaTestTexture(): Nullable<BaseTexture>;
  17345. /**
  17346. * Marks the material to indicate that it needs to be re-calculated
  17347. */
  17348. markDirty(): void;
  17349. /** @hidden */
  17350. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  17351. /**
  17352. * Binds the material to the mesh
  17353. * @param world defines the world transformation matrix
  17354. * @param mesh defines the mesh to bind the material to
  17355. */
  17356. bind(world: Matrix, mesh?: Mesh): void;
  17357. /**
  17358. * Binds the submesh to the material
  17359. * @param world defines the world transformation matrix
  17360. * @param mesh defines the mesh containing the submesh
  17361. * @param subMesh defines the submesh to bind the material to
  17362. */
  17363. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17364. /**
  17365. * Binds the world matrix to the material
  17366. * @param world defines the world transformation matrix
  17367. */
  17368. bindOnlyWorldMatrix(world: Matrix): void;
  17369. /**
  17370. * Binds the scene's uniform buffer to the effect.
  17371. * @param effect defines the effect to bind to the scene uniform buffer
  17372. * @param sceneUbo defines the uniform buffer storing scene data
  17373. */
  17374. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  17375. /**
  17376. * Binds the view matrix to the effect
  17377. * @param effect defines the effect to bind the view matrix to
  17378. */
  17379. bindView(effect: Effect): void;
  17380. /**
  17381. * Binds the view projection matrix to the effect
  17382. * @param effect defines the effect to bind the view projection matrix to
  17383. */
  17384. bindViewProjection(effect: Effect): void;
  17385. /**
  17386. * Specifies if material alpha testing should be turned on for the mesh
  17387. * @param mesh defines the mesh to check
  17388. */
  17389. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  17390. /**
  17391. * Processes to execute after binding the material to a mesh
  17392. * @param mesh defines the rendered mesh
  17393. */
  17394. protected _afterBind(mesh?: Mesh): void;
  17395. /**
  17396. * Unbinds the material from the mesh
  17397. */
  17398. unbind(): void;
  17399. /**
  17400. * Gets the active textures from the material
  17401. * @returns an array of textures
  17402. */
  17403. getActiveTextures(): BaseTexture[];
  17404. /**
  17405. * Specifies if the material uses a texture
  17406. * @param texture defines the texture to check against the material
  17407. * @returns a boolean specifying if the material uses the texture
  17408. */
  17409. hasTexture(texture: BaseTexture): boolean;
  17410. /**
  17411. * Makes a duplicate of the material, and gives it a new name
  17412. * @param name defines the new name for the duplicated material
  17413. * @returns the cloned material
  17414. */
  17415. clone(name: string): Nullable<Material>;
  17416. /**
  17417. * Gets the meshes bound to the material
  17418. * @returns an array of meshes bound to the material
  17419. */
  17420. getBindedMeshes(): AbstractMesh[];
  17421. /**
  17422. * Force shader compilation
  17423. * @param mesh defines the mesh associated with this material
  17424. * @param onCompiled defines a function to execute once the material is compiled
  17425. * @param options defines the options to configure the compilation
  17426. */
  17427. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  17428. clipPlane: boolean;
  17429. }>): void;
  17430. /**
  17431. * Force shader compilation
  17432. * @param mesh defines the mesh that will use this material
  17433. * @param options defines additional options for compiling the shaders
  17434. * @returns a promise that resolves when the compilation completes
  17435. */
  17436. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  17437. clipPlane: boolean;
  17438. }>): Promise<void>;
  17439. private static readonly _ImageProcessingDirtyCallBack;
  17440. private static readonly _TextureDirtyCallBack;
  17441. private static readonly _FresnelDirtyCallBack;
  17442. private static readonly _MiscDirtyCallBack;
  17443. private static readonly _LightsDirtyCallBack;
  17444. private static readonly _AttributeDirtyCallBack;
  17445. private static _FresnelAndMiscDirtyCallBack;
  17446. private static _TextureAndMiscDirtyCallBack;
  17447. private static readonly _DirtyCallbackArray;
  17448. private static readonly _RunDirtyCallBacks;
  17449. /**
  17450. * Marks a define in the material to indicate that it needs to be re-computed
  17451. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  17452. */
  17453. markAsDirty(flag: number): void;
  17454. /**
  17455. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  17456. * @param func defines a function which checks material defines against the submeshes
  17457. */
  17458. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  17459. /**
  17460. * Indicates that image processing needs to be re-calculated for all submeshes
  17461. */
  17462. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  17463. /**
  17464. * Indicates that textures need to be re-calculated for all submeshes
  17465. */
  17466. protected _markAllSubMeshesAsTexturesDirty(): void;
  17467. /**
  17468. * Indicates that fresnel needs to be re-calculated for all submeshes
  17469. */
  17470. protected _markAllSubMeshesAsFresnelDirty(): void;
  17471. /**
  17472. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  17473. */
  17474. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  17475. /**
  17476. * Indicates that lights need to be re-calculated for all submeshes
  17477. */
  17478. protected _markAllSubMeshesAsLightsDirty(): void;
  17479. /**
  17480. * Indicates that attributes need to be re-calculated for all submeshes
  17481. */
  17482. protected _markAllSubMeshesAsAttributesDirty(): void;
  17483. /**
  17484. * Indicates that misc needs to be re-calculated for all submeshes
  17485. */
  17486. protected _markAllSubMeshesAsMiscDirty(): void;
  17487. /**
  17488. * Indicates that textures and misc need to be re-calculated for all submeshes
  17489. */
  17490. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  17491. /**
  17492. * Disposes the material
  17493. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17494. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17495. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17496. */
  17497. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17498. /** @hidden */
  17499. private releaseVertexArrayObject;
  17500. /**
  17501. * Serializes this material
  17502. * @returns the serialized material object
  17503. */
  17504. serialize(): any;
  17505. /**
  17506. * Creates a material from parsed material data
  17507. * @param parsedMaterial defines parsed material data
  17508. * @param scene defines the hosting scene
  17509. * @param rootUrl defines the root URL to use to load textures
  17510. * @returns a new material
  17511. */
  17512. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  17513. }
  17514. }
  17515. declare module "babylonjs/Loading/sceneLoaderFlags" {
  17516. /**
  17517. * Class used to represent data loading progression
  17518. */
  17519. export class SceneLoaderFlags {
  17520. private static _ForceFullSceneLoadingForIncremental;
  17521. private static _ShowLoadingScreen;
  17522. private static _CleanBoneMatrixWeights;
  17523. private static _loggingLevel;
  17524. /**
  17525. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  17526. */
  17527. static ForceFullSceneLoadingForIncremental: boolean;
  17528. /**
  17529. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  17530. */
  17531. static ShowLoadingScreen: boolean;
  17532. /**
  17533. * Defines the current logging level (while loading the scene)
  17534. * @ignorenaming
  17535. */
  17536. static loggingLevel: number;
  17537. /**
  17538. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  17539. */
  17540. static CleanBoneMatrixWeights: boolean;
  17541. }
  17542. }
  17543. declare module "babylonjs/Animations/animationPropertiesOverride" {
  17544. /**
  17545. * Class used to override all child animations of a given target
  17546. */
  17547. export class AnimationPropertiesOverride {
  17548. /**
  17549. * Gets or sets a value indicating if animation blending must be used
  17550. */
  17551. enableBlending: boolean;
  17552. /**
  17553. * Gets or sets the blending speed to use when enableBlending is true
  17554. */
  17555. blendingSpeed: number;
  17556. /**
  17557. * Gets or sets the default loop mode to use
  17558. */
  17559. loopMode: number;
  17560. }
  17561. }
  17562. declare module "babylonjs/Morph/morphTarget" {
  17563. import { IAnimatable } from "babylonjs/Misc/tools";
  17564. import { Observable } from "babylonjs/Misc/observable";
  17565. import { Nullable, FloatArray } from "babylonjs/types";
  17566. import { Scene } from "babylonjs/scene";
  17567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17568. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  17569. /**
  17570. * Defines a target to use with MorphTargetManager
  17571. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17572. */
  17573. export class MorphTarget implements IAnimatable {
  17574. /** defines the name of the target */
  17575. name: string;
  17576. /**
  17577. * Gets or sets the list of animations
  17578. */
  17579. animations: import("babylonjs/Animations/animation").Animation[];
  17580. private _scene;
  17581. private _positions;
  17582. private _normals;
  17583. private _tangents;
  17584. private _influence;
  17585. /**
  17586. * Observable raised when the influence changes
  17587. */
  17588. onInfluenceChanged: Observable<boolean>;
  17589. /** @hidden */
  17590. _onDataLayoutChanged: Observable<void>;
  17591. /**
  17592. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  17593. */
  17594. influence: number;
  17595. /**
  17596. * Gets or sets the id of the morph Target
  17597. */
  17598. id: string;
  17599. private _animationPropertiesOverride;
  17600. /**
  17601. * Gets or sets the animation properties override
  17602. */
  17603. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  17604. /**
  17605. * Creates a new MorphTarget
  17606. * @param name defines the name of the target
  17607. * @param influence defines the influence to use
  17608. * @param scene defines the scene the morphtarget belongs to
  17609. */
  17610. constructor(
  17611. /** defines the name of the target */
  17612. name: string, influence?: number, scene?: Nullable<Scene>);
  17613. /**
  17614. * Gets a boolean defining if the target contains position data
  17615. */
  17616. readonly hasPositions: boolean;
  17617. /**
  17618. * Gets a boolean defining if the target contains normal data
  17619. */
  17620. readonly hasNormals: boolean;
  17621. /**
  17622. * Gets a boolean defining if the target contains tangent data
  17623. */
  17624. readonly hasTangents: boolean;
  17625. /**
  17626. * Affects position data to this target
  17627. * @param data defines the position data to use
  17628. */
  17629. setPositions(data: Nullable<FloatArray>): void;
  17630. /**
  17631. * Gets the position data stored in this target
  17632. * @returns a FloatArray containing the position data (or null if not present)
  17633. */
  17634. getPositions(): Nullable<FloatArray>;
  17635. /**
  17636. * Affects normal data to this target
  17637. * @param data defines the normal data to use
  17638. */
  17639. setNormals(data: Nullable<FloatArray>): void;
  17640. /**
  17641. * Gets the normal data stored in this target
  17642. * @returns a FloatArray containing the normal data (or null if not present)
  17643. */
  17644. getNormals(): Nullable<FloatArray>;
  17645. /**
  17646. * Affects tangent data to this target
  17647. * @param data defines the tangent data to use
  17648. */
  17649. setTangents(data: Nullable<FloatArray>): void;
  17650. /**
  17651. * Gets the tangent data stored in this target
  17652. * @returns a FloatArray containing the tangent data (or null if not present)
  17653. */
  17654. getTangents(): Nullable<FloatArray>;
  17655. /**
  17656. * Serializes the current target into a Serialization object
  17657. * @returns the serialized object
  17658. */
  17659. serialize(): any;
  17660. /**
  17661. * Returns the string "MorphTarget"
  17662. * @returns "MorphTarget"
  17663. */
  17664. getClassName(): string;
  17665. /**
  17666. * Creates a new target from serialized data
  17667. * @param serializationObject defines the serialized data to use
  17668. * @returns a new MorphTarget
  17669. */
  17670. static Parse(serializationObject: any): MorphTarget;
  17671. /**
  17672. * Creates a MorphTarget from mesh data
  17673. * @param mesh defines the source mesh
  17674. * @param name defines the name to use for the new target
  17675. * @param influence defines the influence to attach to the target
  17676. * @returns a new MorphTarget
  17677. */
  17678. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  17679. }
  17680. }
  17681. declare module "babylonjs/Morph/morphTargetManager" {
  17682. import { Nullable } from "babylonjs/types";
  17683. import { Scene } from "babylonjs/scene";
  17684. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  17685. /**
  17686. * This class is used to deform meshes using morphing between different targets
  17687. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  17688. */
  17689. export class MorphTargetManager {
  17690. private _targets;
  17691. private _targetInfluenceChangedObservers;
  17692. private _targetDataLayoutChangedObservers;
  17693. private _activeTargets;
  17694. private _scene;
  17695. private _influences;
  17696. private _supportsNormals;
  17697. private _supportsTangents;
  17698. private _vertexCount;
  17699. private _uniqueId;
  17700. private _tempInfluences;
  17701. /**
  17702. * Creates a new MorphTargetManager
  17703. * @param scene defines the current scene
  17704. */
  17705. constructor(scene?: Nullable<Scene>);
  17706. /**
  17707. * Gets the unique ID of this manager
  17708. */
  17709. readonly uniqueId: number;
  17710. /**
  17711. * Gets the number of vertices handled by this manager
  17712. */
  17713. readonly vertexCount: number;
  17714. /**
  17715. * Gets a boolean indicating if this manager supports morphing of normals
  17716. */
  17717. readonly supportsNormals: boolean;
  17718. /**
  17719. * Gets a boolean indicating if this manager supports morphing of tangents
  17720. */
  17721. readonly supportsTangents: boolean;
  17722. /**
  17723. * Gets the number of targets stored in this manager
  17724. */
  17725. readonly numTargets: number;
  17726. /**
  17727. * Gets the number of influencers (ie. the number of targets with influences > 0)
  17728. */
  17729. readonly numInfluencers: number;
  17730. /**
  17731. * Gets the list of influences (one per target)
  17732. */
  17733. readonly influences: Float32Array;
  17734. /**
  17735. * Gets the active target at specified index. An active target is a target with an influence > 0
  17736. * @param index defines the index to check
  17737. * @returns the requested target
  17738. */
  17739. getActiveTarget(index: number): MorphTarget;
  17740. /**
  17741. * Gets the target at specified index
  17742. * @param index defines the index to check
  17743. * @returns the requested target
  17744. */
  17745. getTarget(index: number): MorphTarget;
  17746. /**
  17747. * Add a new target to this manager
  17748. * @param target defines the target to add
  17749. */
  17750. addTarget(target: MorphTarget): void;
  17751. /**
  17752. * Removes a target from the manager
  17753. * @param target defines the target to remove
  17754. */
  17755. removeTarget(target: MorphTarget): void;
  17756. /**
  17757. * Serializes the current manager into a Serialization object
  17758. * @returns the serialized object
  17759. */
  17760. serialize(): any;
  17761. private _syncActiveTargets;
  17762. /**
  17763. * Syncrhonize the targets with all the meshes using this morph target manager
  17764. */
  17765. synchronize(): void;
  17766. /**
  17767. * Creates a new MorphTargetManager from serialized data
  17768. * @param serializationObject defines the serialized data
  17769. * @param scene defines the hosting scene
  17770. * @returns the new MorphTargetManager
  17771. */
  17772. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  17773. }
  17774. }
  17775. declare module "babylonjs/Physics/physicsJoint" {
  17776. import { Vector3 } from "babylonjs/Maths/math";
  17777. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  17778. /**
  17779. * Interface for Physics-Joint data
  17780. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17781. */
  17782. export interface PhysicsJointData {
  17783. /**
  17784. * The main pivot of the joint
  17785. */
  17786. mainPivot?: Vector3;
  17787. /**
  17788. * The connected pivot of the joint
  17789. */
  17790. connectedPivot?: Vector3;
  17791. /**
  17792. * The main axis of the joint
  17793. */
  17794. mainAxis?: Vector3;
  17795. /**
  17796. * The connected axis of the joint
  17797. */
  17798. connectedAxis?: Vector3;
  17799. /**
  17800. * The collision of the joint
  17801. */
  17802. collision?: boolean;
  17803. /**
  17804. * Native Oimo/Cannon/Energy data
  17805. */
  17806. nativeParams?: any;
  17807. }
  17808. /**
  17809. * This is a holder class for the physics joint created by the physics plugin
  17810. * It holds a set of functions to control the underlying joint
  17811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17812. */
  17813. export class PhysicsJoint {
  17814. /**
  17815. * The type of the physics joint
  17816. */
  17817. type: number;
  17818. /**
  17819. * The data for the physics joint
  17820. */
  17821. jointData: PhysicsJointData;
  17822. private _physicsJoint;
  17823. protected _physicsPlugin: IPhysicsEnginePlugin;
  17824. /**
  17825. * Initializes the physics joint
  17826. * @param type The type of the physics joint
  17827. * @param jointData The data for the physics joint
  17828. */
  17829. constructor(
  17830. /**
  17831. * The type of the physics joint
  17832. */
  17833. type: number,
  17834. /**
  17835. * The data for the physics joint
  17836. */
  17837. jointData: PhysicsJointData);
  17838. /**
  17839. * Gets the physics joint
  17840. */
  17841. /**
  17842. * Sets the physics joint
  17843. */
  17844. physicsJoint: any;
  17845. /**
  17846. * Sets the physics plugin
  17847. */
  17848. physicsPlugin: IPhysicsEnginePlugin;
  17849. /**
  17850. * Execute a function that is physics-plugin specific.
  17851. * @param {Function} func the function that will be executed.
  17852. * It accepts two parameters: the physics world and the physics joint
  17853. */
  17854. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  17855. /**
  17856. * Distance-Joint type
  17857. */
  17858. static DistanceJoint: number;
  17859. /**
  17860. * Hinge-Joint type
  17861. */
  17862. static HingeJoint: number;
  17863. /**
  17864. * Ball-and-Socket joint type
  17865. */
  17866. static BallAndSocketJoint: number;
  17867. /**
  17868. * Wheel-Joint type
  17869. */
  17870. static WheelJoint: number;
  17871. /**
  17872. * Slider-Joint type
  17873. */
  17874. static SliderJoint: number;
  17875. /**
  17876. * Prismatic-Joint type
  17877. */
  17878. static PrismaticJoint: number;
  17879. /**
  17880. * Universal-Joint type
  17881. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  17882. */
  17883. static UniversalJoint: number;
  17884. /**
  17885. * Hinge-Joint 2 type
  17886. */
  17887. static Hinge2Joint: number;
  17888. /**
  17889. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  17890. */
  17891. static PointToPointJoint: number;
  17892. /**
  17893. * Spring-Joint type
  17894. */
  17895. static SpringJoint: number;
  17896. /**
  17897. * Lock-Joint type
  17898. */
  17899. static LockJoint: number;
  17900. }
  17901. /**
  17902. * A class representing a physics distance joint
  17903. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17904. */
  17905. export class DistanceJoint extends PhysicsJoint {
  17906. /**
  17907. *
  17908. * @param jointData The data for the Distance-Joint
  17909. */
  17910. constructor(jointData: DistanceJointData);
  17911. /**
  17912. * Update the predefined distance.
  17913. * @param maxDistance The maximum preferred distance
  17914. * @param minDistance The minimum preferred distance
  17915. */
  17916. updateDistance(maxDistance: number, minDistance?: number): void;
  17917. }
  17918. /**
  17919. * Represents a Motor-Enabled Joint
  17920. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17921. */
  17922. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  17923. /**
  17924. * Initializes the Motor-Enabled Joint
  17925. * @param type The type of the joint
  17926. * @param jointData The physica joint data for the joint
  17927. */
  17928. constructor(type: number, jointData: PhysicsJointData);
  17929. /**
  17930. * Set the motor values.
  17931. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17932. * @param force the force to apply
  17933. * @param maxForce max force for this motor.
  17934. */
  17935. setMotor(force?: number, maxForce?: number): void;
  17936. /**
  17937. * Set the motor's limits.
  17938. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17939. * @param upperLimit The upper limit of the motor
  17940. * @param lowerLimit The lower limit of the motor
  17941. */
  17942. setLimit(upperLimit: number, lowerLimit?: number): void;
  17943. }
  17944. /**
  17945. * This class represents a single physics Hinge-Joint
  17946. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17947. */
  17948. export class HingeJoint extends MotorEnabledJoint {
  17949. /**
  17950. * Initializes the Hinge-Joint
  17951. * @param jointData The joint data for the Hinge-Joint
  17952. */
  17953. constructor(jointData: PhysicsJointData);
  17954. /**
  17955. * Set the motor values.
  17956. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17957. * @param {number} force the force to apply
  17958. * @param {number} maxForce max force for this motor.
  17959. */
  17960. setMotor(force?: number, maxForce?: number): void;
  17961. /**
  17962. * Set the motor's limits.
  17963. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17964. * @param upperLimit The upper limit of the motor
  17965. * @param lowerLimit The lower limit of the motor
  17966. */
  17967. setLimit(upperLimit: number, lowerLimit?: number): void;
  17968. }
  17969. /**
  17970. * This class represents a dual hinge physics joint (same as wheel joint)
  17971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17972. */
  17973. export class Hinge2Joint extends MotorEnabledJoint {
  17974. /**
  17975. * Initializes the Hinge2-Joint
  17976. * @param jointData The joint data for the Hinge2-Joint
  17977. */
  17978. constructor(jointData: PhysicsJointData);
  17979. /**
  17980. * Set the motor values.
  17981. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17982. * @param {number} force the force to apply
  17983. * @param {number} maxForce max force for this motor.
  17984. * @param {motorIndex} the motor's index, 0 or 1.
  17985. */
  17986. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  17987. /**
  17988. * Set the motor limits.
  17989. * Attention, this function is plugin specific. Engines won't react 100% the same.
  17990. * @param {number} upperLimit the upper limit
  17991. * @param {number} lowerLimit lower limit
  17992. * @param {motorIndex} the motor's index, 0 or 1.
  17993. */
  17994. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  17995. }
  17996. /**
  17997. * Interface for a motor enabled joint
  17998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  17999. */
  18000. export interface IMotorEnabledJoint {
  18001. /**
  18002. * Physics joint
  18003. */
  18004. physicsJoint: any;
  18005. /**
  18006. * Sets the motor of the motor-enabled joint
  18007. * @param force The force of the motor
  18008. * @param maxForce The maximum force of the motor
  18009. * @param motorIndex The index of the motor
  18010. */
  18011. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  18012. /**
  18013. * Sets the limit of the motor
  18014. * @param upperLimit The upper limit of the motor
  18015. * @param lowerLimit The lower limit of the motor
  18016. * @param motorIndex The index of the motor
  18017. */
  18018. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18019. }
  18020. /**
  18021. * Joint data for a Distance-Joint
  18022. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18023. */
  18024. export interface DistanceJointData extends PhysicsJointData {
  18025. /**
  18026. * Max distance the 2 joint objects can be apart
  18027. */
  18028. maxDistance: number;
  18029. }
  18030. /**
  18031. * Joint data from a spring joint
  18032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18033. */
  18034. export interface SpringJointData extends PhysicsJointData {
  18035. /**
  18036. * Length of the spring
  18037. */
  18038. length: number;
  18039. /**
  18040. * Stiffness of the spring
  18041. */
  18042. stiffness: number;
  18043. /**
  18044. * Damping of the spring
  18045. */
  18046. damping: number;
  18047. /** this callback will be called when applying the force to the impostors. */
  18048. forceApplicationCallback: () => void;
  18049. }
  18050. }
  18051. declare module "babylonjs/Physics/IPhysicsEngine" {
  18052. import { Nullable } from "babylonjs/types";
  18053. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  18054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18055. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  18056. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  18057. /**
  18058. * Interface used to describe a physics joint
  18059. */
  18060. export interface PhysicsImpostorJoint {
  18061. /** Defines the main impostor to which the joint is linked */
  18062. mainImpostor: PhysicsImpostor;
  18063. /** Defines the impostor that is connected to the main impostor using this joint */
  18064. connectedImpostor: PhysicsImpostor;
  18065. /** Defines the joint itself */
  18066. joint: PhysicsJoint;
  18067. }
  18068. /** @hidden */
  18069. export interface IPhysicsEnginePlugin {
  18070. world: any;
  18071. name: string;
  18072. setGravity(gravity: Vector3): void;
  18073. setTimeStep(timeStep: number): void;
  18074. getTimeStep(): number;
  18075. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  18076. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18077. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  18078. generatePhysicsBody(impostor: PhysicsImpostor): void;
  18079. removePhysicsBody(impostor: PhysicsImpostor): void;
  18080. generateJoint(joint: PhysicsImpostorJoint): void;
  18081. removeJoint(joint: PhysicsImpostorJoint): void;
  18082. isSupported(): boolean;
  18083. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  18084. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  18085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18086. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  18087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  18089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  18090. getBodyMass(impostor: PhysicsImpostor): number;
  18091. getBodyFriction(impostor: PhysicsImpostor): number;
  18092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  18093. getBodyRestitution(impostor: PhysicsImpostor): number;
  18094. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  18095. sleepBody(impostor: PhysicsImpostor): void;
  18096. wakeUpBody(impostor: PhysicsImpostor): void;
  18097. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  18098. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  18099. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  18100. getRadius(impostor: PhysicsImpostor): number;
  18101. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  18102. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  18103. dispose(): void;
  18104. }
  18105. /**
  18106. * Interface used to define a physics engine
  18107. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  18108. */
  18109. export interface IPhysicsEngine {
  18110. /**
  18111. * Gets the gravity vector used by the simulation
  18112. */
  18113. gravity: Vector3;
  18114. /**
  18115. * Sets the gravity vector used by the simulation
  18116. * @param gravity defines the gravity vector to use
  18117. */
  18118. setGravity(gravity: Vector3): void;
  18119. /**
  18120. * Set the time step of the physics engine.
  18121. * Default is 1/60.
  18122. * To slow it down, enter 1/600 for example.
  18123. * To speed it up, 1/30
  18124. * @param newTimeStep the new timestep to apply to this world.
  18125. */
  18126. setTimeStep(newTimeStep: number): void;
  18127. /**
  18128. * Get the time step of the physics engine.
  18129. * @returns the current time step
  18130. */
  18131. getTimeStep(): number;
  18132. /**
  18133. * Release all resources
  18134. */
  18135. dispose(): void;
  18136. /**
  18137. * Gets the name of the current physics plugin
  18138. * @returns the name of the plugin
  18139. */
  18140. getPhysicsPluginName(): string;
  18141. /**
  18142. * Adding a new impostor for the impostor tracking.
  18143. * This will be done by the impostor itself.
  18144. * @param impostor the impostor to add
  18145. */
  18146. addImpostor(impostor: PhysicsImpostor): void;
  18147. /**
  18148. * Remove an impostor from the engine.
  18149. * This impostor and its mesh will not longer be updated by the physics engine.
  18150. * @param impostor the impostor to remove
  18151. */
  18152. removeImpostor(impostor: PhysicsImpostor): void;
  18153. /**
  18154. * Add a joint to the physics engine
  18155. * @param mainImpostor defines the main impostor to which the joint is added.
  18156. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  18157. * @param joint defines the joint that will connect both impostors.
  18158. */
  18159. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18160. /**
  18161. * Removes a joint from the simulation
  18162. * @param mainImpostor defines the impostor used with the joint
  18163. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  18164. * @param joint defines the joint to remove
  18165. */
  18166. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  18167. /**
  18168. * Gets the current plugin used to run the simulation
  18169. * @returns current plugin
  18170. */
  18171. getPhysicsPlugin(): IPhysicsEnginePlugin;
  18172. /**
  18173. * Gets the list of physic impostors
  18174. * @returns an array of PhysicsImpostor
  18175. */
  18176. getImpostors(): Array<PhysicsImpostor>;
  18177. /**
  18178. * Gets the impostor for a physics enabled object
  18179. * @param object defines the object impersonated by the impostor
  18180. * @returns the PhysicsImpostor or null if not found
  18181. */
  18182. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18183. /**
  18184. * Gets the impostor for a physics body object
  18185. * @param body defines physics body used by the impostor
  18186. * @returns the PhysicsImpostor or null if not found
  18187. */
  18188. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  18189. /**
  18190. * Called by the scene. No need to call it.
  18191. * @param delta defines the timespam between frames
  18192. */
  18193. _step(delta: number): void;
  18194. }
  18195. }
  18196. declare module "babylonjs/Physics/physicsImpostor" {
  18197. import { Nullable, IndicesArray } from "babylonjs/types";
  18198. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  18199. import { TransformNode } from "babylonjs/Meshes/transformNode";
  18200. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18201. import { Scene } from "babylonjs/scene";
  18202. import { Bone } from "babylonjs/Bones/bone";
  18203. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  18204. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  18205. /**
  18206. * The interface for the physics imposter parameters
  18207. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18208. */
  18209. export interface PhysicsImpostorParameters {
  18210. /**
  18211. * The mass of the physics imposter
  18212. */
  18213. mass: number;
  18214. /**
  18215. * The friction of the physics imposter
  18216. */
  18217. friction?: number;
  18218. /**
  18219. * The coefficient of restitution of the physics imposter
  18220. */
  18221. restitution?: number;
  18222. /**
  18223. * The native options of the physics imposter
  18224. */
  18225. nativeOptions?: any;
  18226. /**
  18227. * Specifies if the parent should be ignored
  18228. */
  18229. ignoreParent?: boolean;
  18230. /**
  18231. * Specifies if bi-directional transformations should be disabled
  18232. */
  18233. disableBidirectionalTransformation?: boolean;
  18234. }
  18235. /**
  18236. * Interface for a physics-enabled object
  18237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18238. */
  18239. export interface IPhysicsEnabledObject {
  18240. /**
  18241. * The position of the physics-enabled object
  18242. */
  18243. position: Vector3;
  18244. /**
  18245. * The rotation of the physics-enabled object
  18246. */
  18247. rotationQuaternion: Nullable<Quaternion>;
  18248. /**
  18249. * The scale of the physics-enabled object
  18250. */
  18251. scaling: Vector3;
  18252. /**
  18253. * The rotation of the physics-enabled object
  18254. */
  18255. rotation?: Vector3;
  18256. /**
  18257. * The parent of the physics-enabled object
  18258. */
  18259. parent?: any;
  18260. /**
  18261. * The bounding info of the physics-enabled object
  18262. * @returns The bounding info of the physics-enabled object
  18263. */
  18264. getBoundingInfo(): BoundingInfo;
  18265. /**
  18266. * Computes the world matrix
  18267. * @param force Specifies if the world matrix should be computed by force
  18268. * @returns A world matrix
  18269. */
  18270. computeWorldMatrix(force: boolean): Matrix;
  18271. /**
  18272. * Gets the world matrix
  18273. * @returns A world matrix
  18274. */
  18275. getWorldMatrix?(): Matrix;
  18276. /**
  18277. * Gets the child meshes
  18278. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  18279. * @returns An array of abstract meshes
  18280. */
  18281. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  18282. /**
  18283. * Gets the vertex data
  18284. * @param kind The type of vertex data
  18285. * @returns A nullable array of numbers, or a float32 array
  18286. */
  18287. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  18288. /**
  18289. * Gets the indices from the mesh
  18290. * @returns A nullable array of index arrays
  18291. */
  18292. getIndices?(): Nullable<IndicesArray>;
  18293. /**
  18294. * Gets the scene from the mesh
  18295. * @returns the indices array or null
  18296. */
  18297. getScene?(): Scene;
  18298. /**
  18299. * Gets the absolute position from the mesh
  18300. * @returns the absolute position
  18301. */
  18302. getAbsolutePosition(): Vector3;
  18303. /**
  18304. * Gets the absolute pivot point from the mesh
  18305. * @returns the absolute pivot point
  18306. */
  18307. getAbsolutePivotPoint(): Vector3;
  18308. /**
  18309. * Rotates the mesh
  18310. * @param axis The axis of rotation
  18311. * @param amount The amount of rotation
  18312. * @param space The space of the rotation
  18313. * @returns The rotation transform node
  18314. */
  18315. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  18316. /**
  18317. * Translates the mesh
  18318. * @param axis The axis of translation
  18319. * @param distance The distance of translation
  18320. * @param space The space of the translation
  18321. * @returns The transform node
  18322. */
  18323. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  18324. /**
  18325. * Sets the absolute position of the mesh
  18326. * @param absolutePosition The absolute position of the mesh
  18327. * @returns The transform node
  18328. */
  18329. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  18330. /**
  18331. * Gets the class name of the mesh
  18332. * @returns The class name
  18333. */
  18334. getClassName(): string;
  18335. }
  18336. /**
  18337. * Represents a physics imposter
  18338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18339. */
  18340. export class PhysicsImpostor {
  18341. /**
  18342. * The physics-enabled object used as the physics imposter
  18343. */
  18344. object: IPhysicsEnabledObject;
  18345. /**
  18346. * The type of the physics imposter
  18347. */
  18348. type: number;
  18349. private _options;
  18350. private _scene?;
  18351. /**
  18352. * The default object size of the imposter
  18353. */
  18354. static DEFAULT_OBJECT_SIZE: Vector3;
  18355. /**
  18356. * The identity quaternion of the imposter
  18357. */
  18358. static IDENTITY_QUATERNION: Quaternion;
  18359. /** @hidden */
  18360. _pluginData: any;
  18361. private _physicsEngine;
  18362. private _physicsBody;
  18363. private _bodyUpdateRequired;
  18364. private _onBeforePhysicsStepCallbacks;
  18365. private _onAfterPhysicsStepCallbacks;
  18366. /** @hidden */
  18367. _onPhysicsCollideCallbacks: Array<{
  18368. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  18369. otherImpostors: Array<PhysicsImpostor>;
  18370. }>;
  18371. private _deltaPosition;
  18372. private _deltaRotation;
  18373. private _deltaRotationConjugated;
  18374. private _parent;
  18375. private _isDisposed;
  18376. private static _tmpVecs;
  18377. private static _tmpQuat;
  18378. /**
  18379. * Specifies if the physics imposter is disposed
  18380. */
  18381. readonly isDisposed: boolean;
  18382. /**
  18383. * Gets the mass of the physics imposter
  18384. */
  18385. mass: number;
  18386. /**
  18387. * Gets the coefficient of friction
  18388. */
  18389. /**
  18390. * Sets the coefficient of friction
  18391. */
  18392. friction: number;
  18393. /**
  18394. * Gets the coefficient of restitution
  18395. */
  18396. /**
  18397. * Sets the coefficient of restitution
  18398. */
  18399. restitution: number;
  18400. /**
  18401. * The unique id of the physics imposter
  18402. * set by the physics engine when adding this impostor to the array
  18403. */
  18404. uniqueId: number;
  18405. private _joints;
  18406. /**
  18407. * Initializes the physics imposter
  18408. * @param object The physics-enabled object used as the physics imposter
  18409. * @param type The type of the physics imposter
  18410. * @param _options The options for the physics imposter
  18411. * @param _scene The Babylon scene
  18412. */
  18413. constructor(
  18414. /**
  18415. * The physics-enabled object used as the physics imposter
  18416. */
  18417. object: IPhysicsEnabledObject,
  18418. /**
  18419. * The type of the physics imposter
  18420. */
  18421. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  18422. /**
  18423. * This function will completly initialize this impostor.
  18424. * It will create a new body - but only if this mesh has no parent.
  18425. * If it has, this impostor will not be used other than to define the impostor
  18426. * of the child mesh.
  18427. * @hidden
  18428. */
  18429. _init(): void;
  18430. private _getPhysicsParent;
  18431. /**
  18432. * Should a new body be generated.
  18433. * @returns boolean specifying if body initialization is required
  18434. */
  18435. isBodyInitRequired(): boolean;
  18436. /**
  18437. * Sets the updated scaling
  18438. * @param updated Specifies if the scaling is updated
  18439. */
  18440. setScalingUpdated(): void;
  18441. /**
  18442. * Force a regeneration of this or the parent's impostor's body.
  18443. * Use under cautious - This will remove all joints already implemented.
  18444. */
  18445. forceUpdate(): void;
  18446. /**
  18447. * Gets the body that holds this impostor. Either its own, or its parent.
  18448. */
  18449. /**
  18450. * Set the physics body. Used mainly by the physics engine/plugin
  18451. */
  18452. physicsBody: any;
  18453. /**
  18454. * Get the parent of the physics imposter
  18455. * @returns Physics imposter or null
  18456. */
  18457. /**
  18458. * Sets the parent of the physics imposter
  18459. */
  18460. parent: Nullable<PhysicsImpostor>;
  18461. /**
  18462. * Resets the update flags
  18463. */
  18464. resetUpdateFlags(): void;
  18465. /**
  18466. * Gets the object extend size
  18467. * @returns the object extend size
  18468. */
  18469. getObjectExtendSize(): Vector3;
  18470. /**
  18471. * Gets the object center
  18472. * @returns The object center
  18473. */
  18474. getObjectCenter(): Vector3;
  18475. /**
  18476. * Get a specific parametes from the options parameter
  18477. * @param paramName The object parameter name
  18478. * @returns The object parameter
  18479. */
  18480. getParam(paramName: string): any;
  18481. /**
  18482. * Sets a specific parameter in the options given to the physics plugin
  18483. * @param paramName The parameter name
  18484. * @param value The value of the parameter
  18485. */
  18486. setParam(paramName: string, value: number): void;
  18487. /**
  18488. * Specifically change the body's mass option. Won't recreate the physics body object
  18489. * @param mass The mass of the physics imposter
  18490. */
  18491. setMass(mass: number): void;
  18492. /**
  18493. * Gets the linear velocity
  18494. * @returns linear velocity or null
  18495. */
  18496. getLinearVelocity(): Nullable<Vector3>;
  18497. /**
  18498. * Sets the linear velocity
  18499. * @param velocity linear velocity or null
  18500. */
  18501. setLinearVelocity(velocity: Nullable<Vector3>): void;
  18502. /**
  18503. * Gets the angular velocity
  18504. * @returns angular velocity or null
  18505. */
  18506. getAngularVelocity(): Nullable<Vector3>;
  18507. /**
  18508. * Sets the angular velocity
  18509. * @param velocity The velocity or null
  18510. */
  18511. setAngularVelocity(velocity: Nullable<Vector3>): void;
  18512. /**
  18513. * Execute a function with the physics plugin native code
  18514. * Provide a function the will have two variables - the world object and the physics body object
  18515. * @param func The function to execute with the physics plugin native code
  18516. */
  18517. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  18518. /**
  18519. * Register a function that will be executed before the physics world is stepping forward
  18520. * @param func The function to execute before the physics world is stepped forward
  18521. */
  18522. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18523. /**
  18524. * Unregister a function that will be executed before the physics world is stepping forward
  18525. * @param func The function to execute before the physics world is stepped forward
  18526. */
  18527. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18528. /**
  18529. * Register a function that will be executed after the physics step
  18530. * @param func The function to execute after physics step
  18531. */
  18532. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18533. /**
  18534. * Unregisters a function that will be executed after the physics step
  18535. * @param func The function to execute after physics step
  18536. */
  18537. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  18538. /**
  18539. * register a function that will be executed when this impostor collides against a different body
  18540. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  18541. * @param func Callback that is executed on collision
  18542. */
  18543. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  18544. /**
  18545. * Unregisters the physics imposter on contact
  18546. * @param collideAgainst The physics object to collide against
  18547. * @param func Callback to execute on collision
  18548. */
  18549. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  18550. private _tmpQuat;
  18551. private _tmpQuat2;
  18552. /**
  18553. * Get the parent rotation
  18554. * @returns The parent rotation
  18555. */
  18556. getParentsRotation(): Quaternion;
  18557. /**
  18558. * this function is executed by the physics engine.
  18559. */
  18560. beforeStep: () => void;
  18561. /**
  18562. * this function is executed by the physics engine
  18563. */
  18564. afterStep: () => void;
  18565. /**
  18566. * Legacy collision detection event support
  18567. */
  18568. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  18569. /**
  18570. * event and body object due to cannon's event-based architecture.
  18571. */
  18572. onCollide: (e: {
  18573. body: any;
  18574. }) => void;
  18575. /**
  18576. * Apply a force
  18577. * @param force The force to apply
  18578. * @param contactPoint The contact point for the force
  18579. * @returns The physics imposter
  18580. */
  18581. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18582. /**
  18583. * Apply an impulse
  18584. * @param force The impulse force
  18585. * @param contactPoint The contact point for the impulse force
  18586. * @returns The physics imposter
  18587. */
  18588. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  18589. /**
  18590. * A help function to create a joint
  18591. * @param otherImpostor A physics imposter used to create a joint
  18592. * @param jointType The type of joint
  18593. * @param jointData The data for the joint
  18594. * @returns The physics imposter
  18595. */
  18596. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  18597. /**
  18598. * Add a joint to this impostor with a different impostor
  18599. * @param otherImpostor A physics imposter used to add a joint
  18600. * @param joint The joint to add
  18601. * @returns The physics imposter
  18602. */
  18603. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  18604. /**
  18605. * Will keep this body still, in a sleep mode.
  18606. * @returns the physics imposter
  18607. */
  18608. sleep(): PhysicsImpostor;
  18609. /**
  18610. * Wake the body up.
  18611. * @returns The physics imposter
  18612. */
  18613. wakeUp(): PhysicsImpostor;
  18614. /**
  18615. * Clones the physics imposter
  18616. * @param newObject The physics imposter clones to this physics-enabled object
  18617. * @returns A nullable physics imposter
  18618. */
  18619. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  18620. /**
  18621. * Disposes the physics imposter
  18622. */
  18623. dispose(): void;
  18624. /**
  18625. * Sets the delta position
  18626. * @param position The delta position amount
  18627. */
  18628. setDeltaPosition(position: Vector3): void;
  18629. /**
  18630. * Sets the delta rotation
  18631. * @param rotation The delta rotation amount
  18632. */
  18633. setDeltaRotation(rotation: Quaternion): void;
  18634. /**
  18635. * Gets the box size of the physics imposter and stores the result in the input parameter
  18636. * @param result Stores the box size
  18637. * @returns The physics imposter
  18638. */
  18639. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  18640. /**
  18641. * Gets the radius of the physics imposter
  18642. * @returns Radius of the physics imposter
  18643. */
  18644. getRadius(): number;
  18645. /**
  18646. * Sync a bone with this impostor
  18647. * @param bone The bone to sync to the impostor.
  18648. * @param boneMesh The mesh that the bone is influencing.
  18649. * @param jointPivot The pivot of the joint / bone in local space.
  18650. * @param distToJoint Optional distance from the impostor to the joint.
  18651. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18652. */
  18653. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  18654. /**
  18655. * Sync impostor to a bone
  18656. * @param bone The bone that the impostor will be synced to.
  18657. * @param boneMesh The mesh that the bone is influencing.
  18658. * @param jointPivot The pivot of the joint / bone in local space.
  18659. * @param distToJoint Optional distance from the impostor to the joint.
  18660. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  18661. * @param boneAxis Optional vector3 axis the bone is aligned with
  18662. */
  18663. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  18664. /**
  18665. * No-Imposter type
  18666. */
  18667. static NoImpostor: number;
  18668. /**
  18669. * Sphere-Imposter type
  18670. */
  18671. static SphereImpostor: number;
  18672. /**
  18673. * Box-Imposter type
  18674. */
  18675. static BoxImpostor: number;
  18676. /**
  18677. * Plane-Imposter type
  18678. */
  18679. static PlaneImpostor: number;
  18680. /**
  18681. * Mesh-imposter type
  18682. */
  18683. static MeshImpostor: number;
  18684. /**
  18685. * Cylinder-Imposter type
  18686. */
  18687. static CylinderImpostor: number;
  18688. /**
  18689. * Particle-Imposter type
  18690. */
  18691. static ParticleImpostor: number;
  18692. /**
  18693. * Heightmap-Imposter type
  18694. */
  18695. static HeightmapImpostor: number;
  18696. }
  18697. }
  18698. declare module "babylonjs/Meshes/groundMesh" {
  18699. import { Scene } from "babylonjs/scene";
  18700. import { Vector3 } from "babylonjs/Maths/math";
  18701. import { Mesh } from "babylonjs/Meshes/mesh";
  18702. /**
  18703. * Mesh representing the gorund
  18704. */
  18705. export class GroundMesh extends Mesh {
  18706. /** If octree should be generated */
  18707. generateOctree: boolean;
  18708. private _heightQuads;
  18709. /** @hidden */
  18710. _subdivisionsX: number;
  18711. /** @hidden */
  18712. _subdivisionsY: number;
  18713. /** @hidden */
  18714. _width: number;
  18715. /** @hidden */
  18716. _height: number;
  18717. /** @hidden */
  18718. _minX: number;
  18719. /** @hidden */
  18720. _maxX: number;
  18721. /** @hidden */
  18722. _minZ: number;
  18723. /** @hidden */
  18724. _maxZ: number;
  18725. constructor(name: string, scene: Scene);
  18726. /**
  18727. * "GroundMesh"
  18728. * @returns "GroundMesh"
  18729. */
  18730. getClassName(): string;
  18731. /**
  18732. * The minimum of x and y subdivisions
  18733. */
  18734. readonly subdivisions: number;
  18735. /**
  18736. * X subdivisions
  18737. */
  18738. readonly subdivisionsX: number;
  18739. /**
  18740. * Y subdivisions
  18741. */
  18742. readonly subdivisionsY: number;
  18743. /**
  18744. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18745. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18746. * @param chunksCount the number of subdivisions for x and y
  18747. * @param octreeBlocksSize (Default: 32)
  18748. */
  18749. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18750. /**
  18751. * Returns a height (y) value in the Worl system :
  18752. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18753. * @param x x coordinate
  18754. * @param z z coordinate
  18755. * @returns the ground y position if (x, z) are outside the ground surface.
  18756. */
  18757. getHeightAtCoordinates(x: number, z: number): number;
  18758. /**
  18759. * Returns a normalized vector (Vector3) orthogonal to the ground
  18760. * at the ground coordinates (x, z) expressed in the World system.
  18761. * @param x x coordinate
  18762. * @param z z coordinate
  18763. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18764. */
  18765. getNormalAtCoordinates(x: number, z: number): Vector3;
  18766. /**
  18767. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18768. * at the ground coordinates (x, z) expressed in the World system.
  18769. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18770. * @param x x coordinate
  18771. * @param z z coordinate
  18772. * @param ref vector to store the result
  18773. * @returns the GroundMesh.
  18774. */
  18775. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18776. /**
  18777. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18778. * if the ground has been updated.
  18779. * This can be used in the render loop.
  18780. * @returns the GroundMesh.
  18781. */
  18782. updateCoordinateHeights(): GroundMesh;
  18783. private _getFacetAt;
  18784. private _initHeightQuads;
  18785. private _computeHeightQuads;
  18786. /**
  18787. * Serializes this ground mesh
  18788. * @param serializationObject object to write serialization to
  18789. */
  18790. serialize(serializationObject: any): void;
  18791. /**
  18792. * Parses a serialized ground mesh
  18793. * @param parsedMesh the serialized mesh
  18794. * @param scene the scene to create the ground mesh in
  18795. * @returns the created ground mesh
  18796. */
  18797. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18798. }
  18799. }
  18800. declare module "babylonjs/Meshes/mesh" {
  18801. import { Observable } from "babylonjs/Misc/observable";
  18802. import { IAnimatable } from "babylonjs/Misc/tools";
  18803. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  18804. import { Camera } from "babylonjs/Cameras/camera";
  18805. import { Scene } from "babylonjs/scene";
  18806. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  18807. import { Engine } from "babylonjs/Engines/engine";
  18808. import { Node } from "babylonjs/node";
  18809. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  18810. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  18811. import { Buffer } from "babylonjs/Meshes/buffer";
  18812. import { Geometry } from "babylonjs/Meshes/geometry";
  18813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18814. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18815. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  18816. import { Effect } from "babylonjs/Materials/effect";
  18817. import { Material } from "babylonjs/Materials/material";
  18818. import { Skeleton } from "babylonjs/Bones/skeleton";
  18819. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  18820. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  18821. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  18822. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  18823. /**
  18824. * Class used to represent a specific level of detail of a mesh
  18825. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18826. */
  18827. export class MeshLODLevel {
  18828. /** Defines the distance where this level should star being displayed */
  18829. distance: number;
  18830. /** Defines the mesh to use to render this level */
  18831. mesh: Nullable<Mesh>;
  18832. /**
  18833. * Creates a new LOD level
  18834. * @param distance defines the distance where this level should star being displayed
  18835. * @param mesh defines the mesh to use to render this level
  18836. */
  18837. constructor(
  18838. /** Defines the distance where this level should star being displayed */
  18839. distance: number,
  18840. /** Defines the mesh to use to render this level */
  18841. mesh: Nullable<Mesh>);
  18842. }
  18843. /**
  18844. * @hidden
  18845. **/
  18846. export class _CreationDataStorage {
  18847. closePath?: boolean;
  18848. closeArray?: boolean;
  18849. idx: number[];
  18850. dashSize: number;
  18851. gapSize: number;
  18852. path3D: Path3D;
  18853. pathArray: Vector3[][];
  18854. arc: number;
  18855. radius: number;
  18856. cap: number;
  18857. tessellation: number;
  18858. }
  18859. /**
  18860. * @hidden
  18861. **/
  18862. class _InstanceDataStorage {
  18863. visibleInstances: any;
  18864. renderIdForInstances: number[];
  18865. batchCache: _InstancesBatch;
  18866. instancesBufferSize: number;
  18867. instancesBuffer: Nullable<Buffer>;
  18868. instancesData: Float32Array;
  18869. overridenInstanceCount: number;
  18870. }
  18871. /**
  18872. * @hidden
  18873. **/
  18874. export class _InstancesBatch {
  18875. mustReturn: boolean;
  18876. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  18877. renderSelf: boolean[];
  18878. }
  18879. /**
  18880. * Class used to represent renderable models
  18881. */
  18882. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  18883. /**
  18884. * Mesh side orientation : usually the external or front surface
  18885. */
  18886. static readonly FRONTSIDE: number;
  18887. /**
  18888. * Mesh side orientation : usually the internal or back surface
  18889. */
  18890. static readonly BACKSIDE: number;
  18891. /**
  18892. * Mesh side orientation : both internal and external or front and back surfaces
  18893. */
  18894. static readonly DOUBLESIDE: number;
  18895. /**
  18896. * Mesh side orientation : by default, `FRONTSIDE`
  18897. */
  18898. static readonly DEFAULTSIDE: number;
  18899. /**
  18900. * Mesh cap setting : no cap
  18901. */
  18902. static readonly NO_CAP: number;
  18903. /**
  18904. * Mesh cap setting : one cap at the beginning of the mesh
  18905. */
  18906. static readonly CAP_START: number;
  18907. /**
  18908. * Mesh cap setting : one cap at the end of the mesh
  18909. */
  18910. static readonly CAP_END: number;
  18911. /**
  18912. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  18913. */
  18914. static readonly CAP_ALL: number;
  18915. /**
  18916. * Gets the default side orientation.
  18917. * @param orientation the orientation to value to attempt to get
  18918. * @returns the default orientation
  18919. * @hidden
  18920. */
  18921. static _GetDefaultSideOrientation(orientation?: number): number;
  18922. private _onBeforeRenderObservable;
  18923. private _onBeforeBindObservable;
  18924. private _onAfterRenderObservable;
  18925. private _onBeforeDrawObservable;
  18926. /**
  18927. * An event triggered before rendering the mesh
  18928. */
  18929. readonly onBeforeRenderObservable: Observable<Mesh>;
  18930. /**
  18931. * An event triggered before binding the mesh
  18932. */
  18933. readonly onBeforeBindObservable: Observable<Mesh>;
  18934. /**
  18935. * An event triggered after rendering the mesh
  18936. */
  18937. readonly onAfterRenderObservable: Observable<Mesh>;
  18938. /**
  18939. * An event triggered before drawing the mesh
  18940. */
  18941. readonly onBeforeDrawObservable: Observable<Mesh>;
  18942. private _onBeforeDrawObserver;
  18943. /**
  18944. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  18945. */
  18946. onBeforeDraw: () => void;
  18947. /**
  18948. * Gets the delay loading state of the mesh (when delay loading is turned on)
  18949. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  18950. */
  18951. delayLoadState: number;
  18952. /**
  18953. * Gets the list of instances created from this mesh
  18954. * it is not supposed to be modified manually.
  18955. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  18956. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18957. */
  18958. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  18959. /**
  18960. * Gets the file containing delay loading data for this mesh
  18961. */
  18962. delayLoadingFile: string;
  18963. /** @hidden */
  18964. _binaryInfo: any;
  18965. private _LODLevels;
  18966. /**
  18967. * User defined function used to change how LOD level selection is done
  18968. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  18969. */
  18970. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  18971. private _morphTargetManager;
  18972. /**
  18973. * Gets or sets the morph target manager
  18974. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18975. */
  18976. morphTargetManager: Nullable<MorphTargetManager>;
  18977. /** @hidden */
  18978. _creationDataStorage: Nullable<_CreationDataStorage>;
  18979. /** @hidden */
  18980. _geometry: Nullable<Geometry>;
  18981. /** @hidden */
  18982. _delayInfo: Array<string>;
  18983. /** @hidden */
  18984. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  18985. /** @hidden */
  18986. _instanceDataStorage: _InstanceDataStorage;
  18987. private _effectiveMaterial;
  18988. /** @hidden */
  18989. _shouldGenerateFlatShading: boolean;
  18990. private _preActivateId;
  18991. /** @hidden */
  18992. _originalBuilderSideOrientation: number;
  18993. /**
  18994. * Use this property to change the original side orientation defined at construction time
  18995. */
  18996. overrideMaterialSideOrientation: Nullable<number>;
  18997. private _areNormalsFrozen;
  18998. private _sourcePositions;
  18999. private _sourceNormals;
  19000. private _source;
  19001. private meshMap;
  19002. /**
  19003. * Gets the source mesh (the one used to clone this one from)
  19004. */
  19005. readonly source: Nullable<Mesh>;
  19006. /**
  19007. * Gets or sets a boolean indicating that this mesh does not use index buffer
  19008. */
  19009. isUnIndexed: boolean;
  19010. /**
  19011. * @constructor
  19012. * @param name The value used by scene.getMeshByName() to do a lookup.
  19013. * @param scene The scene to add this mesh to.
  19014. * @param parent The parent of this mesh, if it has one
  19015. * @param source An optional Mesh from which geometry is shared, cloned.
  19016. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19017. * When false, achieved by calling a clone(), also passing False.
  19018. * This will make creation of children, recursive.
  19019. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  19020. */
  19021. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  19022. /**
  19023. * Gets the class name
  19024. * @returns the string "Mesh".
  19025. */
  19026. getClassName(): string;
  19027. /** @hidden */
  19028. readonly _isMesh: boolean;
  19029. /**
  19030. * Returns a description of this mesh
  19031. * @param fullDetails define if full details about this mesh must be used
  19032. * @returns a descriptive string representing this mesh
  19033. */
  19034. toString(fullDetails?: boolean): string;
  19035. /** @hidden */
  19036. _unBindEffect(): void;
  19037. /**
  19038. * Gets a boolean indicating if this mesh has LOD
  19039. */
  19040. readonly hasLODLevels: boolean;
  19041. /**
  19042. * Gets the list of MeshLODLevel associated with the current mesh
  19043. * @returns an array of MeshLODLevel
  19044. */
  19045. getLODLevels(): MeshLODLevel[];
  19046. private _sortLODLevels;
  19047. /**
  19048. * Add a mesh as LOD level triggered at the given distance.
  19049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19050. * @param distance The distance from the center of the object to show this level
  19051. * @param mesh The mesh to be added as LOD level (can be null)
  19052. * @return This mesh (for chaining)
  19053. */
  19054. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  19055. /**
  19056. * Returns the LOD level mesh at the passed distance or null if not found.
  19057. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19058. * @param distance The distance from the center of the object to show this level
  19059. * @returns a Mesh or `null`
  19060. */
  19061. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  19062. /**
  19063. * Remove a mesh from the LOD array
  19064. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19065. * @param mesh defines the mesh to be removed
  19066. * @return This mesh (for chaining)
  19067. */
  19068. removeLODLevel(mesh: Mesh): Mesh;
  19069. /**
  19070. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  19071. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  19072. * @param camera defines the camera to use to compute distance
  19073. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  19074. * @return This mesh (for chaining)
  19075. */
  19076. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  19077. /**
  19078. * Gets the mesh internal Geometry object
  19079. */
  19080. readonly geometry: Nullable<Geometry>;
  19081. /**
  19082. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  19083. * @returns the total number of vertices
  19084. */
  19085. getTotalVertices(): number;
  19086. /**
  19087. * Returns the content of an associated vertex buffer
  19088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19089. * - VertexBuffer.PositionKind
  19090. * - VertexBuffer.UVKind
  19091. * - VertexBuffer.UV2Kind
  19092. * - VertexBuffer.UV3Kind
  19093. * - VertexBuffer.UV4Kind
  19094. * - VertexBuffer.UV5Kind
  19095. * - VertexBuffer.UV6Kind
  19096. * - VertexBuffer.ColorKind
  19097. * - VertexBuffer.MatricesIndicesKind
  19098. * - VertexBuffer.MatricesIndicesExtraKind
  19099. * - VertexBuffer.MatricesWeightsKind
  19100. * - VertexBuffer.MatricesWeightsExtraKind
  19101. * @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
  19102. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  19103. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  19104. */
  19105. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  19106. /**
  19107. * Returns the mesh VertexBuffer object from the requested `kind`
  19108. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19109. * - VertexBuffer.PositionKind
  19110. * - VertexBuffer.UVKind
  19111. * - VertexBuffer.UV2Kind
  19112. * - VertexBuffer.UV3Kind
  19113. * - VertexBuffer.UV4Kind
  19114. * - VertexBuffer.UV5Kind
  19115. * - VertexBuffer.UV6Kind
  19116. * - VertexBuffer.ColorKind
  19117. * - VertexBuffer.MatricesIndicesKind
  19118. * - VertexBuffer.MatricesIndicesExtraKind
  19119. * - VertexBuffer.MatricesWeightsKind
  19120. * - VertexBuffer.MatricesWeightsExtraKind
  19121. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  19122. */
  19123. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  19124. /**
  19125. * Tests if a specific vertex buffer is associated with this mesh
  19126. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19127. * - VertexBuffer.PositionKind
  19128. * - VertexBuffer.UVKind
  19129. * - VertexBuffer.UV2Kind
  19130. * - VertexBuffer.UV3Kind
  19131. * - VertexBuffer.UV4Kind
  19132. * - VertexBuffer.UV5Kind
  19133. * - VertexBuffer.UV6Kind
  19134. * - VertexBuffer.ColorKind
  19135. * - VertexBuffer.MatricesIndicesKind
  19136. * - VertexBuffer.MatricesIndicesExtraKind
  19137. * - VertexBuffer.MatricesWeightsKind
  19138. * - VertexBuffer.MatricesWeightsExtraKind
  19139. * @returns a boolean
  19140. */
  19141. isVerticesDataPresent(kind: string): boolean;
  19142. /**
  19143. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  19144. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  19145. * - VertexBuffer.PositionKind
  19146. * - VertexBuffer.UVKind
  19147. * - VertexBuffer.UV2Kind
  19148. * - VertexBuffer.UV3Kind
  19149. * - VertexBuffer.UV4Kind
  19150. * - VertexBuffer.UV5Kind
  19151. * - VertexBuffer.UV6Kind
  19152. * - VertexBuffer.ColorKind
  19153. * - VertexBuffer.MatricesIndicesKind
  19154. * - VertexBuffer.MatricesIndicesExtraKind
  19155. * - VertexBuffer.MatricesWeightsKind
  19156. * - VertexBuffer.MatricesWeightsExtraKind
  19157. * @returns a boolean
  19158. */
  19159. isVertexBufferUpdatable(kind: string): boolean;
  19160. /**
  19161. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  19162. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  19163. * - VertexBuffer.PositionKind
  19164. * - VertexBuffer.UVKind
  19165. * - VertexBuffer.UV2Kind
  19166. * - VertexBuffer.UV3Kind
  19167. * - VertexBuffer.UV4Kind
  19168. * - VertexBuffer.UV5Kind
  19169. * - VertexBuffer.UV6Kind
  19170. * - VertexBuffer.ColorKind
  19171. * - VertexBuffer.MatricesIndicesKind
  19172. * - VertexBuffer.MatricesIndicesExtraKind
  19173. * - VertexBuffer.MatricesWeightsKind
  19174. * - VertexBuffer.MatricesWeightsExtraKind
  19175. * @returns an array of strings
  19176. */
  19177. getVerticesDataKinds(): string[];
  19178. /**
  19179. * Returns a positive integer : the total number of indices in this mesh geometry.
  19180. * @returns the numner of indices or zero if the mesh has no geometry.
  19181. */
  19182. getTotalIndices(): number;
  19183. /**
  19184. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19185. * @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.
  19186. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  19187. * @returns the indices array or an empty array if the mesh has no geometry
  19188. */
  19189. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  19190. readonly isBlocked: boolean;
  19191. /**
  19192. * Determine if the current mesh is ready to be rendered
  19193. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19194. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  19195. * @returns true if all associated assets are ready (material, textures, shaders)
  19196. */
  19197. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  19198. /**
  19199. * 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.
  19200. */
  19201. readonly areNormalsFrozen: boolean;
  19202. /**
  19203. * 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.
  19204. * @returns the current mesh
  19205. */
  19206. freezeNormals(): Mesh;
  19207. /**
  19208. * 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
  19209. * @returns the current mesh
  19210. */
  19211. unfreezeNormals(): Mesh;
  19212. /**
  19213. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  19214. */
  19215. overridenInstanceCount: number;
  19216. /** @hidden */
  19217. _preActivate(): Mesh;
  19218. /** @hidden */
  19219. _preActivateForIntermediateRendering(renderId: number): Mesh;
  19220. /** @hidden */
  19221. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  19222. /**
  19223. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19224. * This means the mesh underlying bounding box and sphere are recomputed.
  19225. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19226. * @returns the current mesh
  19227. */
  19228. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  19229. /** @hidden */
  19230. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  19231. /**
  19232. * This function will subdivide the mesh into multiple submeshes
  19233. * @param count defines the expected number of submeshes
  19234. */
  19235. subdivide(count: number): void;
  19236. /**
  19237. * Copy a FloatArray into a specific associated vertex buffer
  19238. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19239. * - VertexBuffer.PositionKind
  19240. * - VertexBuffer.UVKind
  19241. * - VertexBuffer.UV2Kind
  19242. * - VertexBuffer.UV3Kind
  19243. * - VertexBuffer.UV4Kind
  19244. * - VertexBuffer.UV5Kind
  19245. * - VertexBuffer.UV6Kind
  19246. * - VertexBuffer.ColorKind
  19247. * - VertexBuffer.MatricesIndicesKind
  19248. * - VertexBuffer.MatricesIndicesExtraKind
  19249. * - VertexBuffer.MatricesWeightsKind
  19250. * - VertexBuffer.MatricesWeightsExtraKind
  19251. * @param data defines the data source
  19252. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19253. * @param stride defines the data stride size (can be null)
  19254. * @returns the current mesh
  19255. */
  19256. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  19257. /**
  19258. * Flags an associated vertex buffer as updatable
  19259. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  19260. * - VertexBuffer.PositionKind
  19261. * - VertexBuffer.UVKind
  19262. * - VertexBuffer.UV2Kind
  19263. * - VertexBuffer.UV3Kind
  19264. * - VertexBuffer.UV4Kind
  19265. * - VertexBuffer.UV5Kind
  19266. * - VertexBuffer.UV6Kind
  19267. * - VertexBuffer.ColorKind
  19268. * - VertexBuffer.MatricesIndicesKind
  19269. * - VertexBuffer.MatricesIndicesExtraKind
  19270. * - VertexBuffer.MatricesWeightsKind
  19271. * - VertexBuffer.MatricesWeightsExtraKind
  19272. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  19273. */
  19274. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  19275. /**
  19276. * Sets the mesh global Vertex Buffer
  19277. * @param buffer defines the buffer to use
  19278. * @returns the current mesh
  19279. */
  19280. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  19281. /**
  19282. * Update a specific associated vertex buffer
  19283. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  19284. * - VertexBuffer.PositionKind
  19285. * - VertexBuffer.UVKind
  19286. * - VertexBuffer.UV2Kind
  19287. * - VertexBuffer.UV3Kind
  19288. * - VertexBuffer.UV4Kind
  19289. * - VertexBuffer.UV5Kind
  19290. * - VertexBuffer.UV6Kind
  19291. * - VertexBuffer.ColorKind
  19292. * - VertexBuffer.MatricesIndicesKind
  19293. * - VertexBuffer.MatricesIndicesExtraKind
  19294. * - VertexBuffer.MatricesWeightsKind
  19295. * - VertexBuffer.MatricesWeightsExtraKind
  19296. * @param data defines the data source
  19297. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  19298. * @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)
  19299. * @returns the current mesh
  19300. */
  19301. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19302. /**
  19303. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  19304. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  19305. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  19306. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  19307. * @returns the current mesh
  19308. */
  19309. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  19310. /**
  19311. * Creates a un-shared specific occurence of the geometry for the mesh.
  19312. * @returns the current mesh
  19313. */
  19314. makeGeometryUnique(): Mesh;
  19315. /**
  19316. * Set the index buffer of this mesh
  19317. * @param indices defines the source data
  19318. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  19319. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  19320. * @returns the current mesh
  19321. */
  19322. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  19323. /**
  19324. * Update the current index buffer
  19325. * @param indices defines the source data
  19326. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  19327. * @returns the current mesh
  19328. */
  19329. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  19330. /**
  19331. * Invert the geometry to move from a right handed system to a left handed one.
  19332. * @returns the current mesh
  19333. */
  19334. toLeftHanded(): Mesh;
  19335. /** @hidden */
  19336. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19337. /** @hidden */
  19338. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  19339. /**
  19340. * Registers for this mesh a javascript function called just before the rendering process
  19341. * @param func defines the function to call before rendering this mesh
  19342. * @returns the current mesh
  19343. */
  19344. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19345. /**
  19346. * Disposes a previously registered javascript function called before the rendering
  19347. * @param func defines the function to remove
  19348. * @returns the current mesh
  19349. */
  19350. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  19351. /**
  19352. * Registers for this mesh a javascript function called just after the rendering is complete
  19353. * @param func defines the function to call after rendering this mesh
  19354. * @returns the current mesh
  19355. */
  19356. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19357. /**
  19358. * Disposes a previously registered javascript function called after the rendering.
  19359. * @param func defines the function to remove
  19360. * @returns the current mesh
  19361. */
  19362. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  19363. /** @hidden */
  19364. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  19365. /** @hidden */
  19366. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  19367. /** @hidden */
  19368. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  19369. /**
  19370. * 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
  19371. * @param subMesh defines the subMesh to render
  19372. * @param enableAlphaMode defines if alpha mode can be changed
  19373. * @returns the current mesh
  19374. */
  19375. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  19376. private _onBeforeDraw;
  19377. /**
  19378. * Renormalize the mesh and patch it up if there are no weights
  19379. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  19380. * However in the case of zero weights then we set just a single influence to 1.
  19381. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  19382. */
  19383. cleanMatrixWeights(): void;
  19384. private normalizeSkinFourWeights;
  19385. private normalizeSkinWeightsAndExtra;
  19386. /**
  19387. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  19388. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  19389. * the user know there was an issue with importing the mesh
  19390. * @returns a validation object with skinned, valid and report string
  19391. */
  19392. validateSkinning(): {
  19393. skinned: boolean;
  19394. valid: boolean;
  19395. report: string;
  19396. };
  19397. /** @hidden */
  19398. _checkDelayState(): Mesh;
  19399. private _queueLoad;
  19400. /**
  19401. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  19402. * A mesh is in the frustum if its bounding box intersects the frustum
  19403. * @param frustumPlanes defines the frustum to test
  19404. * @returns true if the mesh is in the frustum planes
  19405. */
  19406. isInFrustum(frustumPlanes: Plane[]): boolean;
  19407. /**
  19408. * Sets the mesh material by the material or multiMaterial `id` property
  19409. * @param id is a string identifying the material or the multiMaterial
  19410. * @returns the current mesh
  19411. */
  19412. setMaterialByID(id: string): Mesh;
  19413. /**
  19414. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  19415. * @returns an array of IAnimatable
  19416. */
  19417. getAnimatables(): IAnimatable[];
  19418. /**
  19419. * Modifies the mesh geometry according to the passed transformation matrix.
  19420. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  19421. * The mesh normals are modified using the same transformation.
  19422. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19423. * @param transform defines the transform matrix to use
  19424. * @see http://doc.babylonjs.com/resources/baking_transformations
  19425. * @returns the current mesh
  19426. */
  19427. bakeTransformIntoVertices(transform: Matrix): Mesh;
  19428. /**
  19429. * Modifies the mesh geometry according to its own current World Matrix.
  19430. * The mesh World Matrix is then reset.
  19431. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  19432. * Note that, under the hood, this method sets a new VertexBuffer each call.
  19433. * @see http://doc.babylonjs.com/resources/baking_transformations
  19434. * @returns the current mesh
  19435. */
  19436. bakeCurrentTransformIntoVertices(): Mesh;
  19437. /** @hidden */
  19438. readonly _positions: Nullable<Vector3[]>;
  19439. /** @hidden */
  19440. _resetPointsArrayCache(): Mesh;
  19441. /** @hidden */
  19442. _generatePointsArray(): boolean;
  19443. /**
  19444. * Returns a new Mesh object generated from the current mesh properties.
  19445. * This method must not get confused with createInstance()
  19446. * @param name is a string, the name given to the new mesh
  19447. * @param newParent can be any Node object (default `null`)
  19448. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  19449. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  19450. * @returns a new mesh
  19451. */
  19452. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  19453. /**
  19454. * Releases resources associated with this mesh.
  19455. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  19456. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  19457. */
  19458. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19459. /**
  19460. * Modifies the mesh geometry according to a displacement map.
  19461. * 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.
  19462. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19463. * @param url is a string, the URL from the image file is to be downloaded.
  19464. * @param minHeight is the lower limit of the displacement.
  19465. * @param maxHeight is the upper limit of the displacement.
  19466. * @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.
  19467. * @param uvOffset is an optional vector2 used to offset UV.
  19468. * @param uvScale is an optional vector2 used to scale UV.
  19469. * @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.
  19470. * @returns the Mesh.
  19471. */
  19472. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19473. /**
  19474. * Modifies the mesh geometry according to a displacementMap buffer.
  19475. * 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.
  19476. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  19477. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  19478. * @param heightMapWidth is the width of the buffer image.
  19479. * @param heightMapHeight is the height of the buffer image.
  19480. * @param minHeight is the lower limit of the displacement.
  19481. * @param maxHeight is the upper limit of the displacement.
  19482. * @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.
  19483. * @param uvOffset is an optional vector2 used to offset UV.
  19484. * @param uvScale is an optional vector2 used to scale UV.
  19485. * @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.
  19486. * @returns the Mesh.
  19487. */
  19488. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  19489. /**
  19490. * Modify the mesh to get a flat shading rendering.
  19491. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  19492. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  19493. * @returns current mesh
  19494. */
  19495. convertToFlatShadedMesh(): Mesh;
  19496. /**
  19497. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  19498. * In other words, more vertices, no more indices and a single bigger VBO.
  19499. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  19500. * @returns current mesh
  19501. */
  19502. convertToUnIndexedMesh(): Mesh;
  19503. /**
  19504. * Inverses facet orientations.
  19505. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  19506. * @param flipNormals will also inverts the normals
  19507. * @returns current mesh
  19508. */
  19509. flipFaces(flipNormals?: boolean): Mesh;
  19510. /** @hidden */
  19511. static _instancedMeshFactory: (name: string, mesh: Mesh) => import("babylonjs/Meshes/instancedMesh").InstancedMesh;
  19512. /**
  19513. * Creates a new InstancedMesh object from the mesh model.
  19514. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19515. * @param name defines the name of the new instance
  19516. * @returns a new InstancedMesh
  19517. */
  19518. createInstance(name: string): InstancedMesh;
  19519. /**
  19520. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  19521. * After this call, all the mesh instances have the same submeshes than the current mesh.
  19522. * @returns the current mesh
  19523. */
  19524. synchronizeInstances(): Mesh;
  19525. /**
  19526. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  19527. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  19528. * This should be used together with the simplification to avoid disappearing triangles.
  19529. * @param successCallback an optional success callback to be called after the optimization finished.
  19530. * @returns the current mesh
  19531. */
  19532. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  19533. /**
  19534. * Serialize current mesh
  19535. * @param serializationObject defines the object which will receive the serialization data
  19536. */
  19537. serialize(serializationObject: any): void;
  19538. /** @hidden */
  19539. _syncGeometryWithMorphTargetManager(): void;
  19540. /** @hidden */
  19541. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  19542. /**
  19543. * Returns a new Mesh object parsed from the source provided.
  19544. * @param parsedMesh is the source
  19545. * @param scene defines the hosting scene
  19546. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  19547. * @returns a new Mesh
  19548. */
  19549. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  19550. /**
  19551. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  19552. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19553. * @param name defines the name of the mesh to create
  19554. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  19555. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  19556. * @param closePath creates a seam between the first and the last points of each path of the path array
  19557. * @param offset is taken in account only if the `pathArray` is containing a single path
  19558. * @param scene defines the hosting scene
  19559. * @param updatable defines if the mesh must be flagged as updatable
  19560. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19561. * @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)
  19562. * @returns a new Mesh
  19563. */
  19564. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19565. /**
  19566. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  19567. * @param name defines the name of the mesh to create
  19568. * @param radius sets the radius size (float) of the polygon (default 0.5)
  19569. * @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
  19570. * @param scene defines the hosting scene
  19571. * @param updatable defines if the mesh must be flagged as updatable
  19572. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19573. * @returns a new Mesh
  19574. */
  19575. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19576. /**
  19577. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  19578. * @param name defines the name of the mesh to create
  19579. * @param size sets the size (float) of each box side (default 1)
  19580. * @param scene defines the hosting scene
  19581. * @param updatable defines if the mesh must be flagged as updatable
  19582. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19583. * @returns a new Mesh
  19584. */
  19585. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  19586. /**
  19587. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  19588. * @param name defines the name of the mesh to create
  19589. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  19590. * @param diameter sets the diameter size (float) of the sphere (default 1)
  19591. * @param scene defines the hosting scene
  19592. * @param updatable defines if the mesh must be flagged as updatable
  19593. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19594. * @returns a new Mesh
  19595. */
  19596. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19597. /**
  19598. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  19599. * @param name defines the name of the mesh to create
  19600. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  19601. * @param diameterTop set the top cap diameter (floats, default 1)
  19602. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  19603. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  19604. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  19605. * @param scene defines the hosting scene
  19606. * @param updatable defines if the mesh must be flagged as updatable
  19607. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19608. * @returns a new Mesh
  19609. */
  19610. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  19611. /**
  19612. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  19613. * @param name defines the name of the mesh to create
  19614. * @param diameter sets the diameter size (float) of the torus (default 1)
  19615. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  19616. * @param tessellation sets the number of torus sides (postive integer, default 16)
  19617. * @param scene defines the hosting scene
  19618. * @param updatable defines if the mesh must be flagged as updatable
  19619. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19620. * @returns a new Mesh
  19621. */
  19622. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19623. /**
  19624. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  19625. * @param name defines the name of the mesh to create
  19626. * @param radius sets the global radius size (float) of the torus knot (default 2)
  19627. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  19628. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  19629. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  19630. * @param p the number of windings on X axis (positive integers, default 2)
  19631. * @param q the number of windings on Y axis (positive integers, default 3)
  19632. * @param scene defines the hosting scene
  19633. * @param updatable defines if the mesh must be flagged as updatable
  19634. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19635. * @returns a new Mesh
  19636. */
  19637. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19638. /**
  19639. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  19640. * @param name defines the name of the mesh to create
  19641. * @param points is an array successive Vector3
  19642. * @param scene defines the hosting scene
  19643. * @param updatable defines if the mesh must be flagged as updatable
  19644. * @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).
  19645. * @returns a new Mesh
  19646. */
  19647. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  19648. /**
  19649. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  19650. * @param name defines the name of the mesh to create
  19651. * @param points is an array successive Vector3
  19652. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  19653. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  19654. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  19655. * @param scene defines the hosting scene
  19656. * @param updatable defines if the mesh must be flagged as updatable
  19657. * @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)
  19658. * @returns a new Mesh
  19659. */
  19660. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  19661. /**
  19662. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  19663. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  19664. * 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.
  19665. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19666. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  19667. * Remember you can only change the shape positions, not their number when updating a polygon.
  19668. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  19669. * @param name defines the name of the mesh to create
  19670. * @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
  19671. * @param scene defines the hosting scene
  19672. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19673. * @param updatable defines if the mesh must be flagged as updatable
  19674. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19675. * @param earcutInjection can be used to inject your own earcut reference
  19676. * @returns a new Mesh
  19677. */
  19678. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19679. /**
  19680. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  19681. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  19682. * @param name defines the name of the mesh to create
  19683. * @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
  19684. * @param depth defines the height of extrusion
  19685. * @param scene defines the hosting scene
  19686. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  19687. * @param updatable defines if the mesh must be flagged as updatable
  19688. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19689. * @param earcutInjection can be used to inject your own earcut reference
  19690. * @returns a new Mesh
  19691. */
  19692. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  19693. /**
  19694. * Creates an extruded shape mesh.
  19695. * 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
  19696. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19697. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19698. * @param name defines the name of the mesh to create
  19699. * @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
  19700. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19701. * @param scale is the value to scale the shape
  19702. * @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
  19703. * @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
  19704. * @param scene defines the hosting scene
  19705. * @param updatable defines if the mesh must be flagged as updatable
  19706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19707. * @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)
  19708. * @returns a new Mesh
  19709. */
  19710. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19711. /**
  19712. * Creates an custom extruded shape mesh.
  19713. * The custom extrusion is a parametric shape.
  19714. * It has no predefined shape. Its final shape will depend on the input parameters.
  19715. * Please consider using the same method from the MeshBuilder class instead
  19716. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  19717. * @param name defines the name of the mesh to create
  19718. * @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
  19719. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  19720. * @param scaleFunction is a custom Javascript function called on each path point
  19721. * @param rotationFunction is a custom Javascript function called on each path point
  19722. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  19723. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  19724. * @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
  19725. * @param scene defines the hosting scene
  19726. * @param updatable defines if the mesh must be flagged as updatable
  19727. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19728. * @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)
  19729. * @returns a new Mesh
  19730. */
  19731. 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;
  19732. /**
  19733. * Creates lathe mesh.
  19734. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  19735. * Please consider using the same method from the MeshBuilder class instead
  19736. * @param name defines the name of the mesh to create
  19737. * @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
  19738. * @param radius is the radius value of the lathe
  19739. * @param tessellation is the side number of the lathe.
  19740. * @param scene defines the hosting scene
  19741. * @param updatable defines if the mesh must be flagged as updatable
  19742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19743. * @returns a new Mesh
  19744. */
  19745. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19746. /**
  19747. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  19748. * @param name defines the name of the mesh to create
  19749. * @param size sets the size (float) of both sides of the plane at once (default 1)
  19750. * @param scene defines the hosting scene
  19751. * @param updatable defines if the mesh must be flagged as updatable
  19752. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19753. * @returns a new Mesh
  19754. */
  19755. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  19756. /**
  19757. * Creates a ground mesh.
  19758. * Please consider using the same method from the MeshBuilder class instead
  19759. * @param name defines the name of the mesh to create
  19760. * @param width set the width of the ground
  19761. * @param height set the height of the ground
  19762. * @param subdivisions sets the number of subdivisions per side
  19763. * @param scene defines the hosting scene
  19764. * @param updatable defines if the mesh must be flagged as updatable
  19765. * @returns a new Mesh
  19766. */
  19767. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  19768. /**
  19769. * Creates a tiled ground mesh.
  19770. * Please consider using the same method from the MeshBuilder class instead
  19771. * @param name defines the name of the mesh to create
  19772. * @param xmin set the ground minimum X coordinate
  19773. * @param zmin set the ground minimum Y coordinate
  19774. * @param xmax set the ground maximum X coordinate
  19775. * @param zmax set the ground maximum Z coordinate
  19776. * @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
  19777. * @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
  19778. * @param scene defines the hosting scene
  19779. * @param updatable defines if the mesh must be flagged as updatable
  19780. * @returns a new Mesh
  19781. */
  19782. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  19783. w: number;
  19784. h: number;
  19785. }, precision: {
  19786. w: number;
  19787. h: number;
  19788. }, scene: Scene, updatable?: boolean): Mesh;
  19789. /**
  19790. * Creates a ground mesh from a height map.
  19791. * Please consider using the same method from the MeshBuilder class instead
  19792. * @see http://doc.babylonjs.com/babylon101/height_map
  19793. * @param name defines the name of the mesh to create
  19794. * @param url sets the URL of the height map image resource
  19795. * @param width set the ground width size
  19796. * @param height set the ground height size
  19797. * @param subdivisions sets the number of subdivision per side
  19798. * @param minHeight is the minimum altitude on the ground
  19799. * @param maxHeight is the maximum altitude on the ground
  19800. * @param scene defines the hosting scene
  19801. * @param updatable defines if the mesh must be flagged as updatable
  19802. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  19803. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  19804. * @returns a new Mesh
  19805. */
  19806. 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;
  19807. /**
  19808. * Creates a tube mesh.
  19809. * The tube is a parametric shape.
  19810. * It has no predefined shape. Its final shape will depend on the input parameters.
  19811. * Please consider using the same method from the MeshBuilder class instead
  19812. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  19813. * @param name defines the name of the mesh to create
  19814. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  19815. * @param radius sets the tube radius size
  19816. * @param tessellation is the number of sides on the tubular surface
  19817. * @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
  19818. * @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
  19819. * @param scene defines the hosting scene
  19820. * @param updatable defines if the mesh must be flagged as updatable
  19821. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  19822. * @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)
  19823. * @returns a new Mesh
  19824. */
  19825. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  19826. (i: number, distance: number): number;
  19827. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  19828. /**
  19829. * Creates a polyhedron mesh.
  19830. * Please consider using the same method from the MeshBuilder class instead.
  19831. * * 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
  19832. * * The parameter `size` (positive float, default 1) sets the polygon size
  19833. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  19834. * * 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`
  19835. * * 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
  19836. * * 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)`)
  19837. * * 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
  19838. * * 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
  19839. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19840. * * If you create a double-sided mesh, you can choose what parts of 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
  19841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19842. * @param name defines the name of the mesh to create
  19843. * @param options defines the options used to create the mesh
  19844. * @param scene defines the hosting scene
  19845. * @returns a new Mesh
  19846. */
  19847. static CreatePolyhedron(name: string, options: {
  19848. type?: number;
  19849. size?: number;
  19850. sizeX?: number;
  19851. sizeY?: number;
  19852. sizeZ?: number;
  19853. custom?: any;
  19854. faceUV?: Vector4[];
  19855. faceColors?: Color4[];
  19856. updatable?: boolean;
  19857. sideOrientation?: number;
  19858. }, scene: Scene): Mesh;
  19859. /**
  19860. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  19861. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  19862. * * 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`)
  19863. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  19864. * * 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
  19865. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  19866. * * If you create a double-sided mesh, you can choose what parts of 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
  19867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  19868. * @param name defines the name of the mesh
  19869. * @param options defines the options used to create the mesh
  19870. * @param scene defines the hosting scene
  19871. * @returns a new Mesh
  19872. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  19873. */
  19874. static CreateIcoSphere(name: string, options: {
  19875. radius?: number;
  19876. flat?: boolean;
  19877. subdivisions?: number;
  19878. sideOrientation?: number;
  19879. updatable?: boolean;
  19880. }, scene: Scene): Mesh;
  19881. /**
  19882. * Creates a decal mesh.
  19883. * Please consider using the same method from the MeshBuilder class instead.
  19884. * A decal is a mesh usually applied as a model onto the surface of another mesh
  19885. * @param name defines the name of the mesh
  19886. * @param sourceMesh defines the mesh receiving the decal
  19887. * @param position sets the position of the decal in world coordinates
  19888. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  19889. * @param size sets the decal scaling
  19890. * @param angle sets the angle to rotate the decal
  19891. * @returns a new Mesh
  19892. */
  19893. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  19894. /**
  19895. * Prepare internal position array for software CPU skinning
  19896. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  19897. */
  19898. setPositionsForCPUSkinning(): Float32Array;
  19899. /**
  19900. * Prepare internal normal array for software CPU skinning
  19901. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  19902. */
  19903. setNormalsForCPUSkinning(): Float32Array;
  19904. /**
  19905. * Updates the vertex buffer by applying transformation from the bones
  19906. * @param skeleton defines the skeleton to apply to current mesh
  19907. * @returns the current mesh
  19908. */
  19909. applySkeleton(skeleton: Skeleton): Mesh;
  19910. /**
  19911. * 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
  19912. * @param meshes defines the list of meshes to scan
  19913. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  19914. */
  19915. static MinMax(meshes: AbstractMesh[]): {
  19916. min: Vector3;
  19917. max: Vector3;
  19918. };
  19919. /**
  19920. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  19921. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  19922. * @returns a vector3
  19923. */
  19924. static Center(meshesOrMinMaxVector: {
  19925. min: Vector3;
  19926. max: Vector3;
  19927. } | AbstractMesh[]): Vector3;
  19928. /**
  19929. * Merge the array of meshes into a single mesh for performance reasons.
  19930. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  19931. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  19932. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  19933. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  19934. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  19935. * @returns a new mesh
  19936. */
  19937. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  19938. /** @hidden */
  19939. addInstance(instance: InstancedMesh): void;
  19940. /** @hidden */
  19941. removeInstance(instance: InstancedMesh): void;
  19942. }
  19943. }
  19944. declare module "babylonjs/Actions/action" {
  19945. import { Observable } from "babylonjs/Misc/observable";
  19946. import { Condition } from "babylonjs/Actions/condition";
  19947. import { ActionManager } from "babylonjs/Actions/actionManager";
  19948. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  19949. /**
  19950. * Interface used to define Action
  19951. */
  19952. export interface IAction {
  19953. /**
  19954. * Trigger for the action
  19955. */
  19956. trigger: number;
  19957. /** the trigger, with or without parameters, for the action */
  19958. triggerOptions: any;
  19959. /**
  19960. * Gets the trigger parameters
  19961. * @returns the trigger parameters
  19962. */
  19963. getTriggerParameter(): any;
  19964. /**
  19965. * Internal only - executes current action event
  19966. * @hidden
  19967. */
  19968. _executeCurrent(evt?: ActionEvent): void;
  19969. /**
  19970. * Serialize placeholder for child classes
  19971. * @param parent of child
  19972. * @returns the serialized object
  19973. */
  19974. serialize(parent: any): any;
  19975. }
  19976. /**
  19977. * The action to be carried out following a trigger
  19978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  19979. */
  19980. export class Action implements IAction {
  19981. /** the trigger, with or without parameters, for the action */
  19982. triggerOptions: any;
  19983. /**
  19984. * Trigger for the action
  19985. */
  19986. trigger: number;
  19987. /**
  19988. * Internal only - manager for action
  19989. * @hidden
  19990. */
  19991. _actionManager: ActionManager;
  19992. private _nextActiveAction;
  19993. private _child;
  19994. private _condition?;
  19995. private _triggerParameter;
  19996. /**
  19997. * An event triggered prior to action being executed.
  19998. */
  19999. onBeforeExecuteObservable: Observable<Action>;
  20000. /**
  20001. * Creates a new Action
  20002. * @param triggerOptions the trigger, with or without parameters, for the action
  20003. * @param condition an optional determinant of action
  20004. */
  20005. constructor(
  20006. /** the trigger, with or without parameters, for the action */
  20007. triggerOptions: any, condition?: Condition);
  20008. /**
  20009. * Internal only
  20010. * @hidden
  20011. */
  20012. _prepare(): void;
  20013. /**
  20014. * Gets the trigger parameters
  20015. * @returns the trigger parameters
  20016. */
  20017. getTriggerParameter(): any;
  20018. /**
  20019. * Internal only - executes current action event
  20020. * @hidden
  20021. */
  20022. _executeCurrent(evt?: ActionEvent): void;
  20023. /**
  20024. * Execute placeholder for child classes
  20025. * @param evt optional action event
  20026. */
  20027. execute(evt?: ActionEvent): void;
  20028. /**
  20029. * Skips to next active action
  20030. */
  20031. skipToNextActiveAction(): void;
  20032. /**
  20033. * Adds action to chain of actions, may be a DoNothingAction
  20034. * @param action defines the next action to execute
  20035. * @returns The action passed in
  20036. * @see https://www.babylonjs-playground.com/#1T30HR#0
  20037. */
  20038. then(action: Action): Action;
  20039. /**
  20040. * Internal only
  20041. * @hidden
  20042. */
  20043. _getProperty(propertyPath: string): string;
  20044. /**
  20045. * Internal only
  20046. * @hidden
  20047. */
  20048. _getEffectiveTarget(target: any, propertyPath: string): any;
  20049. /**
  20050. * Serialize placeholder for child classes
  20051. * @param parent of child
  20052. * @returns the serialized object
  20053. */
  20054. serialize(parent: any): any;
  20055. /**
  20056. * Internal only called by serialize
  20057. * @hidden
  20058. */
  20059. protected _serialize(serializedAction: any, parent?: any): any;
  20060. /**
  20061. * Internal only
  20062. * @hidden
  20063. */
  20064. static _SerializeValueAsString: (value: any) => string;
  20065. /**
  20066. * Internal only
  20067. * @hidden
  20068. */
  20069. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  20070. name: string;
  20071. targetType: string;
  20072. value: string;
  20073. };
  20074. }
  20075. }
  20076. declare module "babylonjs/Actions/condition" {
  20077. import { ActionManager } from "babylonjs/Actions/actionManager";
  20078. /**
  20079. * A Condition applied to an Action
  20080. */
  20081. export class Condition {
  20082. /**
  20083. * Internal only - manager for action
  20084. * @hidden
  20085. */
  20086. _actionManager: ActionManager;
  20087. /**
  20088. * Internal only
  20089. * @hidden
  20090. */
  20091. _evaluationId: number;
  20092. /**
  20093. * Internal only
  20094. * @hidden
  20095. */
  20096. _currentResult: boolean;
  20097. /**
  20098. * Creates a new Condition
  20099. * @param actionManager the manager of the action the condition is applied to
  20100. */
  20101. constructor(actionManager: ActionManager);
  20102. /**
  20103. * Check if the current condition is valid
  20104. * @returns a boolean
  20105. */
  20106. isValid(): boolean;
  20107. /**
  20108. * Internal only
  20109. * @hidden
  20110. */
  20111. _getProperty(propertyPath: string): string;
  20112. /**
  20113. * Internal only
  20114. * @hidden
  20115. */
  20116. _getEffectiveTarget(target: any, propertyPath: string): any;
  20117. /**
  20118. * Serialize placeholder for child classes
  20119. * @returns the serialized object
  20120. */
  20121. serialize(): any;
  20122. /**
  20123. * Internal only
  20124. * @hidden
  20125. */
  20126. protected _serialize(serializedCondition: any): any;
  20127. }
  20128. /**
  20129. * Defines specific conditional operators as extensions of Condition
  20130. */
  20131. export class ValueCondition extends Condition {
  20132. /** path to specify the property of the target the conditional operator uses */
  20133. propertyPath: string;
  20134. /** the value compared by the conditional operator against the current value of the property */
  20135. value: any;
  20136. /** the conditional operator, default ValueCondition.IsEqual */
  20137. operator: number;
  20138. /**
  20139. * Internal only
  20140. * @hidden
  20141. */
  20142. private static _IsEqual;
  20143. /**
  20144. * Internal only
  20145. * @hidden
  20146. */
  20147. private static _IsDifferent;
  20148. /**
  20149. * Internal only
  20150. * @hidden
  20151. */
  20152. private static _IsGreater;
  20153. /**
  20154. * Internal only
  20155. * @hidden
  20156. */
  20157. private static _IsLesser;
  20158. /**
  20159. * returns the number for IsEqual
  20160. */
  20161. static readonly IsEqual: number;
  20162. /**
  20163. * Returns the number for IsDifferent
  20164. */
  20165. static readonly IsDifferent: number;
  20166. /**
  20167. * Returns the number for IsGreater
  20168. */
  20169. static readonly IsGreater: number;
  20170. /**
  20171. * Returns the number for IsLesser
  20172. */
  20173. static readonly IsLesser: number;
  20174. /**
  20175. * Internal only The action manager for the condition
  20176. * @hidden
  20177. */
  20178. _actionManager: ActionManager;
  20179. /**
  20180. * Internal only
  20181. * @hidden
  20182. */
  20183. private _target;
  20184. /**
  20185. * Internal only
  20186. * @hidden
  20187. */
  20188. private _effectiveTarget;
  20189. /**
  20190. * Internal only
  20191. * @hidden
  20192. */
  20193. private _property;
  20194. /**
  20195. * Creates a new ValueCondition
  20196. * @param actionManager manager for the action the condition applies to
  20197. * @param target for the action
  20198. * @param propertyPath path to specify the property of the target the conditional operator uses
  20199. * @param value the value compared by the conditional operator against the current value of the property
  20200. * @param operator the conditional operator, default ValueCondition.IsEqual
  20201. */
  20202. constructor(actionManager: ActionManager, target: any,
  20203. /** path to specify the property of the target the conditional operator uses */
  20204. propertyPath: string,
  20205. /** the value compared by the conditional operator against the current value of the property */
  20206. value: any,
  20207. /** the conditional operator, default ValueCondition.IsEqual */
  20208. operator?: number);
  20209. /**
  20210. * Compares the given value with the property value for the specified conditional operator
  20211. * @returns the result of the comparison
  20212. */
  20213. isValid(): boolean;
  20214. /**
  20215. * Serialize the ValueCondition into a JSON compatible object
  20216. * @returns serialization object
  20217. */
  20218. serialize(): any;
  20219. /**
  20220. * Gets the name of the conditional operator for the ValueCondition
  20221. * @param operator the conditional operator
  20222. * @returns the name
  20223. */
  20224. static GetOperatorName(operator: number): string;
  20225. }
  20226. /**
  20227. * Defines a predicate condition as an extension of Condition
  20228. */
  20229. export class PredicateCondition extends Condition {
  20230. /** defines the predicate function used to validate the condition */
  20231. predicate: () => boolean;
  20232. /**
  20233. * Internal only - manager for action
  20234. * @hidden
  20235. */
  20236. _actionManager: ActionManager;
  20237. /**
  20238. * Creates a new PredicateCondition
  20239. * @param actionManager manager for the action the condition applies to
  20240. * @param predicate defines the predicate function used to validate the condition
  20241. */
  20242. constructor(actionManager: ActionManager,
  20243. /** defines the predicate function used to validate the condition */
  20244. predicate: () => boolean);
  20245. /**
  20246. * @returns the validity of the predicate condition
  20247. */
  20248. isValid(): boolean;
  20249. }
  20250. /**
  20251. * Defines a state condition as an extension of Condition
  20252. */
  20253. export class StateCondition extends Condition {
  20254. /** Value to compare with target state */
  20255. value: string;
  20256. /**
  20257. * Internal only - manager for action
  20258. * @hidden
  20259. */
  20260. _actionManager: ActionManager;
  20261. /**
  20262. * Internal only
  20263. * @hidden
  20264. */
  20265. private _target;
  20266. /**
  20267. * Creates a new StateCondition
  20268. * @param actionManager manager for the action the condition applies to
  20269. * @param target of the condition
  20270. * @param value to compare with target state
  20271. */
  20272. constructor(actionManager: ActionManager, target: any,
  20273. /** Value to compare with target state */
  20274. value: string);
  20275. /**
  20276. * Gets a boolean indicating if the current condition is met
  20277. * @returns the validity of the state
  20278. */
  20279. isValid(): boolean;
  20280. /**
  20281. * Serialize the StateCondition into a JSON compatible object
  20282. * @returns serialization object
  20283. */
  20284. serialize(): any;
  20285. }
  20286. }
  20287. declare module "babylonjs/Actions/directActions" {
  20288. import { Action } from "babylonjs/Actions/action";
  20289. import { Condition } from "babylonjs/Actions/condition";
  20290. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  20291. /**
  20292. * This defines an action responsible to toggle a boolean once triggered.
  20293. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20294. */
  20295. export class SwitchBooleanAction extends Action {
  20296. /**
  20297. * The path to the boolean property in the target object
  20298. */
  20299. propertyPath: string;
  20300. private _target;
  20301. private _effectiveTarget;
  20302. private _property;
  20303. /**
  20304. * Instantiate the action
  20305. * @param triggerOptions defines the trigger options
  20306. * @param target defines the object containing the boolean
  20307. * @param propertyPath defines the path to the boolean property in the target object
  20308. * @param condition defines the trigger related conditions
  20309. */
  20310. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  20311. /** @hidden */
  20312. _prepare(): void;
  20313. /**
  20314. * Execute the action toggle the boolean value.
  20315. */
  20316. execute(): void;
  20317. /**
  20318. * Serializes the actions and its related information.
  20319. * @param parent defines the object to serialize in
  20320. * @returns the serialized object
  20321. */
  20322. serialize(parent: any): any;
  20323. }
  20324. /**
  20325. * This defines an action responsible to set a the state field of the target
  20326. * to a desired value once triggered.
  20327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20328. */
  20329. export class SetStateAction extends Action {
  20330. /**
  20331. * The value to store in the state field.
  20332. */
  20333. value: string;
  20334. private _target;
  20335. /**
  20336. * Instantiate the action
  20337. * @param triggerOptions defines the trigger options
  20338. * @param target defines the object containing the state property
  20339. * @param value defines the value to store in the state field
  20340. * @param condition defines the trigger related conditions
  20341. */
  20342. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  20343. /**
  20344. * Execute the action and store the value on the target state property.
  20345. */
  20346. execute(): void;
  20347. /**
  20348. * Serializes the actions and its related information.
  20349. * @param parent defines the object to serialize in
  20350. * @returns the serialized object
  20351. */
  20352. serialize(parent: any): any;
  20353. }
  20354. /**
  20355. * This defines an action responsible to set a property of the target
  20356. * to a desired value once triggered.
  20357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20358. */
  20359. export class SetValueAction extends Action {
  20360. /**
  20361. * The path of the property to set in the target.
  20362. */
  20363. propertyPath: string;
  20364. /**
  20365. * The value to set in the property
  20366. */
  20367. value: any;
  20368. private _target;
  20369. private _effectiveTarget;
  20370. private _property;
  20371. /**
  20372. * Instantiate the action
  20373. * @param triggerOptions defines the trigger options
  20374. * @param target defines the object containing the property
  20375. * @param propertyPath defines the path of the property to set in the target
  20376. * @param value defines the value to set in the property
  20377. * @param condition defines the trigger related conditions
  20378. */
  20379. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20380. /** @hidden */
  20381. _prepare(): void;
  20382. /**
  20383. * Execute the action and set the targetted property to the desired value.
  20384. */
  20385. execute(): void;
  20386. /**
  20387. * Serializes the actions and its related information.
  20388. * @param parent defines the object to serialize in
  20389. * @returns the serialized object
  20390. */
  20391. serialize(parent: any): any;
  20392. }
  20393. /**
  20394. * This defines an action responsible to increment the target value
  20395. * to a desired value once triggered.
  20396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20397. */
  20398. export class IncrementValueAction extends Action {
  20399. /**
  20400. * The path of the property to increment in the target.
  20401. */
  20402. propertyPath: string;
  20403. /**
  20404. * The value we should increment the property by.
  20405. */
  20406. value: any;
  20407. private _target;
  20408. private _effectiveTarget;
  20409. private _property;
  20410. /**
  20411. * Instantiate the action
  20412. * @param triggerOptions defines the trigger options
  20413. * @param target defines the object containing the property
  20414. * @param propertyPath defines the path of the property to increment in the target
  20415. * @param value defines the value value we should increment the property by
  20416. * @param condition defines the trigger related conditions
  20417. */
  20418. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  20419. /** @hidden */
  20420. _prepare(): void;
  20421. /**
  20422. * Execute the action and increment the target of the value amount.
  20423. */
  20424. execute(): void;
  20425. /**
  20426. * Serializes the actions and its related information.
  20427. * @param parent defines the object to serialize in
  20428. * @returns the serialized object
  20429. */
  20430. serialize(parent: any): any;
  20431. }
  20432. /**
  20433. * This defines an action responsible to start an animation once triggered.
  20434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20435. */
  20436. export class PlayAnimationAction extends Action {
  20437. /**
  20438. * Where the animation should start (animation frame)
  20439. */
  20440. from: number;
  20441. /**
  20442. * Where the animation should stop (animation frame)
  20443. */
  20444. to: number;
  20445. /**
  20446. * Define if the animation should loop or stop after the first play.
  20447. */
  20448. loop?: boolean;
  20449. private _target;
  20450. /**
  20451. * Instantiate the action
  20452. * @param triggerOptions defines the trigger options
  20453. * @param target defines the target animation or animation name
  20454. * @param from defines from where the animation should start (animation frame)
  20455. * @param end defines where the animation should stop (animation frame)
  20456. * @param loop defines if the animation should loop or stop after the first play
  20457. * @param condition defines the trigger related conditions
  20458. */
  20459. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  20460. /** @hidden */
  20461. _prepare(): void;
  20462. /**
  20463. * Execute the action and play the animation.
  20464. */
  20465. execute(): void;
  20466. /**
  20467. * Serializes the actions and its related information.
  20468. * @param parent defines the object to serialize in
  20469. * @returns the serialized object
  20470. */
  20471. serialize(parent: any): any;
  20472. }
  20473. /**
  20474. * This defines an action responsible to stop an animation once triggered.
  20475. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20476. */
  20477. export class StopAnimationAction extends Action {
  20478. private _target;
  20479. /**
  20480. * Instantiate the action
  20481. * @param triggerOptions defines the trigger options
  20482. * @param target defines the target animation or animation name
  20483. * @param condition defines the trigger related conditions
  20484. */
  20485. constructor(triggerOptions: any, target: any, condition?: Condition);
  20486. /** @hidden */
  20487. _prepare(): void;
  20488. /**
  20489. * Execute the action and stop the animation.
  20490. */
  20491. execute(): void;
  20492. /**
  20493. * Serializes the actions and its related information.
  20494. * @param parent defines the object to serialize in
  20495. * @returns the serialized object
  20496. */
  20497. serialize(parent: any): any;
  20498. }
  20499. /**
  20500. * This defines an action responsible that does nothing once triggered.
  20501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20502. */
  20503. export class DoNothingAction extends Action {
  20504. /**
  20505. * Instantiate the action
  20506. * @param triggerOptions defines the trigger options
  20507. * @param condition defines the trigger related conditions
  20508. */
  20509. constructor(triggerOptions?: any, condition?: Condition);
  20510. /**
  20511. * Execute the action and do nothing.
  20512. */
  20513. execute(): void;
  20514. /**
  20515. * Serializes the actions and its related information.
  20516. * @param parent defines the object to serialize in
  20517. * @returns the serialized object
  20518. */
  20519. serialize(parent: any): any;
  20520. }
  20521. /**
  20522. * This defines an action responsible to trigger several actions once triggered.
  20523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20524. */
  20525. export class CombineAction extends Action {
  20526. /**
  20527. * The list of aggregated animations to run.
  20528. */
  20529. children: Action[];
  20530. /**
  20531. * Instantiate the action
  20532. * @param triggerOptions defines the trigger options
  20533. * @param children defines the list of aggregated animations to run
  20534. * @param condition defines the trigger related conditions
  20535. */
  20536. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  20537. /** @hidden */
  20538. _prepare(): void;
  20539. /**
  20540. * Execute the action and executes all the aggregated actions.
  20541. */
  20542. execute(evt: ActionEvent): void;
  20543. /**
  20544. * Serializes the actions and its related information.
  20545. * @param parent defines the object to serialize in
  20546. * @returns the serialized object
  20547. */
  20548. serialize(parent: any): any;
  20549. }
  20550. /**
  20551. * This defines an action responsible to run code (external event) once triggered.
  20552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20553. */
  20554. export class ExecuteCodeAction extends Action {
  20555. /**
  20556. * The callback function to run.
  20557. */
  20558. func: (evt: ActionEvent) => void;
  20559. /**
  20560. * Instantiate the action
  20561. * @param triggerOptions defines the trigger options
  20562. * @param func defines the callback function to run
  20563. * @param condition defines the trigger related conditions
  20564. */
  20565. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  20566. /**
  20567. * Execute the action and run the attached code.
  20568. */
  20569. execute(evt: ActionEvent): void;
  20570. }
  20571. /**
  20572. * This defines an action responsible to set the parent property of the target once triggered.
  20573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20574. */
  20575. export class SetParentAction extends Action {
  20576. private _parent;
  20577. private _target;
  20578. /**
  20579. * Instantiate the action
  20580. * @param triggerOptions defines the trigger options
  20581. * @param target defines the target containing the parent property
  20582. * @param parent defines from where the animation should start (animation frame)
  20583. * @param condition defines the trigger related conditions
  20584. */
  20585. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  20586. /** @hidden */
  20587. _prepare(): void;
  20588. /**
  20589. * Execute the action and set the parent property.
  20590. */
  20591. execute(): void;
  20592. /**
  20593. * Serializes the actions and its related information.
  20594. * @param parent defines the object to serialize in
  20595. * @returns the serialized object
  20596. */
  20597. serialize(parent: any): any;
  20598. }
  20599. }
  20600. declare module "babylonjs/Actions/abstractActionManager" {
  20601. import { IDisposable } from "babylonjs/scene";
  20602. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  20603. import { IAction } from "babylonjs/Actions/action";
  20604. /**
  20605. * Abstract class used to decouple action Manager from scene and meshes.
  20606. * Do not instantiate.
  20607. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20608. */
  20609. export abstract class AbstractActionManager implements IDisposable {
  20610. /** Gets the list of active triggers */
  20611. static Triggers: {
  20612. [key: string]: number;
  20613. };
  20614. /** Gets the cursor to use when hovering items */
  20615. hoverCursor: string;
  20616. /** Gets the list of actions */
  20617. actions: IAction[];
  20618. /**
  20619. * Releases all associated resources
  20620. */
  20621. abstract dispose(): void;
  20622. /**
  20623. * Does this action manager has pointer triggers
  20624. */
  20625. abstract readonly hasPointerTriggers: boolean;
  20626. /**
  20627. * Does this action manager has pick triggers
  20628. */
  20629. abstract readonly hasPickTriggers: boolean;
  20630. /**
  20631. * Process a specific trigger
  20632. * @param trigger defines the trigger to process
  20633. * @param evt defines the event details to be processed
  20634. */
  20635. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  20636. /**
  20637. * Does this action manager handles actions of any of the given triggers
  20638. * @param triggers defines the triggers to be tested
  20639. * @return a boolean indicating whether one (or more) of the triggers is handled
  20640. */
  20641. abstract hasSpecificTriggers(triggers: number[]): boolean;
  20642. /**
  20643. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20644. * speed.
  20645. * @param triggerA defines the trigger to be tested
  20646. * @param triggerB defines the trigger to be tested
  20647. * @return a boolean indicating whether one (or more) of the triggers is handled
  20648. */
  20649. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20650. /**
  20651. * Does this action manager handles actions of a given trigger
  20652. * @param trigger defines the trigger to be tested
  20653. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20654. * @return whether the trigger is handled
  20655. */
  20656. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20657. /**
  20658. * Serialize this manager to a JSON object
  20659. * @param name defines the property name to store this manager
  20660. * @returns a JSON representation of this manager
  20661. */
  20662. abstract serialize(name: string): any;
  20663. /**
  20664. * Does exist one action manager with at least one trigger
  20665. **/
  20666. static readonly HasTriggers: boolean;
  20667. /**
  20668. * Does exist one action manager with at least one pick trigger
  20669. **/
  20670. static readonly HasPickTriggers: boolean;
  20671. /**
  20672. * Does exist one action manager that handles actions of a given trigger
  20673. * @param trigger defines the trigger to be tested
  20674. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  20675. **/
  20676. static HasSpecificTrigger(trigger: number): boolean;
  20677. }
  20678. }
  20679. declare module "babylonjs/Actions/actionManager" {
  20680. import { Nullable } from "babylonjs/types";
  20681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20682. import { Scene } from "babylonjs/scene";
  20683. import { Action } from "babylonjs/Actions/action";
  20684. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  20685. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  20686. /**
  20687. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  20688. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  20689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  20690. */
  20691. export class ActionManager extends AbstractActionManager {
  20692. /**
  20693. * Nothing
  20694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20695. */
  20696. static readonly NothingTrigger: number;
  20697. /**
  20698. * On pick
  20699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20700. */
  20701. static readonly OnPickTrigger: number;
  20702. /**
  20703. * On left pick
  20704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20705. */
  20706. static readonly OnLeftPickTrigger: number;
  20707. /**
  20708. * On right pick
  20709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20710. */
  20711. static readonly OnRightPickTrigger: number;
  20712. /**
  20713. * On center pick
  20714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20715. */
  20716. static readonly OnCenterPickTrigger: number;
  20717. /**
  20718. * On pick down
  20719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20720. */
  20721. static readonly OnPickDownTrigger: number;
  20722. /**
  20723. * On double pick
  20724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20725. */
  20726. static readonly OnDoublePickTrigger: number;
  20727. /**
  20728. * On pick up
  20729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20730. */
  20731. static readonly OnPickUpTrigger: number;
  20732. /**
  20733. * On pick out.
  20734. * This trigger will only be raised if you also declared a OnPickDown
  20735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20736. */
  20737. static readonly OnPickOutTrigger: number;
  20738. /**
  20739. * On long press
  20740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20741. */
  20742. static readonly OnLongPressTrigger: number;
  20743. /**
  20744. * On pointer over
  20745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20746. */
  20747. static readonly OnPointerOverTrigger: number;
  20748. /**
  20749. * On pointer out
  20750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20751. */
  20752. static readonly OnPointerOutTrigger: number;
  20753. /**
  20754. * On every frame
  20755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20756. */
  20757. static readonly OnEveryFrameTrigger: number;
  20758. /**
  20759. * On intersection enter
  20760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20761. */
  20762. static readonly OnIntersectionEnterTrigger: number;
  20763. /**
  20764. * On intersection exit
  20765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20766. */
  20767. static readonly OnIntersectionExitTrigger: number;
  20768. /**
  20769. * On key down
  20770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20771. */
  20772. static readonly OnKeyDownTrigger: number;
  20773. /**
  20774. * On key up
  20775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  20776. */
  20777. static readonly OnKeyUpTrigger: number;
  20778. private _scene;
  20779. /**
  20780. * Creates a new action manager
  20781. * @param scene defines the hosting scene
  20782. */
  20783. constructor(scene: Scene);
  20784. /**
  20785. * Releases all associated resources
  20786. */
  20787. dispose(): void;
  20788. /**
  20789. * Gets hosting scene
  20790. * @returns the hosting scene
  20791. */
  20792. getScene(): Scene;
  20793. /**
  20794. * Does this action manager handles actions of any of the given triggers
  20795. * @param triggers defines the triggers to be tested
  20796. * @return a boolean indicating whether one (or more) of the triggers is handled
  20797. */
  20798. hasSpecificTriggers(triggers: number[]): boolean;
  20799. /**
  20800. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  20801. * speed.
  20802. * @param triggerA defines the trigger to be tested
  20803. * @param triggerB defines the trigger to be tested
  20804. * @return a boolean indicating whether one (or more) of the triggers is handled
  20805. */
  20806. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  20807. /**
  20808. * Does this action manager handles actions of a given trigger
  20809. * @param trigger defines the trigger to be tested
  20810. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  20811. * @return whether the trigger is handled
  20812. */
  20813. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  20814. /**
  20815. * Does this action manager has pointer triggers
  20816. */
  20817. readonly hasPointerTriggers: boolean;
  20818. /**
  20819. * Does this action manager has pick triggers
  20820. */
  20821. readonly hasPickTriggers: boolean;
  20822. /**
  20823. * Registers an action to this action manager
  20824. * @param action defines the action to be registered
  20825. * @return the action amended (prepared) after registration
  20826. */
  20827. registerAction(action: Action): Nullable<Action>;
  20828. /**
  20829. * Unregisters an action to this action manager
  20830. * @param action defines the action to be unregistered
  20831. * @return a boolean indicating whether the action has been unregistered
  20832. */
  20833. unregisterAction(action: Action): Boolean;
  20834. /**
  20835. * Process a specific trigger
  20836. * @param trigger defines the trigger to process
  20837. * @param evt defines the event details to be processed
  20838. */
  20839. processTrigger(trigger: number, evt?: IActionEvent): void;
  20840. /** @hidden */
  20841. _getEffectiveTarget(target: any, propertyPath: string): any;
  20842. /** @hidden */
  20843. _getProperty(propertyPath: string): string;
  20844. /**
  20845. * Serialize this manager to a JSON object
  20846. * @param name defines the property name to store this manager
  20847. * @returns a JSON representation of this manager
  20848. */
  20849. serialize(name: string): any;
  20850. /**
  20851. * Creates a new ActionManager from a JSON data
  20852. * @param parsedActions defines the JSON data to read from
  20853. * @param object defines the hosting mesh
  20854. * @param scene defines the hosting scene
  20855. */
  20856. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  20857. /**
  20858. * Get a trigger name by index
  20859. * @param trigger defines the trigger index
  20860. * @returns a trigger name
  20861. */
  20862. static GetTriggerName(trigger: number): string;
  20863. }
  20864. }
  20865. declare module "babylonjs/Sprites/sprite" {
  20866. import { Vector3, Color4 } from "babylonjs/Maths/math";
  20867. import { Nullable } from "babylonjs/types";
  20868. import { ActionManager } from "babylonjs/Actions/actionManager";
  20869. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20870. /**
  20871. * Class used to represent a sprite
  20872. * @see http://doc.babylonjs.com/babylon101/sprites
  20873. */
  20874. export class Sprite {
  20875. /** defines the name */
  20876. name: string;
  20877. /** Gets or sets the current world position */
  20878. position: Vector3;
  20879. /** Gets or sets the main color */
  20880. color: Color4;
  20881. /** Gets or sets the width */
  20882. width: number;
  20883. /** Gets or sets the height */
  20884. height: number;
  20885. /** Gets or sets rotation angle */
  20886. angle: number;
  20887. /** Gets or sets the cell index in the sprite sheet */
  20888. cellIndex: number;
  20889. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  20890. invertU: number;
  20891. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  20892. invertV: number;
  20893. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  20894. disposeWhenFinishedAnimating: boolean;
  20895. /** Gets the list of attached animations */
  20896. animations: Animation[];
  20897. /** Gets or sets a boolean indicating if the sprite can be picked */
  20898. isPickable: boolean;
  20899. /**
  20900. * Gets or sets the associated action manager
  20901. */
  20902. actionManager: Nullable<ActionManager>;
  20903. private _animationStarted;
  20904. private _loopAnimation;
  20905. private _fromIndex;
  20906. private _toIndex;
  20907. private _delay;
  20908. private _direction;
  20909. private _manager;
  20910. private _time;
  20911. private _onAnimationEnd;
  20912. /**
  20913. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  20914. */
  20915. isVisible: boolean;
  20916. /**
  20917. * Gets or sets the sprite size
  20918. */
  20919. size: number;
  20920. /**
  20921. * Creates a new Sprite
  20922. * @param name defines the name
  20923. * @param manager defines the manager
  20924. */
  20925. constructor(
  20926. /** defines the name */
  20927. name: string, manager: ISpriteManager);
  20928. /**
  20929. * Starts an animation
  20930. * @param from defines the initial key
  20931. * @param to defines the end key
  20932. * @param loop defines if the animation must loop
  20933. * @param delay defines the start delay (in ms)
  20934. * @param onAnimationEnd defines a callback to call when animation ends
  20935. */
  20936. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  20937. /** Stops current animation (if any) */
  20938. stopAnimation(): void;
  20939. /** @hidden */
  20940. _animate(deltaTime: number): void;
  20941. /** Release associated resources */
  20942. dispose(): void;
  20943. }
  20944. }
  20945. declare module "babylonjs/Collisions/pickingInfo" {
  20946. import { Nullable } from "babylonjs/types";
  20947. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  20948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20949. import { Ray } from "babylonjs/Culling/ray";
  20950. import { Sprite } from "babylonjs/Sprites/sprite";
  20951. /**
  20952. * Information about the result of picking within a scene
  20953. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  20954. */
  20955. export class PickingInfo {
  20956. /**
  20957. * If the pick collided with an object
  20958. */
  20959. hit: boolean;
  20960. /**
  20961. * Distance away where the pick collided
  20962. */
  20963. distance: number;
  20964. /**
  20965. * The location of pick collision
  20966. */
  20967. pickedPoint: Nullable<Vector3>;
  20968. /**
  20969. * The mesh corresponding the the pick collision
  20970. */
  20971. pickedMesh: Nullable<AbstractMesh>;
  20972. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  20973. bu: number;
  20974. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  20975. bv: number;
  20976. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  20977. faceId: number;
  20978. /** Id of the the submesh that was picked */
  20979. subMeshId: number;
  20980. /** If a sprite was picked, this will be the sprite the pick collided with */
  20981. pickedSprite: Nullable<Sprite>;
  20982. /**
  20983. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  20984. */
  20985. originMesh: Nullable<AbstractMesh>;
  20986. /**
  20987. * The ray that was used to perform the picking.
  20988. */
  20989. ray: Nullable<Ray>;
  20990. /**
  20991. * Gets the normal correspodning to the face the pick collided with
  20992. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  20993. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  20994. * @returns The normal correspodning to the face the pick collided with
  20995. */
  20996. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  20997. /**
  20998. * Gets the texture coordinates of where the pick occured
  20999. * @returns the vector containing the coordnates of the texture
  21000. */
  21001. getTextureCoordinates(): Nullable<Vector2>;
  21002. }
  21003. }
  21004. declare module "babylonjs/Culling/ray" {
  21005. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  21006. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21007. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21008. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  21009. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21010. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  21011. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21012. /**
  21013. * Class representing a ray with position and direction
  21014. */
  21015. export class Ray {
  21016. /** origin point */
  21017. origin: Vector3;
  21018. /** direction */
  21019. direction: Vector3;
  21020. /** length of the ray */
  21021. length: number;
  21022. private static readonly TmpVector3;
  21023. private _tmpRay;
  21024. /**
  21025. * Creates a new ray
  21026. * @param origin origin point
  21027. * @param direction direction
  21028. * @param length length of the ray
  21029. */
  21030. constructor(
  21031. /** origin point */
  21032. origin: Vector3,
  21033. /** direction */
  21034. direction: Vector3,
  21035. /** length of the ray */
  21036. length?: number);
  21037. /**
  21038. * Checks if the ray intersects a box
  21039. * @param minimum bound of the box
  21040. * @param maximum bound of the box
  21041. * @param intersectionTreshold extra extend to be added to the box in all direction
  21042. * @returns if the box was hit
  21043. */
  21044. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  21045. /**
  21046. * Checks if the ray intersects a box
  21047. * @param box the bounding box to check
  21048. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  21049. * @returns if the box was hit
  21050. */
  21051. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  21052. /**
  21053. * If the ray hits a sphere
  21054. * @param sphere the bounding sphere to check
  21055. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  21056. * @returns true if it hits the sphere
  21057. */
  21058. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  21059. /**
  21060. * If the ray hits a triange
  21061. * @param vertex0 triangle vertex
  21062. * @param vertex1 triangle vertex
  21063. * @param vertex2 triangle vertex
  21064. * @returns intersection information if hit
  21065. */
  21066. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  21067. /**
  21068. * Checks if ray intersects a plane
  21069. * @param plane the plane to check
  21070. * @returns the distance away it was hit
  21071. */
  21072. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  21073. /**
  21074. * Checks if ray intersects a mesh
  21075. * @param mesh the mesh to check
  21076. * @param fastCheck if only the bounding box should checked
  21077. * @returns picking info of the intersecton
  21078. */
  21079. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  21080. /**
  21081. * Checks if ray intersects a mesh
  21082. * @param meshes the meshes to check
  21083. * @param fastCheck if only the bounding box should checked
  21084. * @param results array to store result in
  21085. * @returns Array of picking infos
  21086. */
  21087. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  21088. private _comparePickingInfo;
  21089. private static smallnum;
  21090. private static rayl;
  21091. /**
  21092. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  21093. * @param sega the first point of the segment to test the intersection against
  21094. * @param segb the second point of the segment to test the intersection against
  21095. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  21096. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  21097. */
  21098. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  21099. /**
  21100. * Update the ray from viewport position
  21101. * @param x position
  21102. * @param y y position
  21103. * @param viewportWidth viewport width
  21104. * @param viewportHeight viewport height
  21105. * @param world world matrix
  21106. * @param view view matrix
  21107. * @param projection projection matrix
  21108. * @returns this ray updated
  21109. */
  21110. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21111. /**
  21112. * Creates a ray with origin and direction of 0,0,0
  21113. * @returns the new ray
  21114. */
  21115. static Zero(): Ray;
  21116. /**
  21117. * Creates a new ray from screen space and viewport
  21118. * @param x position
  21119. * @param y y position
  21120. * @param viewportWidth viewport width
  21121. * @param viewportHeight viewport height
  21122. * @param world world matrix
  21123. * @param view view matrix
  21124. * @param projection projection matrix
  21125. * @returns new ray
  21126. */
  21127. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  21128. /**
  21129. * 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
  21130. * transformed to the given world matrix.
  21131. * @param origin The origin point
  21132. * @param end The end point
  21133. * @param world a matrix to transform the ray to. Default is the identity matrix.
  21134. * @returns the new ray
  21135. */
  21136. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  21137. /**
  21138. * Transforms a ray by a matrix
  21139. * @param ray ray to transform
  21140. * @param matrix matrix to apply
  21141. * @returns the resulting new ray
  21142. */
  21143. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  21144. /**
  21145. * Transforms a ray by a matrix
  21146. * @param ray ray to transform
  21147. * @param matrix matrix to apply
  21148. * @param result ray to store result in
  21149. */
  21150. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  21151. /**
  21152. * Unproject a ray from screen space to object space
  21153. * @param sourceX defines the screen space x coordinate to use
  21154. * @param sourceY defines the screen space y coordinate to use
  21155. * @param viewportWidth defines the current width of the viewport
  21156. * @param viewportHeight defines the current height of the viewport
  21157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  21158. * @param view defines the view matrix to use
  21159. * @param projection defines the projection matrix to use
  21160. */
  21161. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  21162. }
  21163. }
  21164. declare module "babylonjs/Materials/multiMaterial" {
  21165. import { Nullable } from "babylonjs/types";
  21166. import { Scene } from "babylonjs/scene";
  21167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21168. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21169. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21170. import { Material } from "babylonjs/Materials/material";
  21171. /**
  21172. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21173. * separate meshes. This can be use to improve performances.
  21174. * @see http://doc.babylonjs.com/how_to/multi_materials
  21175. */
  21176. export class MultiMaterial extends Material {
  21177. private _subMaterials;
  21178. /**
  21179. * Gets or Sets the list of Materials used within the multi material.
  21180. * They need to be ordered according to the submeshes order in the associated mesh
  21181. */
  21182. subMaterials: Nullable<Material>[];
  21183. /**
  21184. * Function used to align with Node.getChildren()
  21185. * @returns the list of Materials used within the multi material
  21186. */
  21187. getChildren(): Nullable<Material>[];
  21188. /**
  21189. * Instantiates a new Multi Material
  21190. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21191. * separate meshes. This can be use to improve performances.
  21192. * @see http://doc.babylonjs.com/how_to/multi_materials
  21193. * @param name Define the name in the scene
  21194. * @param scene Define the scene the material belongs to
  21195. */
  21196. constructor(name: string, scene: Scene);
  21197. private _hookArray;
  21198. /**
  21199. * Get one of the submaterial by its index in the submaterials array
  21200. * @param index The index to look the sub material at
  21201. * @returns The Material if the index has been defined
  21202. */
  21203. getSubMaterial(index: number): Nullable<Material>;
  21204. /**
  21205. * Get the list of active textures for the whole sub materials list.
  21206. * @returns All the textures that will be used during the rendering
  21207. */
  21208. getActiveTextures(): BaseTexture[];
  21209. /**
  21210. * Gets the current class name of the material e.g. "MultiMaterial"
  21211. * Mainly use in serialization.
  21212. * @returns the class name
  21213. */
  21214. getClassName(): string;
  21215. /**
  21216. * Checks if the material is ready to render the requested sub mesh
  21217. * @param mesh Define the mesh the submesh belongs to
  21218. * @param subMesh Define the sub mesh to look readyness for
  21219. * @param useInstances Define whether or not the material is used with instances
  21220. * @returns true if ready, otherwise false
  21221. */
  21222. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21223. /**
  21224. * Clones the current material and its related sub materials
  21225. * @param name Define the name of the newly cloned material
  21226. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21227. * @returns the cloned material
  21228. */
  21229. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21230. /**
  21231. * Serializes the materials into a JSON representation.
  21232. * @returns the JSON representation
  21233. */
  21234. serialize(): any;
  21235. /**
  21236. * Dispose the material and release its associated resources
  21237. * @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)
  21238. * @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)
  21239. * @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)
  21240. */
  21241. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21242. /**
  21243. * Creates a MultiMaterial from parsed MultiMaterial data.
  21244. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21245. * @param scene defines the hosting scene
  21246. * @returns a new MultiMaterial
  21247. */
  21248. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21249. }
  21250. }
  21251. declare module "babylonjs/Meshes/subMesh" {
  21252. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  21253. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  21254. import { Engine } from "babylonjs/Engines/engine";
  21255. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21256. import { Ray } from "babylonjs/Culling/ray";
  21257. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21258. import { Effect } from "babylonjs/Materials/effect";
  21259. import { Collider } from "babylonjs/Collisions/collider";
  21260. import { Material } from "babylonjs/Materials/material";
  21261. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21263. import { Mesh } from "babylonjs/Meshes/mesh";
  21264. /**
  21265. * Base class for submeshes
  21266. */
  21267. export class BaseSubMesh {
  21268. /** @hidden */
  21269. _materialDefines: Nullable<MaterialDefines>;
  21270. /** @hidden */
  21271. _materialEffect: Nullable<Effect>;
  21272. /**
  21273. * Gets associated effect
  21274. */
  21275. readonly effect: Nullable<Effect>;
  21276. /**
  21277. * Sets associated effect (effect used to render this submesh)
  21278. * @param effect defines the effect to associate with
  21279. * @param defines defines the set of defines used to compile this effect
  21280. */
  21281. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21282. }
  21283. /**
  21284. * Defines a subdivision inside a mesh
  21285. */
  21286. export class SubMesh extends BaseSubMesh implements ICullable {
  21287. /** the material index to use */
  21288. materialIndex: number;
  21289. /** vertex index start */
  21290. verticesStart: number;
  21291. /** vertices count */
  21292. verticesCount: number;
  21293. /** index start */
  21294. indexStart: number;
  21295. /** indices count */
  21296. indexCount: number;
  21297. /** @hidden */
  21298. _linesIndexCount: number;
  21299. private _mesh;
  21300. private _renderingMesh;
  21301. private _boundingInfo;
  21302. private _linesIndexBuffer;
  21303. /** @hidden */
  21304. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21305. /** @hidden */
  21306. _trianglePlanes: Plane[];
  21307. /** @hidden */
  21308. _lastColliderTransformMatrix: Matrix;
  21309. /** @hidden */
  21310. _renderId: number;
  21311. /** @hidden */
  21312. _alphaIndex: number;
  21313. /** @hidden */
  21314. _distanceToCamera: number;
  21315. /** @hidden */
  21316. _id: number;
  21317. private _currentMaterial;
  21318. /**
  21319. * Add a new submesh to a mesh
  21320. * @param materialIndex defines the material index to use
  21321. * @param verticesStart defines vertex index start
  21322. * @param verticesCount defines vertices count
  21323. * @param indexStart defines index start
  21324. * @param indexCount defines indices count
  21325. * @param mesh defines the parent mesh
  21326. * @param renderingMesh defines an optional rendering mesh
  21327. * @param createBoundingBox defines if bounding box should be created for this submesh
  21328. * @returns the new submesh
  21329. */
  21330. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21331. /**
  21332. * Creates a new submesh
  21333. * @param materialIndex defines the material index to use
  21334. * @param verticesStart defines vertex index start
  21335. * @param verticesCount defines vertices count
  21336. * @param indexStart defines index start
  21337. * @param indexCount defines indices count
  21338. * @param mesh defines the parent mesh
  21339. * @param renderingMesh defines an optional rendering mesh
  21340. * @param createBoundingBox defines if bounding box should be created for this submesh
  21341. */
  21342. constructor(
  21343. /** the material index to use */
  21344. materialIndex: number,
  21345. /** vertex index start */
  21346. verticesStart: number,
  21347. /** vertices count */
  21348. verticesCount: number,
  21349. /** index start */
  21350. indexStart: number,
  21351. /** indices count */
  21352. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21353. /**
  21354. * Returns true if this submesh covers the entire parent mesh
  21355. * @ignorenaming
  21356. */
  21357. readonly IsGlobal: boolean;
  21358. /**
  21359. * Returns the submesh BoudingInfo object
  21360. * @returns current bounding info (or mesh's one if the submesh is global)
  21361. */
  21362. getBoundingInfo(): BoundingInfo;
  21363. /**
  21364. * Sets the submesh BoundingInfo
  21365. * @param boundingInfo defines the new bounding info to use
  21366. * @returns the SubMesh
  21367. */
  21368. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21369. /**
  21370. * Returns the mesh of the current submesh
  21371. * @return the parent mesh
  21372. */
  21373. getMesh(): AbstractMesh;
  21374. /**
  21375. * Returns the rendering mesh of the submesh
  21376. * @returns the rendering mesh (could be different from parent mesh)
  21377. */
  21378. getRenderingMesh(): Mesh;
  21379. /**
  21380. * Returns the submesh material
  21381. * @returns null or the current material
  21382. */
  21383. getMaterial(): Nullable<Material>;
  21384. /**
  21385. * Sets a new updated BoundingInfo object to the submesh
  21386. * @returns the SubMesh
  21387. */
  21388. refreshBoundingInfo(): SubMesh;
  21389. /** @hidden */
  21390. _checkCollision(collider: Collider): boolean;
  21391. /**
  21392. * Updates the submesh BoundingInfo
  21393. * @param world defines the world matrix to use to update the bounding info
  21394. * @returns the submesh
  21395. */
  21396. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21397. /**
  21398. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21399. * @param frustumPlanes defines the frustum planes
  21400. * @returns true if the submesh is intersecting with the frustum
  21401. */
  21402. isInFrustum(frustumPlanes: Plane[]): boolean;
  21403. /**
  21404. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21405. * @param frustumPlanes defines the frustum planes
  21406. * @returns true if the submesh is inside the frustum
  21407. */
  21408. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21409. /**
  21410. * Renders the submesh
  21411. * @param enableAlphaMode defines if alpha needs to be used
  21412. * @returns the submesh
  21413. */
  21414. render(enableAlphaMode: boolean): SubMesh;
  21415. /**
  21416. * @hidden
  21417. */
  21418. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21419. /**
  21420. * Checks if the submesh intersects with a ray
  21421. * @param ray defines the ray to test
  21422. * @returns true is the passed ray intersects the submesh bounding box
  21423. */
  21424. canIntersects(ray: Ray): boolean;
  21425. /**
  21426. * Intersects current submesh with a ray
  21427. * @param ray defines the ray to test
  21428. * @param positions defines mesh's positions array
  21429. * @param indices defines mesh's indices array
  21430. * @param fastCheck defines if only bounding info should be used
  21431. * @returns intersection info or null if no intersection
  21432. */
  21433. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  21434. /** @hidden */
  21435. private _intersectLines;
  21436. /** @hidden */
  21437. private _intersectTriangles;
  21438. /** @hidden */
  21439. _rebuild(): void;
  21440. /**
  21441. * Creates a new submesh from the passed mesh
  21442. * @param newMesh defines the new hosting mesh
  21443. * @param newRenderingMesh defines an optional rendering mesh
  21444. * @returns the new submesh
  21445. */
  21446. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21447. /**
  21448. * Release associated resources
  21449. */
  21450. dispose(): void;
  21451. /**
  21452. * Gets the class name
  21453. * @returns the string "SubMesh".
  21454. */
  21455. getClassName(): string;
  21456. /**
  21457. * Creates a new submesh from indices data
  21458. * @param materialIndex the index of the main mesh material
  21459. * @param startIndex the index where to start the copy in the mesh indices array
  21460. * @param indexCount the number of indices to copy then from the startIndex
  21461. * @param mesh the main mesh to create the submesh from
  21462. * @param renderingMesh the optional rendering mesh
  21463. * @returns a new submesh
  21464. */
  21465. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21466. }
  21467. }
  21468. declare module "babylonjs/Meshes/geometry" {
  21469. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21470. import { Scene } from "babylonjs/scene";
  21471. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  21472. import { Engine } from "babylonjs/Engines/engine";
  21473. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21474. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21475. import { Effect } from "babylonjs/Materials/effect";
  21476. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21477. import { Mesh } from "babylonjs/Meshes/mesh";
  21478. /**
  21479. * Class used to store geometry data (vertex buffers + index buffer)
  21480. */
  21481. export class Geometry implements IGetSetVerticesData {
  21482. /**
  21483. * Gets or sets the ID of the geometry
  21484. */
  21485. id: string;
  21486. /**
  21487. * Gets or sets the unique ID of the geometry
  21488. */
  21489. uniqueId: number;
  21490. /**
  21491. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21492. */
  21493. delayLoadState: number;
  21494. /**
  21495. * Gets the file containing the data to load when running in delay load state
  21496. */
  21497. delayLoadingFile: Nullable<string>;
  21498. /**
  21499. * Callback called when the geometry is updated
  21500. */
  21501. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21502. private _scene;
  21503. private _engine;
  21504. private _meshes;
  21505. private _totalVertices;
  21506. /** @hidden */
  21507. _indices: IndicesArray;
  21508. /** @hidden */
  21509. _vertexBuffers: {
  21510. [key: string]: VertexBuffer;
  21511. };
  21512. private _isDisposed;
  21513. private _extend;
  21514. private _boundingBias;
  21515. /** @hidden */
  21516. _delayInfo: Array<string>;
  21517. private _indexBuffer;
  21518. private _indexBufferIsUpdatable;
  21519. /** @hidden */
  21520. _boundingInfo: Nullable<BoundingInfo>;
  21521. /** @hidden */
  21522. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21523. /** @hidden */
  21524. _softwareSkinningFrameId: number;
  21525. private _vertexArrayObjects;
  21526. private _updatable;
  21527. /** @hidden */
  21528. _positions: Nullable<Vector3[]>;
  21529. /**
  21530. * 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
  21531. */
  21532. /**
  21533. * 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
  21534. */
  21535. boundingBias: Vector2;
  21536. /**
  21537. * Static function used to attach a new empty geometry to a mesh
  21538. * @param mesh defines the mesh to attach the geometry to
  21539. * @returns the new Geometry
  21540. */
  21541. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21542. /**
  21543. * Creates a new geometry
  21544. * @param id defines the unique ID
  21545. * @param scene defines the hosting scene
  21546. * @param vertexData defines the VertexData used to get geometry data
  21547. * @param updatable defines if geometry must be updatable (false by default)
  21548. * @param mesh defines the mesh that will be associated with the geometry
  21549. */
  21550. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21551. /**
  21552. * Gets the current extend of the geometry
  21553. */
  21554. readonly extend: {
  21555. minimum: Vector3;
  21556. maximum: Vector3;
  21557. };
  21558. /**
  21559. * Gets the hosting scene
  21560. * @returns the hosting Scene
  21561. */
  21562. getScene(): Scene;
  21563. /**
  21564. * Gets the hosting engine
  21565. * @returns the hosting Engine
  21566. */
  21567. getEngine(): Engine;
  21568. /**
  21569. * Defines if the geometry is ready to use
  21570. * @returns true if the geometry is ready to be used
  21571. */
  21572. isReady(): boolean;
  21573. /**
  21574. * Gets a value indicating that the geometry should not be serialized
  21575. */
  21576. readonly doNotSerialize: boolean;
  21577. /** @hidden */
  21578. _rebuild(): void;
  21579. /**
  21580. * Affects all geometry data in one call
  21581. * @param vertexData defines the geometry data
  21582. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21583. */
  21584. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21585. /**
  21586. * Set specific vertex data
  21587. * @param kind defines the data kind (Position, normal, etc...)
  21588. * @param data defines the vertex data to use
  21589. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21590. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21591. */
  21592. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21593. /**
  21594. * Removes a specific vertex data
  21595. * @param kind defines the data kind (Position, normal, etc...)
  21596. */
  21597. removeVerticesData(kind: string): void;
  21598. /**
  21599. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21600. * @param buffer defines the vertex buffer to use
  21601. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21602. */
  21603. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21604. /**
  21605. * Update a specific vertex buffer
  21606. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  21607. * It will do nothing if the buffer is not updatable
  21608. * @param kind defines the data kind (Position, normal, etc...)
  21609. * @param data defines the data to use
  21610. * @param offset defines the offset in the target buffer where to store the data
  21611. * @param useBytes set to true if the offset is in bytes
  21612. */
  21613. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21614. /**
  21615. * Update a specific vertex buffer
  21616. * This function will create a new buffer if the current one is not updatable
  21617. * @param kind defines the data kind (Position, normal, etc...)
  21618. * @param data defines the data to use
  21619. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21620. */
  21621. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21622. private _updateBoundingInfo;
  21623. /** @hidden */
  21624. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  21625. /**
  21626. * Gets total number of vertices
  21627. * @returns the total number of vertices
  21628. */
  21629. getTotalVertices(): number;
  21630. /**
  21631. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21632. * @param kind defines the data kind (Position, normal, etc...)
  21633. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21634. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21635. * @returns a float array containing vertex data
  21636. */
  21637. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21638. /**
  21639. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21640. * @param kind defines the data kind (Position, normal, etc...)
  21641. * @returns true if the vertex buffer with the specified kind is updatable
  21642. */
  21643. isVertexBufferUpdatable(kind: string): boolean;
  21644. /**
  21645. * Gets a specific vertex buffer
  21646. * @param kind defines the data kind (Position, normal, etc...)
  21647. * @returns a VertexBuffer
  21648. */
  21649. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21650. /**
  21651. * Returns all vertex buffers
  21652. * @return an object holding all vertex buffers indexed by kind
  21653. */
  21654. getVertexBuffers(): Nullable<{
  21655. [key: string]: VertexBuffer;
  21656. }>;
  21657. /**
  21658. * Gets a boolean indicating if specific vertex buffer is present
  21659. * @param kind defines the data kind (Position, normal, etc...)
  21660. * @returns true if data is present
  21661. */
  21662. isVerticesDataPresent(kind: string): boolean;
  21663. /**
  21664. * Gets a list of all attached data kinds (Position, normal, etc...)
  21665. * @returns a list of string containing all kinds
  21666. */
  21667. getVerticesDataKinds(): string[];
  21668. /**
  21669. * Update index buffer
  21670. * @param indices defines the indices to store in the index buffer
  21671. * @param offset defines the offset in the target buffer where to store the data
  21672. */
  21673. updateIndices(indices: IndicesArray, offset?: number): void;
  21674. /**
  21675. * Creates a new index buffer
  21676. * @param indices defines the indices to store in the index buffer
  21677. * @param totalVertices defines the total number of vertices (could be null)
  21678. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21679. */
  21680. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21681. /**
  21682. * Return the total number of indices
  21683. * @returns the total number of indices
  21684. */
  21685. getTotalIndices(): number;
  21686. /**
  21687. * Gets the index buffer array
  21688. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21689. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21690. * @returns the index buffer array
  21691. */
  21692. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21693. /**
  21694. * Gets the index buffer
  21695. * @return the index buffer
  21696. */
  21697. getIndexBuffer(): Nullable<WebGLBuffer>;
  21698. /** @hidden */
  21699. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21700. /**
  21701. * Release the associated resources for a specific mesh
  21702. * @param mesh defines the source mesh
  21703. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21704. */
  21705. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21706. /**
  21707. * Apply current geometry to a given mesh
  21708. * @param mesh defines the mesh to apply geometry to
  21709. */
  21710. applyToMesh(mesh: Mesh): void;
  21711. private _updateExtend;
  21712. private _applyToMesh;
  21713. private notifyUpdate;
  21714. /**
  21715. * Load the geometry if it was flagged as delay loaded
  21716. * @param scene defines the hosting scene
  21717. * @param onLoaded defines a callback called when the geometry is loaded
  21718. */
  21719. load(scene: Scene, onLoaded?: () => void): void;
  21720. private _queueLoad;
  21721. /**
  21722. * Invert the geometry to move from a right handed system to a left handed one.
  21723. */
  21724. toLeftHanded(): void;
  21725. /** @hidden */
  21726. _resetPointsArrayCache(): void;
  21727. /** @hidden */
  21728. _generatePointsArray(): boolean;
  21729. /**
  21730. * Gets a value indicating if the geometry is disposed
  21731. * @returns true if the geometry was disposed
  21732. */
  21733. isDisposed(): boolean;
  21734. private _disposeVertexArrayObjects;
  21735. /**
  21736. * Free all associated resources
  21737. */
  21738. dispose(): void;
  21739. /**
  21740. * Clone the current geometry into a new geometry
  21741. * @param id defines the unique ID of the new geometry
  21742. * @returns a new geometry object
  21743. */
  21744. copy(id: string): Geometry;
  21745. /**
  21746. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21747. * @return a JSON representation of the current geometry data (without the vertices data)
  21748. */
  21749. serialize(): any;
  21750. private toNumberArray;
  21751. /**
  21752. * Serialize all vertices data into a JSON oject
  21753. * @returns a JSON representation of the current geometry data
  21754. */
  21755. serializeVerticeData(): any;
  21756. /**
  21757. * Extracts a clone of a mesh geometry
  21758. * @param mesh defines the source mesh
  21759. * @param id defines the unique ID of the new geometry object
  21760. * @returns the new geometry object
  21761. */
  21762. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21763. /**
  21764. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21765. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21766. * Be aware Math.random() could cause collisions, but:
  21767. * "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"
  21768. * @returns a string containing a new GUID
  21769. */
  21770. static RandomId(): string;
  21771. /** @hidden */
  21772. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21773. private static _CleanMatricesWeights;
  21774. /**
  21775. * Create a new geometry from persisted data (Using .babylon file format)
  21776. * @param parsedVertexData defines the persisted data
  21777. * @param scene defines the hosting scene
  21778. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21779. * @returns the new geometry object
  21780. */
  21781. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21782. }
  21783. }
  21784. declare module "babylonjs/Meshes/mesh.vertexData" {
  21785. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21786. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  21787. import { Geometry } from "babylonjs/Meshes/geometry";
  21788. import { Mesh } from "babylonjs/Meshes/mesh";
  21789. /**
  21790. * Define an interface for all classes that will get and set the data on vertices
  21791. */
  21792. export interface IGetSetVerticesData {
  21793. /**
  21794. * Gets a boolean indicating if specific vertex data is present
  21795. * @param kind defines the vertex data kind to use
  21796. * @returns true is data kind is present
  21797. */
  21798. isVerticesDataPresent(kind: string): boolean;
  21799. /**
  21800. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21801. * @param kind defines the data kind (Position, normal, etc...)
  21802. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21803. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21804. * @returns a float array containing vertex data
  21805. */
  21806. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21807. /**
  21808. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21809. * @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.
  21810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21811. * @returns the indices array or an empty array if the mesh has no geometry
  21812. */
  21813. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21814. /**
  21815. * Set specific vertex data
  21816. * @param kind defines the data kind (Position, normal, etc...)
  21817. * @param data defines the vertex data to use
  21818. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21819. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21820. */
  21821. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21822. /**
  21823. * Update a specific associated vertex buffer
  21824. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21825. * - VertexBuffer.PositionKind
  21826. * - VertexBuffer.UVKind
  21827. * - VertexBuffer.UV2Kind
  21828. * - VertexBuffer.UV3Kind
  21829. * - VertexBuffer.UV4Kind
  21830. * - VertexBuffer.UV5Kind
  21831. * - VertexBuffer.UV6Kind
  21832. * - VertexBuffer.ColorKind
  21833. * - VertexBuffer.MatricesIndicesKind
  21834. * - VertexBuffer.MatricesIndicesExtraKind
  21835. * - VertexBuffer.MatricesWeightsKind
  21836. * - VertexBuffer.MatricesWeightsExtraKind
  21837. * @param data defines the data source
  21838. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21839. * @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)
  21840. */
  21841. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21842. /**
  21843. * Creates a new index buffer
  21844. * @param indices defines the indices to store in the index buffer
  21845. * @param totalVertices defines the total number of vertices (could be null)
  21846. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21847. */
  21848. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21849. }
  21850. /**
  21851. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21852. */
  21853. export class VertexData {
  21854. /**
  21855. * Mesh side orientation : usually the external or front surface
  21856. */
  21857. static readonly FRONTSIDE: number;
  21858. /**
  21859. * Mesh side orientation : usually the internal or back surface
  21860. */
  21861. static readonly BACKSIDE: number;
  21862. /**
  21863. * Mesh side orientation : both internal and external or front and back surfaces
  21864. */
  21865. static readonly DOUBLESIDE: number;
  21866. /**
  21867. * Mesh side orientation : by default, `FRONTSIDE`
  21868. */
  21869. static readonly DEFAULTSIDE: number;
  21870. /**
  21871. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21872. */
  21873. positions: Nullable<FloatArray>;
  21874. /**
  21875. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21876. */
  21877. normals: Nullable<FloatArray>;
  21878. /**
  21879. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21880. */
  21881. tangents: Nullable<FloatArray>;
  21882. /**
  21883. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21884. */
  21885. uvs: Nullable<FloatArray>;
  21886. /**
  21887. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21888. */
  21889. uvs2: Nullable<FloatArray>;
  21890. /**
  21891. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21892. */
  21893. uvs3: Nullable<FloatArray>;
  21894. /**
  21895. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21896. */
  21897. uvs4: Nullable<FloatArray>;
  21898. /**
  21899. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21900. */
  21901. uvs5: Nullable<FloatArray>;
  21902. /**
  21903. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21904. */
  21905. uvs6: Nullable<FloatArray>;
  21906. /**
  21907. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21908. */
  21909. colors: Nullable<FloatArray>;
  21910. /**
  21911. * 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).
  21912. */
  21913. matricesIndices: Nullable<FloatArray>;
  21914. /**
  21915. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21916. */
  21917. matricesWeights: Nullable<FloatArray>;
  21918. /**
  21919. * An array extending the number of possible indices
  21920. */
  21921. matricesIndicesExtra: Nullable<FloatArray>;
  21922. /**
  21923. * An array extending the number of possible weights when the number of indices is extended
  21924. */
  21925. matricesWeightsExtra: Nullable<FloatArray>;
  21926. /**
  21927. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21928. */
  21929. indices: Nullable<IndicesArray>;
  21930. /**
  21931. * Uses the passed data array to set the set the values for the specified kind of data
  21932. * @param data a linear array of floating numbers
  21933. * @param kind the type of data that is being set, eg positions, colors etc
  21934. */
  21935. set(data: FloatArray, kind: string): void;
  21936. /**
  21937. * Associates the vertexData to the passed Mesh.
  21938. * Sets it as updatable or not (default `false`)
  21939. * @param mesh the mesh the vertexData is applied to
  21940. * @param updatable when used and having the value true allows new data to update the vertexData
  21941. * @returns the VertexData
  21942. */
  21943. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  21944. /**
  21945. * Associates the vertexData to the passed Geometry.
  21946. * Sets it as updatable or not (default `false`)
  21947. * @param geometry the geometry the vertexData is applied to
  21948. * @param updatable when used and having the value true allows new data to update the vertexData
  21949. * @returns VertexData
  21950. */
  21951. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  21952. /**
  21953. * Updates the associated mesh
  21954. * @param mesh the mesh to be updated
  21955. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21956. * @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
  21957. * @returns VertexData
  21958. */
  21959. updateMesh(mesh: Mesh): VertexData;
  21960. /**
  21961. * Updates the associated geometry
  21962. * @param geometry the geometry to be updated
  21963. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  21964. * @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
  21965. * @returns VertexData.
  21966. */
  21967. updateGeometry(geometry: Geometry): VertexData;
  21968. private _applyTo;
  21969. private _update;
  21970. /**
  21971. * Transforms each position and each normal of the vertexData according to the passed Matrix
  21972. * @param matrix the transforming matrix
  21973. * @returns the VertexData
  21974. */
  21975. transform(matrix: Matrix): VertexData;
  21976. /**
  21977. * Merges the passed VertexData into the current one
  21978. * @param other the VertexData to be merged into the current one
  21979. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  21980. * @returns the modified VertexData
  21981. */
  21982. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  21983. private _mergeElement;
  21984. private _validate;
  21985. /**
  21986. * Serializes the VertexData
  21987. * @returns a serialized object
  21988. */
  21989. serialize(): any;
  21990. /**
  21991. * Extracts the vertexData from a mesh
  21992. * @param mesh the mesh from which to extract the VertexData
  21993. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  21994. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  21995. * @returns the object VertexData associated to the passed mesh
  21996. */
  21997. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  21998. /**
  21999. * Extracts the vertexData from the geometry
  22000. * @param geometry the geometry from which to extract the VertexData
  22001. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22002. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22003. * @returns the object VertexData associated to the passed mesh
  22004. */
  22005. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22006. private static _ExtractFrom;
  22007. /**
  22008. * Creates the VertexData for a Ribbon
  22009. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22010. * * pathArray array of paths, each of which an array of successive Vector3
  22011. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22012. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22013. * * 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
  22014. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22015. * * 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)
  22016. * * 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)
  22017. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22018. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22019. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22020. * @returns the VertexData of the ribbon
  22021. */
  22022. static CreateRibbon(options: {
  22023. pathArray: Vector3[][];
  22024. closeArray?: boolean;
  22025. closePath?: boolean;
  22026. offset?: number;
  22027. sideOrientation?: number;
  22028. frontUVs?: Vector4;
  22029. backUVs?: Vector4;
  22030. invertUV?: boolean;
  22031. uvs?: Vector2[];
  22032. colors?: Color4[];
  22033. }): VertexData;
  22034. /**
  22035. * Creates the VertexData for a box
  22036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22037. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22038. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22039. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22040. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22041. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22042. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22044. * * 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)
  22045. * * 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)
  22046. * @returns the VertexData of the box
  22047. */
  22048. static CreateBox(options: {
  22049. size?: number;
  22050. width?: number;
  22051. height?: number;
  22052. depth?: number;
  22053. faceUV?: Vector4[];
  22054. faceColors?: Color4[];
  22055. sideOrientation?: number;
  22056. frontUVs?: Vector4;
  22057. backUVs?: Vector4;
  22058. }): VertexData;
  22059. /**
  22060. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22061. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22062. * * segments sets the number of horizontal strips optional, default 32
  22063. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22064. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22065. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22066. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22067. * * 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
  22068. * * 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
  22069. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22070. * * 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)
  22071. * * 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)
  22072. * @returns the VertexData of the ellipsoid
  22073. */
  22074. static CreateSphere(options: {
  22075. segments?: number;
  22076. diameter?: number;
  22077. diameterX?: number;
  22078. diameterY?: number;
  22079. diameterZ?: number;
  22080. arc?: number;
  22081. slice?: number;
  22082. sideOrientation?: number;
  22083. frontUVs?: Vector4;
  22084. backUVs?: Vector4;
  22085. }): VertexData;
  22086. /**
  22087. * Creates the VertexData for a cylinder, cone or prism
  22088. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22089. * * height sets the height (y direction) of the cylinder, optional, default 2
  22090. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22091. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22092. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22093. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22094. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22095. * * 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
  22096. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22097. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22098. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22099. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22100. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22101. * * 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)
  22102. * * 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)
  22103. * @returns the VertexData of the cylinder, cone or prism
  22104. */
  22105. static CreateCylinder(options: {
  22106. height?: number;
  22107. diameterTop?: number;
  22108. diameterBottom?: number;
  22109. diameter?: number;
  22110. tessellation?: number;
  22111. subdivisions?: number;
  22112. arc?: number;
  22113. faceColors?: Color4[];
  22114. faceUV?: Vector4[];
  22115. hasRings?: boolean;
  22116. enclose?: boolean;
  22117. sideOrientation?: number;
  22118. frontUVs?: Vector4;
  22119. backUVs?: Vector4;
  22120. }): VertexData;
  22121. /**
  22122. * Creates the VertexData for a torus
  22123. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22124. * * diameter the diameter of the torus, optional default 1
  22125. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22126. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22127. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22128. * * 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)
  22129. * * 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)
  22130. * @returns the VertexData of the torus
  22131. */
  22132. static CreateTorus(options: {
  22133. diameter?: number;
  22134. thickness?: number;
  22135. tessellation?: number;
  22136. sideOrientation?: number;
  22137. frontUVs?: Vector4;
  22138. backUVs?: Vector4;
  22139. }): VertexData;
  22140. /**
  22141. * Creates the VertexData of the LineSystem
  22142. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22143. * - lines an array of lines, each line being an array of successive Vector3
  22144. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22145. * @returns the VertexData of the LineSystem
  22146. */
  22147. static CreateLineSystem(options: {
  22148. lines: Vector3[][];
  22149. colors?: Nullable<Color4[][]>;
  22150. }): VertexData;
  22151. /**
  22152. * Create the VertexData for a DashedLines
  22153. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22154. * - points an array successive Vector3
  22155. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22156. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22157. * - dashNb the intended total number of dashes, optional, default 200
  22158. * @returns the VertexData for the DashedLines
  22159. */
  22160. static CreateDashedLines(options: {
  22161. points: Vector3[];
  22162. dashSize?: number;
  22163. gapSize?: number;
  22164. dashNb?: number;
  22165. }): VertexData;
  22166. /**
  22167. * Creates the VertexData for a Ground
  22168. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22169. * - width the width (x direction) of the ground, optional, default 1
  22170. * - height the height (z direction) of the ground, optional, default 1
  22171. * - subdivisions the number of subdivisions per side, optional, default 1
  22172. * @returns the VertexData of the Ground
  22173. */
  22174. static CreateGround(options: {
  22175. width?: number;
  22176. height?: number;
  22177. subdivisions?: number;
  22178. subdivisionsX?: number;
  22179. subdivisionsY?: number;
  22180. }): VertexData;
  22181. /**
  22182. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22183. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22184. * * xmin the ground minimum X coordinate, optional, default -1
  22185. * * zmin the ground minimum Z coordinate, optional, default -1
  22186. * * xmax the ground maximum X coordinate, optional, default 1
  22187. * * zmax the ground maximum Z coordinate, optional, default 1
  22188. * * 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}
  22189. * * 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}
  22190. * @returns the VertexData of the TiledGround
  22191. */
  22192. static CreateTiledGround(options: {
  22193. xmin: number;
  22194. zmin: number;
  22195. xmax: number;
  22196. zmax: number;
  22197. subdivisions?: {
  22198. w: number;
  22199. h: number;
  22200. };
  22201. precision?: {
  22202. w: number;
  22203. h: number;
  22204. };
  22205. }): VertexData;
  22206. /**
  22207. * Creates the VertexData of the Ground designed from a heightmap
  22208. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22209. * * width the width (x direction) of the ground
  22210. * * height the height (z direction) of the ground
  22211. * * subdivisions the number of subdivisions per side
  22212. * * minHeight the minimum altitude on the ground, optional, default 0
  22213. * * maxHeight the maximum altitude on the ground, optional default 1
  22214. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22215. * * buffer the array holding the image color data
  22216. * * bufferWidth the width of image
  22217. * * bufferHeight the height of image
  22218. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22219. * @returns the VertexData of the Ground designed from a heightmap
  22220. */
  22221. static CreateGroundFromHeightMap(options: {
  22222. width: number;
  22223. height: number;
  22224. subdivisions: number;
  22225. minHeight: number;
  22226. maxHeight: number;
  22227. colorFilter: Color3;
  22228. buffer: Uint8Array;
  22229. bufferWidth: number;
  22230. bufferHeight: number;
  22231. alphaFilter: number;
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData for a Plane
  22235. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22236. * * size sets the width and height of the plane to the value of size, optional default 1
  22237. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22238. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22239. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22240. * * 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)
  22241. * * 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)
  22242. * @returns the VertexData of the box
  22243. */
  22244. static CreatePlane(options: {
  22245. size?: number;
  22246. width?: number;
  22247. height?: number;
  22248. sideOrientation?: number;
  22249. frontUVs?: Vector4;
  22250. backUVs?: Vector4;
  22251. }): VertexData;
  22252. /**
  22253. * Creates the VertexData of the Disc or regular Polygon
  22254. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22255. * * radius the radius of the disc, optional default 0.5
  22256. * * tessellation the number of polygon sides, optional, default 64
  22257. * * 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
  22258. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22259. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22260. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22261. * @returns the VertexData of the box
  22262. */
  22263. static CreateDisc(options: {
  22264. radius?: number;
  22265. tessellation?: number;
  22266. arc?: number;
  22267. sideOrientation?: number;
  22268. frontUVs?: Vector4;
  22269. backUVs?: Vector4;
  22270. }): VertexData;
  22271. /**
  22272. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22273. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22274. * @param polygon a mesh built from polygonTriangulation.build()
  22275. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22276. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22277. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22278. * @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)
  22279. * @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)
  22280. * @returns the VertexData of the Polygon
  22281. */
  22282. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22283. /**
  22284. * Creates the VertexData of the IcoSphere
  22285. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22286. * * radius the radius of the IcoSphere, optional default 1
  22287. * * radiusX allows stretching in the x direction, optional, default radius
  22288. * * radiusY allows stretching in the y direction, optional, default radius
  22289. * * radiusZ allows stretching in the z direction, optional, default radius
  22290. * * flat when true creates a flat shaded mesh, optional, default true
  22291. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22293. * * 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)
  22294. * * 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)
  22295. * @returns the VertexData of the IcoSphere
  22296. */
  22297. static CreateIcoSphere(options: {
  22298. radius?: number;
  22299. radiusX?: number;
  22300. radiusY?: number;
  22301. radiusZ?: number;
  22302. flat?: boolean;
  22303. subdivisions?: number;
  22304. sideOrientation?: number;
  22305. frontUVs?: Vector4;
  22306. backUVs?: Vector4;
  22307. }): VertexData;
  22308. /**
  22309. * Creates the VertexData for a Polyhedron
  22310. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22311. * * type provided types are:
  22312. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22313. * * 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)
  22314. * * size the size of the IcoSphere, optional default 1
  22315. * * sizeX allows stretching in the x direction, optional, default size
  22316. * * sizeY allows stretching in the y direction, optional, default size
  22317. * * sizeZ allows stretching in the z direction, optional, default size
  22318. * * 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
  22319. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22320. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22321. * * flat when true creates a flat shaded mesh, optional, default true
  22322. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22324. * * 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)
  22325. * * 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)
  22326. * @returns the VertexData of the Polyhedron
  22327. */
  22328. static CreatePolyhedron(options: {
  22329. type?: number;
  22330. size?: number;
  22331. sizeX?: number;
  22332. sizeY?: number;
  22333. sizeZ?: number;
  22334. custom?: any;
  22335. faceUV?: Vector4[];
  22336. faceColors?: Color4[];
  22337. flat?: boolean;
  22338. sideOrientation?: number;
  22339. frontUVs?: Vector4;
  22340. backUVs?: Vector4;
  22341. }): VertexData;
  22342. /**
  22343. * Creates the VertexData for a TorusKnot
  22344. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22345. * * radius the radius of the torus knot, optional, default 2
  22346. * * tube the thickness of the tube, optional, default 0.5
  22347. * * radialSegments the number of sides on each tube segments, optional, default 32
  22348. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22349. * * p the number of windings around the z axis, optional, default 2
  22350. * * q the number of windings around the x axis, optional, default 3
  22351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22352. * * 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)
  22353. * * 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)
  22354. * @returns the VertexData of the Torus Knot
  22355. */
  22356. static CreateTorusKnot(options: {
  22357. radius?: number;
  22358. tube?: number;
  22359. radialSegments?: number;
  22360. tubularSegments?: number;
  22361. p?: number;
  22362. q?: number;
  22363. sideOrientation?: number;
  22364. frontUVs?: Vector4;
  22365. backUVs?: Vector4;
  22366. }): VertexData;
  22367. /**
  22368. * Compute normals for given positions and indices
  22369. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22370. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22371. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22372. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22373. * * facetNormals : optional array of facet normals (vector3)
  22374. * * facetPositions : optional array of facet positions (vector3)
  22375. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22376. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22377. * * bInfo : optional bounding info, required for facetPartitioning computation
  22378. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22379. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22380. * * useRightHandedSystem: optional boolean to for right handed system computation
  22381. * * depthSort : optional boolean to enable the facet depth sort computation
  22382. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22383. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22384. */
  22385. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22386. facetNormals?: any;
  22387. facetPositions?: any;
  22388. facetPartitioning?: any;
  22389. ratio?: number;
  22390. bInfo?: any;
  22391. bbSize?: Vector3;
  22392. subDiv?: any;
  22393. useRightHandedSystem?: boolean;
  22394. depthSort?: boolean;
  22395. distanceTo?: Vector3;
  22396. depthSortedFacets?: any;
  22397. }): void;
  22398. /** @hidden */
  22399. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22400. /**
  22401. * Applies VertexData created from the imported parameters to the geometry
  22402. * @param parsedVertexData the parsed data from an imported file
  22403. * @param geometry the geometry to apply the VertexData to
  22404. */
  22405. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22406. }
  22407. }
  22408. declare module "babylonjs/Meshes/Builders/discBuilder" {
  22409. import { Nullable } from "babylonjs/types";
  22410. import { Scene } from "babylonjs/scene";
  22411. import { Vector4 } from "babylonjs/Maths/math";
  22412. import { Mesh } from "babylonjs/Meshes/mesh";
  22413. /**
  22414. * Class containing static functions to help procedurally build meshes
  22415. */
  22416. export class DiscBuilder {
  22417. /**
  22418. * Creates a plane polygonal mesh. By default, this is a disc
  22419. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22420. * * 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
  22421. * * 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
  22422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  22424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22425. * @param name defines the name of the mesh
  22426. * @param options defines the options used to create the mesh
  22427. * @param scene defines the hosting scene
  22428. * @returns the plane polygonal mesh
  22429. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22430. */
  22431. static CreateDisc(name: string, options: {
  22432. radius?: number;
  22433. tessellation?: number;
  22434. arc?: number;
  22435. updatable?: boolean;
  22436. sideOrientation?: number;
  22437. frontUVs?: Vector4;
  22438. backUVs?: Vector4;
  22439. }, scene?: Nullable<Scene>): Mesh;
  22440. }
  22441. }
  22442. declare module "babylonjs/Particles/solidParticleSystem" {
  22443. import { Vector3 } from "babylonjs/Maths/math";
  22444. import { Mesh } from "babylonjs/Meshes/mesh";
  22445. import { Scene, IDisposable } from "babylonjs/scene";
  22446. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  22447. /**
  22448. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22449. *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.
  22450. * The SPS is also a particle system. It provides some methods to manage the particles.
  22451. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22452. *
  22453. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22454. */
  22455. export class SolidParticleSystem implements IDisposable {
  22456. /**
  22457. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22458. * Example : var p = SPS.particles[i];
  22459. */
  22460. particles: SolidParticle[];
  22461. /**
  22462. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22463. */
  22464. nbParticles: number;
  22465. /**
  22466. * If the particles must ever face the camera (default false). Useful for planar particles.
  22467. */
  22468. billboard: boolean;
  22469. /**
  22470. * Recompute normals when adding a shape
  22471. */
  22472. recomputeNormals: boolean;
  22473. /**
  22474. * This a counter ofr your own usage. It's not set by any SPS functions.
  22475. */
  22476. counter: number;
  22477. /**
  22478. * The SPS name. This name is also given to the underlying mesh.
  22479. */
  22480. name: string;
  22481. /**
  22482. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22483. */
  22484. mesh: Mesh;
  22485. /**
  22486. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22487. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22488. */
  22489. vars: any;
  22490. /**
  22491. * This array is populated when the SPS is set as 'pickable'.
  22492. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22493. * Each element of this array is an object `{idx: int, faceId: int}`.
  22494. * `idx` is the picked particle index in the `SPS.particles` array
  22495. * `faceId` is the picked face index counted within this particle.
  22496. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22497. */
  22498. pickedParticles: {
  22499. idx: number;
  22500. faceId: number;
  22501. }[];
  22502. /**
  22503. * This array is populated when `enableDepthSort` is set to true.
  22504. * Each element of this array is an instance of the class DepthSortedParticle.
  22505. */
  22506. depthSortedParticles: DepthSortedParticle[];
  22507. /**
  22508. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22509. * @hidden
  22510. */
  22511. _bSphereOnly: boolean;
  22512. /**
  22513. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22514. * @hidden
  22515. */
  22516. _bSphereRadiusFactor: number;
  22517. private _scene;
  22518. private _positions;
  22519. private _indices;
  22520. private _normals;
  22521. private _colors;
  22522. private _uvs;
  22523. private _indices32;
  22524. private _positions32;
  22525. private _normals32;
  22526. private _fixedNormal32;
  22527. private _colors32;
  22528. private _uvs32;
  22529. private _index;
  22530. private _updatable;
  22531. private _pickable;
  22532. private _isVisibilityBoxLocked;
  22533. private _alwaysVisible;
  22534. private _depthSort;
  22535. private _shapeCounter;
  22536. private _copy;
  22537. private _color;
  22538. private _computeParticleColor;
  22539. private _computeParticleTexture;
  22540. private _computeParticleRotation;
  22541. private _computeParticleVertex;
  22542. private _computeBoundingBox;
  22543. private _depthSortParticles;
  22544. private _camera;
  22545. private _mustUnrotateFixedNormals;
  22546. private _particlesIntersect;
  22547. private _needs32Bits;
  22548. /**
  22549. * Creates a SPS (Solid Particle System) object.
  22550. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22551. * @param scene (Scene) is the scene in which the SPS is added.
  22552. * @param options defines the options of the sps e.g.
  22553. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22554. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22555. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  22556. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  22557. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  22558. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  22559. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  22560. */
  22561. constructor(name: string, scene: Scene, options?: {
  22562. updatable?: boolean;
  22563. isPickable?: boolean;
  22564. enableDepthSort?: boolean;
  22565. particleIntersection?: boolean;
  22566. boundingSphereOnly?: boolean;
  22567. bSphereRadiusFactor?: number;
  22568. });
  22569. /**
  22570. * Builds the SPS underlying mesh. Returns a standard Mesh.
  22571. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  22572. * @returns the created mesh
  22573. */
  22574. buildMesh(): Mesh;
  22575. /**
  22576. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  22577. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  22578. * Thus the particles generated from `digest()` have their property `position` set yet.
  22579. * @param mesh ( Mesh ) is the mesh to be digested
  22580. * @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
  22581. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  22582. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  22583. * @returns the current SPS
  22584. */
  22585. digest(mesh: Mesh, options?: {
  22586. facetNb?: number;
  22587. number?: number;
  22588. delta?: number;
  22589. }): SolidParticleSystem;
  22590. private _unrotateFixedNormals;
  22591. private _resetCopy;
  22592. private _meshBuilder;
  22593. private _posToShape;
  22594. private _uvsToShapeUV;
  22595. private _addParticle;
  22596. /**
  22597. * Adds some particles to the SPS from the model shape. Returns the shape id.
  22598. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  22599. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  22600. * @param nb (positive integer) the number of particles to be created from this model
  22601. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  22602. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  22603. * @returns the number of shapes in the system
  22604. */
  22605. addShape(mesh: Mesh, nb: number, options?: {
  22606. positionFunction?: any;
  22607. vertexFunction?: any;
  22608. }): number;
  22609. private _rebuildParticle;
  22610. /**
  22611. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  22612. * @returns the SPS.
  22613. */
  22614. rebuildMesh(): SolidParticleSystem;
  22615. /**
  22616. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  22617. * This method calls `updateParticle()` for each particle of the SPS.
  22618. * For an animated SPS, it is usually called within the render loop.
  22619. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  22620. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  22621. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  22622. * @returns the SPS.
  22623. */
  22624. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  22625. /**
  22626. * Disposes the SPS.
  22627. */
  22628. dispose(): void;
  22629. /**
  22630. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  22631. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22632. * @returns the SPS.
  22633. */
  22634. refreshVisibleSize(): SolidParticleSystem;
  22635. /**
  22636. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  22637. * @param size the size (float) of the visibility box
  22638. * note : this doesn't lock the SPS mesh bounding box.
  22639. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22640. */
  22641. setVisibilityBox(size: number): void;
  22642. /**
  22643. * Gets whether the SPS as always visible or not
  22644. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22645. */
  22646. /**
  22647. * Sets the SPS as always visible or not
  22648. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22649. */
  22650. isAlwaysVisible: boolean;
  22651. /**
  22652. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22653. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22654. */
  22655. /**
  22656. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  22657. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  22658. */
  22659. isVisibilityBoxLocked: boolean;
  22660. /**
  22661. * Tells to `setParticles()` to compute the particle rotations or not.
  22662. * Default value : true. The SPS is faster when it's set to false.
  22663. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22664. */
  22665. /**
  22666. * Gets if `setParticles()` computes the particle rotations or not.
  22667. * Default value : true. The SPS is faster when it's set to false.
  22668. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  22669. */
  22670. computeParticleRotation: boolean;
  22671. /**
  22672. * Tells to `setParticles()` to compute the particle colors or not.
  22673. * Default value : true. The SPS is faster when it's set to false.
  22674. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22675. */
  22676. /**
  22677. * Gets if `setParticles()` computes the particle colors or not.
  22678. * Default value : true. The SPS is faster when it's set to false.
  22679. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  22680. */
  22681. computeParticleColor: boolean;
  22682. /**
  22683. * Gets if `setParticles()` computes the particle textures or not.
  22684. * Default value : true. The SPS is faster when it's set to false.
  22685. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  22686. */
  22687. computeParticleTexture: boolean;
  22688. /**
  22689. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  22690. * Default value : false. The SPS is faster when it's set to false.
  22691. * Note : the particle custom vertex positions aren't stored values.
  22692. */
  22693. /**
  22694. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  22695. * Default value : false. The SPS is faster when it's set to false.
  22696. * Note : the particle custom vertex positions aren't stored values.
  22697. */
  22698. computeParticleVertex: boolean;
  22699. /**
  22700. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  22701. */
  22702. /**
  22703. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  22704. */
  22705. computeBoundingBox: boolean;
  22706. /**
  22707. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  22708. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22709. * Default : `true`
  22710. */
  22711. /**
  22712. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  22713. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  22714. * Default : `true`
  22715. */
  22716. depthSortParticles: boolean;
  22717. /**
  22718. * This function does nothing. It may be overwritten to set all the particle first values.
  22719. * The SPS doesn't call this function, you may have to call it by your own.
  22720. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22721. */
  22722. initParticles(): void;
  22723. /**
  22724. * This function does nothing. It may be overwritten to recycle a particle.
  22725. * The SPS doesn't call this function, you may have to call it by your own.
  22726. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22727. * @param particle The particle to recycle
  22728. * @returns the recycled particle
  22729. */
  22730. recycleParticle(particle: SolidParticle): SolidParticle;
  22731. /**
  22732. * Updates a particle : this function should be overwritten by the user.
  22733. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  22734. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  22735. * @example : just set a particle position or velocity and recycle conditions
  22736. * @param particle The particle to update
  22737. * @returns the updated particle
  22738. */
  22739. updateParticle(particle: SolidParticle): SolidParticle;
  22740. /**
  22741. * Updates a vertex of a particle : it can be overwritten by the user.
  22742. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  22743. * @param particle the current particle
  22744. * @param vertex the current index of the current particle
  22745. * @param pt the index of the current vertex in the particle shape
  22746. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  22747. * @example : just set a vertex particle position
  22748. * @returns the updated vertex
  22749. */
  22750. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  22751. /**
  22752. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  22753. * This does nothing and may be overwritten by the user.
  22754. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22755. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22756. * @param update the boolean update value actually passed to setParticles()
  22757. */
  22758. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22759. /**
  22760. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  22761. * This will be passed three parameters.
  22762. * This does nothing and may be overwritten by the user.
  22763. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22764. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  22765. * @param update the boolean update value actually passed to setParticles()
  22766. */
  22767. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  22768. }
  22769. }
  22770. declare module "babylonjs/Particles/solidParticle" {
  22771. import { Nullable } from "babylonjs/types";
  22772. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  22773. import { Mesh } from "babylonjs/Meshes/mesh";
  22774. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22775. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  22776. /**
  22777. * Represents one particle of a solid particle system.
  22778. */
  22779. export class SolidParticle {
  22780. /**
  22781. * particle global index
  22782. */
  22783. idx: number;
  22784. /**
  22785. * The color of the particle
  22786. */
  22787. color: Nullable<Color4>;
  22788. /**
  22789. * The world space position of the particle.
  22790. */
  22791. position: Vector3;
  22792. /**
  22793. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  22794. */
  22795. rotation: Vector3;
  22796. /**
  22797. * The world space rotation quaternion of the particle.
  22798. */
  22799. rotationQuaternion: Nullable<Quaternion>;
  22800. /**
  22801. * The scaling of the particle.
  22802. */
  22803. scaling: Vector3;
  22804. /**
  22805. * The uvs of the particle.
  22806. */
  22807. uvs: Vector4;
  22808. /**
  22809. * The current speed of the particle.
  22810. */
  22811. velocity: Vector3;
  22812. /**
  22813. * The pivot point in the particle local space.
  22814. */
  22815. pivot: Vector3;
  22816. /**
  22817. * Must the particle be translated from its pivot point in its local space ?
  22818. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  22819. * Default : false
  22820. */
  22821. translateFromPivot: boolean;
  22822. /**
  22823. * Is the particle active or not ?
  22824. */
  22825. alive: boolean;
  22826. /**
  22827. * Is the particle visible or not ?
  22828. */
  22829. isVisible: boolean;
  22830. /**
  22831. * Index of this particle in the global "positions" array (Internal use)
  22832. * @hidden
  22833. */
  22834. _pos: number;
  22835. /**
  22836. * @hidden Index of this particle in the global "indices" array (Internal use)
  22837. */
  22838. _ind: number;
  22839. /**
  22840. * @hidden ModelShape of this particle (Internal use)
  22841. */
  22842. _model: ModelShape;
  22843. /**
  22844. * ModelShape id of this particle
  22845. */
  22846. shapeId: number;
  22847. /**
  22848. * Index of the particle in its shape id (Internal use)
  22849. */
  22850. idxInShape: number;
  22851. /**
  22852. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  22853. */
  22854. _modelBoundingInfo: BoundingInfo;
  22855. /**
  22856. * @hidden Particle BoundingInfo object (Internal use)
  22857. */
  22858. _boundingInfo: BoundingInfo;
  22859. /**
  22860. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  22861. */
  22862. _sps: SolidParticleSystem;
  22863. /**
  22864. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  22865. */
  22866. _stillInvisible: boolean;
  22867. /**
  22868. * @hidden Last computed particle rotation matrix
  22869. */
  22870. _rotationMatrix: number[];
  22871. /**
  22872. * Parent particle Id, if any.
  22873. * Default null.
  22874. */
  22875. parentId: Nullable<number>;
  22876. /**
  22877. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  22878. * The possible values are :
  22879. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  22880. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22881. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  22882. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  22883. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  22884. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  22885. * */
  22886. cullingStrategy: number;
  22887. /**
  22888. * @hidden Internal global position in the SPS.
  22889. */
  22890. _globalPosition: Vector3;
  22891. /**
  22892. * Creates a Solid Particle object.
  22893. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  22894. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  22895. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  22896. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  22897. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  22898. * @param shapeId (integer) is the model shape identifier in the SPS.
  22899. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  22900. * @param sps defines the sps it is associated to
  22901. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  22902. */
  22903. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  22904. /**
  22905. * Legacy support, changed scale to scaling
  22906. */
  22907. /**
  22908. * Legacy support, changed scale to scaling
  22909. */
  22910. scale: Vector3;
  22911. /**
  22912. * Legacy support, changed quaternion to rotationQuaternion
  22913. */
  22914. /**
  22915. * Legacy support, changed quaternion to rotationQuaternion
  22916. */
  22917. quaternion: Nullable<Quaternion>;
  22918. /**
  22919. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  22920. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  22921. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  22922. * @returns true if it intersects
  22923. */
  22924. intersectsMesh(target: Mesh | SolidParticle): boolean;
  22925. /**
  22926. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  22927. * A particle is in the frustum if its bounding box intersects the frustum
  22928. * @param frustumPlanes defines the frustum to test
  22929. * @returns true if the particle is in the frustum planes
  22930. */
  22931. isInFrustum(frustumPlanes: Plane[]): boolean;
  22932. /**
  22933. * get the rotation matrix of the particle
  22934. * @hidden
  22935. */
  22936. getRotationMatrix(m: Matrix): void;
  22937. }
  22938. /**
  22939. * Represents the shape of the model used by one particle of a solid particle system.
  22940. * SPS internal tool, don't use it manually.
  22941. */
  22942. export class ModelShape {
  22943. /**
  22944. * The shape id
  22945. * @hidden
  22946. */
  22947. shapeID: number;
  22948. /**
  22949. * flat array of model positions (internal use)
  22950. * @hidden
  22951. */
  22952. _shape: Vector3[];
  22953. /**
  22954. * flat array of model UVs (internal use)
  22955. * @hidden
  22956. */
  22957. _shapeUV: number[];
  22958. /**
  22959. * length of the shape in the model indices array (internal use)
  22960. * @hidden
  22961. */
  22962. _indicesLength: number;
  22963. /**
  22964. * Custom position function (internal use)
  22965. * @hidden
  22966. */
  22967. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  22968. /**
  22969. * Custom vertex function (internal use)
  22970. * @hidden
  22971. */
  22972. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  22973. /**
  22974. * 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.
  22975. * SPS internal tool, don't use it manually.
  22976. * @hidden
  22977. */
  22978. 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>);
  22979. }
  22980. /**
  22981. * Represents a Depth Sorted Particle in the solid particle system.
  22982. */
  22983. export class DepthSortedParticle {
  22984. /**
  22985. * Index of the particle in the "indices" array
  22986. */
  22987. ind: number;
  22988. /**
  22989. * Length of the particle shape in the "indices" array
  22990. */
  22991. indicesLength: number;
  22992. /**
  22993. * Squared distance from the particle to the camera
  22994. */
  22995. sqDistance: number;
  22996. }
  22997. }
  22998. declare module "babylonjs/Meshes/abstractMesh" {
  22999. import { Observable } from "babylonjs/Misc/observable";
  23000. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  23001. import { Camera } from "babylonjs/Cameras/camera";
  23002. import { Scene, IDisposable } from "babylonjs/scene";
  23003. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  23004. import { Node } from "babylonjs/node";
  23005. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  23006. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23007. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23008. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  23009. import { Ray } from "babylonjs/Culling/ray";
  23010. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23011. import { Material } from "babylonjs/Materials/material";
  23012. import { Light } from "babylonjs/Lights/light";
  23013. import { Skeleton } from "babylonjs/Bones/skeleton";
  23014. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  23015. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  23016. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  23017. import { Collider } from "babylonjs/Collisions/collider";
  23018. /**
  23019. * Class used to store all common mesh properties
  23020. */
  23021. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23022. /** No occlusion */
  23023. static OCCLUSION_TYPE_NONE: number;
  23024. /** Occlusion set to optimisitic */
  23025. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23026. /** Occlusion set to strict */
  23027. static OCCLUSION_TYPE_STRICT: number;
  23028. /** Use an accurante occlusion algorithm */
  23029. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23030. /** Use a conservative occlusion algorithm */
  23031. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23032. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23033. * Test order :
  23034. * Is the bounding sphere outside the frustum ?
  23035. * If not, are the bounding box vertices outside the frustum ?
  23036. * It not, then the cullable object is in the frustum.
  23037. */
  23038. static readonly CULLINGSTRATEGY_STANDARD: number;
  23039. /** Culling strategy : Bounding Sphere Only.
  23040. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23041. * It's also less accurate than the standard because some not visible objects can still be selected.
  23042. * Test : is the bounding sphere outside the frustum ?
  23043. * If not, then the cullable object is in the frustum.
  23044. */
  23045. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23046. /** Culling strategy : Optimistic Inclusion.
  23047. * This in an inclusion test first, then the standard exclusion test.
  23048. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23049. * 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.
  23050. * Anyway, it's as accurate as the standard strategy.
  23051. * Test :
  23052. * Is the cullable object bounding sphere center in the frustum ?
  23053. * If not, apply the default culling strategy.
  23054. */
  23055. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23056. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23057. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23058. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23059. * 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.
  23060. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23061. * Test :
  23062. * Is the cullable object bounding sphere center in the frustum ?
  23063. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23064. */
  23065. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23066. /**
  23067. * No billboard
  23068. */
  23069. static readonly BILLBOARDMODE_NONE: number;
  23070. /** Billboard on X axis */
  23071. static readonly BILLBOARDMODE_X: number;
  23072. /** Billboard on Y axis */
  23073. static readonly BILLBOARDMODE_Y: number;
  23074. /** Billboard on Z axis */
  23075. static readonly BILLBOARDMODE_Z: number;
  23076. /** Billboard on all axes */
  23077. static readonly BILLBOARDMODE_ALL: number;
  23078. private _facetData;
  23079. /**
  23080. * The culling strategy to use to check whether the mesh must be rendered or not.
  23081. * This value can be changed at any time and will be used on the next render mesh selection.
  23082. * The possible values are :
  23083. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23084. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23085. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23086. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23087. * Please read each static variable documentation to get details about the culling process.
  23088. * */
  23089. cullingStrategy: number;
  23090. /**
  23091. * Gets the number of facets in the mesh
  23092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23093. */
  23094. readonly facetNb: number;
  23095. /**
  23096. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23097. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23098. */
  23099. partitioningSubdivisions: number;
  23100. /**
  23101. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23102. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23103. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23104. */
  23105. partitioningBBoxRatio: number;
  23106. /**
  23107. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23108. * Works only for updatable meshes.
  23109. * Doesn't work with multi-materials
  23110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23111. */
  23112. mustDepthSortFacets: boolean;
  23113. /**
  23114. * The location (Vector3) where the facet depth sort must be computed from.
  23115. * By default, the active camera position.
  23116. * Used only when facet depth sort is enabled
  23117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23118. */
  23119. facetDepthSortFrom: Vector3;
  23120. /**
  23121. * gets a boolean indicating if facetData is enabled
  23122. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23123. */
  23124. readonly isFacetDataEnabled: boolean;
  23125. /** @hidden */
  23126. _updateNonUniformScalingState(value: boolean): boolean;
  23127. /**
  23128. * An event triggered when this mesh collides with another one
  23129. */
  23130. onCollideObservable: Observable<AbstractMesh>;
  23131. private _onCollideObserver;
  23132. /** Set a function to call when this mesh collides with another one */
  23133. onCollide: () => void;
  23134. /**
  23135. * An event triggered when the collision's position changes
  23136. */
  23137. onCollisionPositionChangeObservable: Observable<Vector3>;
  23138. private _onCollisionPositionChangeObserver;
  23139. /** Set a function to call when the collision's position changes */
  23140. onCollisionPositionChange: () => void;
  23141. /**
  23142. * An event triggered when material is changed
  23143. */
  23144. onMaterialChangedObservable: Observable<AbstractMesh>;
  23145. /**
  23146. * Gets or sets the orientation for POV movement & rotation
  23147. */
  23148. definedFacingForward: boolean;
  23149. /** @hidden */
  23150. _occlusionQuery: Nullable<WebGLQuery>;
  23151. private _visibility;
  23152. /**
  23153. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23154. */
  23155. /**
  23156. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23157. */
  23158. visibility: number;
  23159. /** Gets or sets the alpha index used to sort transparent meshes
  23160. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23161. */
  23162. alphaIndex: number;
  23163. /**
  23164. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23165. */
  23166. isVisible: boolean;
  23167. /**
  23168. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23169. */
  23170. isPickable: boolean;
  23171. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23172. showSubMeshesBoundingBox: boolean;
  23173. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23174. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23175. */
  23176. isBlocker: boolean;
  23177. /**
  23178. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23179. */
  23180. enablePointerMoveEvents: boolean;
  23181. /**
  23182. * Specifies the rendering group id for this mesh (0 by default)
  23183. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23184. */
  23185. renderingGroupId: number;
  23186. private _material;
  23187. /** Gets or sets current material */
  23188. material: Nullable<Material>;
  23189. private _receiveShadows;
  23190. /**
  23191. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23192. * @see http://doc.babylonjs.com/babylon101/shadows
  23193. */
  23194. receiveShadows: boolean;
  23195. /** Defines color to use when rendering outline */
  23196. outlineColor: Color3;
  23197. /** Define width to use when rendering outline */
  23198. outlineWidth: number;
  23199. /** Defines color to use when rendering overlay */
  23200. overlayColor: Color3;
  23201. /** Defines alpha to use when rendering overlay */
  23202. overlayAlpha: number;
  23203. private _hasVertexAlpha;
  23204. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23205. hasVertexAlpha: boolean;
  23206. private _useVertexColors;
  23207. /** 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) */
  23208. useVertexColors: boolean;
  23209. private _computeBonesUsingShaders;
  23210. /**
  23211. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23212. */
  23213. computeBonesUsingShaders: boolean;
  23214. private _numBoneInfluencers;
  23215. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23216. numBoneInfluencers: number;
  23217. private _applyFog;
  23218. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23219. applyFog: boolean;
  23220. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23221. useOctreeForRenderingSelection: boolean;
  23222. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23223. useOctreeForPicking: boolean;
  23224. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23225. useOctreeForCollisions: boolean;
  23226. private _layerMask;
  23227. /**
  23228. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23229. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23230. */
  23231. layerMask: number;
  23232. /**
  23233. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23234. */
  23235. alwaysSelectAsActiveMesh: boolean;
  23236. /**
  23237. * Gets or sets the current action manager
  23238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23239. */
  23240. actionManager: Nullable<AbstractActionManager>;
  23241. private _checkCollisions;
  23242. private _collisionMask;
  23243. private _collisionGroup;
  23244. /**
  23245. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23246. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23247. */
  23248. ellipsoid: Vector3;
  23249. /**
  23250. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23251. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23252. */
  23253. ellipsoidOffset: Vector3;
  23254. private _collider;
  23255. private _oldPositionForCollisions;
  23256. private _diffPositionForCollisions;
  23257. /**
  23258. * Gets or sets a collision mask used to mask collisions (default is -1).
  23259. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23260. */
  23261. collisionMask: number;
  23262. /**
  23263. * Gets or sets the current collision group mask (-1 by default).
  23264. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23265. */
  23266. collisionGroup: number;
  23267. /**
  23268. * Defines edge width used when edgesRenderer is enabled
  23269. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23270. */
  23271. edgesWidth: number;
  23272. /**
  23273. * Defines edge color used when edgesRenderer is enabled
  23274. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23275. */
  23276. edgesColor: Color4;
  23277. /** @hidden */
  23278. _edgesRenderer: Nullable<IEdgesRenderer>;
  23279. /** @hidden */
  23280. _masterMesh: Nullable<AbstractMesh>;
  23281. /** @hidden */
  23282. _boundingInfo: Nullable<BoundingInfo>;
  23283. /** @hidden */
  23284. _renderId: number;
  23285. /**
  23286. * Gets or sets the list of subMeshes
  23287. * @see http://doc.babylonjs.com/how_to/multi_materials
  23288. */
  23289. subMeshes: SubMesh[];
  23290. /** @hidden */
  23291. _intersectionsInProgress: AbstractMesh[];
  23292. /** @hidden */
  23293. _unIndexed: boolean;
  23294. /** @hidden */
  23295. _lightSources: Light[];
  23296. /** @hidden */
  23297. readonly _positions: Nullable<Vector3[]>;
  23298. /** @hidden */
  23299. _waitingActions: any;
  23300. /** @hidden */
  23301. _waitingFreezeWorldMatrix: Nullable<boolean>;
  23302. private _skeleton;
  23303. /** @hidden */
  23304. _bonesTransformMatrices: Nullable<Float32Array>;
  23305. /**
  23306. * Gets or sets a skeleton to apply skining transformations
  23307. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23308. */
  23309. skeleton: Nullable<Skeleton>;
  23310. /**
  23311. * An event triggered when the mesh is rebuilt.
  23312. */
  23313. onRebuildObservable: Observable<AbstractMesh>;
  23314. /**
  23315. * Creates a new AbstractMesh
  23316. * @param name defines the name of the mesh
  23317. * @param scene defines the hosting scene
  23318. */
  23319. constructor(name: string, scene?: Nullable<Scene>);
  23320. /**
  23321. * Returns the string "AbstractMesh"
  23322. * @returns "AbstractMesh"
  23323. */
  23324. getClassName(): string;
  23325. /**
  23326. * Gets a string representation of the current mesh
  23327. * @param fullDetails defines a boolean indicating if full details must be included
  23328. * @returns a string representation of the current mesh
  23329. */
  23330. toString(fullDetails?: boolean): string;
  23331. /** @hidden */
  23332. _rebuild(): void;
  23333. /** @hidden */
  23334. _resyncLightSources(): void;
  23335. /** @hidden */
  23336. _resyncLighSource(light: Light): void;
  23337. /** @hidden */
  23338. _unBindEffect(): void;
  23339. /** @hidden */
  23340. _removeLightSource(light: Light): void;
  23341. private _markSubMeshesAsDirty;
  23342. /** @hidden */
  23343. _markSubMeshesAsLightDirty(): void;
  23344. /** @hidden */
  23345. _markSubMeshesAsAttributesDirty(): void;
  23346. /** @hidden */
  23347. _markSubMeshesAsMiscDirty(): void;
  23348. /**
  23349. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23350. */
  23351. scaling: Vector3;
  23352. /**
  23353. * Returns true if the mesh is blocked. Implemented by child classes
  23354. */
  23355. readonly isBlocked: boolean;
  23356. /**
  23357. * Returns the mesh itself by default. Implemented by child classes
  23358. * @param camera defines the camera to use to pick the right LOD level
  23359. * @returns the currentAbstractMesh
  23360. */
  23361. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23362. /**
  23363. * Returns 0 by default. Implemented by child classes
  23364. * @returns an integer
  23365. */
  23366. getTotalVertices(): number;
  23367. /**
  23368. * Returns a positive integer : the total number of indices in this mesh geometry.
  23369. * @returns the numner of indices or zero if the mesh has no geometry.
  23370. */
  23371. getTotalIndices(): number;
  23372. /**
  23373. * Returns null by default. Implemented by child classes
  23374. * @returns null
  23375. */
  23376. getIndices(): Nullable<IndicesArray>;
  23377. /**
  23378. * Returns the array of the requested vertex data kind. Implemented by child classes
  23379. * @param kind defines the vertex data kind to use
  23380. * @returns null
  23381. */
  23382. getVerticesData(kind: string): Nullable<FloatArray>;
  23383. /**
  23384. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23385. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23386. * Note that a new underlying VertexBuffer object is created each call.
  23387. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23388. * @param kind defines vertex data kind:
  23389. * * VertexBuffer.PositionKind
  23390. * * VertexBuffer.UVKind
  23391. * * VertexBuffer.UV2Kind
  23392. * * VertexBuffer.UV3Kind
  23393. * * VertexBuffer.UV4Kind
  23394. * * VertexBuffer.UV5Kind
  23395. * * VertexBuffer.UV6Kind
  23396. * * VertexBuffer.ColorKind
  23397. * * VertexBuffer.MatricesIndicesKind
  23398. * * VertexBuffer.MatricesIndicesExtraKind
  23399. * * VertexBuffer.MatricesWeightsKind
  23400. * * VertexBuffer.MatricesWeightsExtraKind
  23401. * @param data defines the data source
  23402. * @param updatable defines if the data must be flagged as updatable (or static)
  23403. * @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
  23404. * @returns the current mesh
  23405. */
  23406. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23407. /**
  23408. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23409. * If the mesh has no geometry, it is simply returned as it is.
  23410. * @param kind defines vertex data kind:
  23411. * * VertexBuffer.PositionKind
  23412. * * VertexBuffer.UVKind
  23413. * * VertexBuffer.UV2Kind
  23414. * * VertexBuffer.UV3Kind
  23415. * * VertexBuffer.UV4Kind
  23416. * * VertexBuffer.UV5Kind
  23417. * * VertexBuffer.UV6Kind
  23418. * * VertexBuffer.ColorKind
  23419. * * VertexBuffer.MatricesIndicesKind
  23420. * * VertexBuffer.MatricesIndicesExtraKind
  23421. * * VertexBuffer.MatricesWeightsKind
  23422. * * VertexBuffer.MatricesWeightsExtraKind
  23423. * @param data defines the data source
  23424. * @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
  23425. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23426. * @returns the current mesh
  23427. */
  23428. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23429. /**
  23430. * Sets the mesh indices,
  23431. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23432. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23433. * @param totalVertices Defines the total number of vertices
  23434. * @returns the current mesh
  23435. */
  23436. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23437. /**
  23438. * Gets a boolean indicating if specific vertex data is present
  23439. * @param kind defines the vertex data kind to use
  23440. * @returns true is data kind is present
  23441. */
  23442. isVerticesDataPresent(kind: string): boolean;
  23443. /**
  23444. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23445. * @returns a BoundingInfo
  23446. */
  23447. getBoundingInfo(): BoundingInfo;
  23448. /**
  23449. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23450. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  23451. * @returns the current mesh
  23452. */
  23453. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  23454. /**
  23455. * Overwrite the current bounding info
  23456. * @param boundingInfo defines the new bounding info
  23457. * @returns the current mesh
  23458. */
  23459. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23460. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23461. readonly useBones: boolean;
  23462. /** @hidden */
  23463. _preActivate(): void;
  23464. /** @hidden */
  23465. _preActivateForIntermediateRendering(renderId: number): void;
  23466. /** @hidden */
  23467. _activate(renderId: number): void;
  23468. /**
  23469. * Gets the current world matrix
  23470. * @returns a Matrix
  23471. */
  23472. getWorldMatrix(): Matrix;
  23473. /** @hidden */
  23474. _getWorldMatrixDeterminant(): number;
  23475. /**
  23476. * Perform relative position change from the point of view of behind the front of the mesh.
  23477. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23478. * Supports definition of mesh facing forward or backward
  23479. * @param amountRight defines the distance on the right axis
  23480. * @param amountUp defines the distance on the up axis
  23481. * @param amountForward defines the distance on the forward axis
  23482. * @returns the current mesh
  23483. */
  23484. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23485. /**
  23486. * Calculate relative position change from the point of view of behind the front of the mesh.
  23487. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23488. * Supports definition of mesh facing forward or backward
  23489. * @param amountRight defines the distance on the right axis
  23490. * @param amountUp defines the distance on the up axis
  23491. * @param amountForward defines the distance on the forward axis
  23492. * @returns the new displacement vector
  23493. */
  23494. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23495. /**
  23496. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23497. * Supports definition of mesh facing forward or backward
  23498. * @param flipBack defines the flip
  23499. * @param twirlClockwise defines the twirl
  23500. * @param tiltRight defines the tilt
  23501. * @returns the current mesh
  23502. */
  23503. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23504. /**
  23505. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23506. * Supports definition of mesh facing forward or backward.
  23507. * @param flipBack defines the flip
  23508. * @param twirlClockwise defines the twirl
  23509. * @param tiltRight defines the tilt
  23510. * @returns the new rotation vector
  23511. */
  23512. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23513. /**
  23514. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23515. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23516. * @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
  23517. * @returns the new bounding vectors
  23518. */
  23519. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23520. min: Vector3;
  23521. max: Vector3;
  23522. };
  23523. /**
  23524. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23525. * This means the mesh underlying bounding box and sphere are recomputed.
  23526. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23527. * @returns the current mesh
  23528. */
  23529. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23530. /** @hidden */
  23531. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23532. /** @hidden */
  23533. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23534. /** @hidden */
  23535. _updateBoundingInfo(): AbstractMesh;
  23536. /** @hidden */
  23537. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23538. /** @hidden */
  23539. protected _afterComputeWorldMatrix(): void;
  23540. /**
  23541. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23542. * A mesh is in the frustum if its bounding box intersects the frustum
  23543. * @param frustumPlanes defines the frustum to test
  23544. * @returns true if the mesh is in the frustum planes
  23545. */
  23546. isInFrustum(frustumPlanes: Plane[]): boolean;
  23547. /**
  23548. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23549. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23550. * @param frustumPlanes defines the frustum to test
  23551. * @returns true if the mesh is completely in the frustum planes
  23552. */
  23553. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23554. /**
  23555. * True if the mesh intersects another mesh or a SolidParticle object
  23556. * @param mesh defines a target mesh or SolidParticle to test
  23557. * @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)
  23558. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23559. * @returns true if there is an intersection
  23560. */
  23561. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23562. /**
  23563. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23564. * @param point defines the point to test
  23565. * @returns true if there is an intersection
  23566. */
  23567. intersectsPoint(point: Vector3): boolean;
  23568. /**
  23569. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23570. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23571. */
  23572. checkCollisions: boolean;
  23573. /**
  23574. * Gets Collider object used to compute collisions (not physics)
  23575. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23576. */
  23577. readonly collider: Collider;
  23578. /**
  23579. * Move the mesh using collision engine
  23580. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23581. * @param displacement defines the requested displacement vector
  23582. * @returns the current mesh
  23583. */
  23584. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23585. private _onCollisionPositionChange;
  23586. /** @hidden */
  23587. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23588. /** @hidden */
  23589. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23590. /** @hidden */
  23591. _checkCollision(collider: Collider): AbstractMesh;
  23592. /** @hidden */
  23593. _generatePointsArray(): boolean;
  23594. /**
  23595. * Checks if the passed Ray intersects with the mesh
  23596. * @param ray defines the ray to use
  23597. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23598. * @returns the picking info
  23599. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23600. */
  23601. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  23602. /**
  23603. * Clones the current mesh
  23604. * @param name defines the mesh name
  23605. * @param newParent defines the new mesh parent
  23606. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23607. * @returns the new mesh
  23608. */
  23609. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23610. /**
  23611. * Disposes all the submeshes of the current meshnp
  23612. * @returns the current mesh
  23613. */
  23614. releaseSubMeshes(): AbstractMesh;
  23615. /**
  23616. * Releases resources associated with this abstract mesh.
  23617. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23618. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23619. */
  23620. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23621. /**
  23622. * Adds the passed mesh as a child to the current mesh
  23623. * @param mesh defines the child mesh
  23624. * @returns the current mesh
  23625. */
  23626. addChild(mesh: AbstractMesh): AbstractMesh;
  23627. /**
  23628. * Removes the passed mesh from the current mesh children list
  23629. * @param mesh defines the child mesh
  23630. * @returns the current mesh
  23631. */
  23632. removeChild(mesh: AbstractMesh): AbstractMesh;
  23633. /** @hidden */
  23634. private _initFacetData;
  23635. /**
  23636. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  23637. * This method can be called within the render loop.
  23638. * 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
  23639. * @returns the current mesh
  23640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23641. */
  23642. updateFacetData(): AbstractMesh;
  23643. /**
  23644. * Returns the facetLocalNormals array.
  23645. * The normals are expressed in the mesh local spac
  23646. * @returns an array of Vector3
  23647. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23648. */
  23649. getFacetLocalNormals(): Vector3[];
  23650. /**
  23651. * Returns the facetLocalPositions array.
  23652. * The facet positions are expressed in the mesh local space
  23653. * @returns an array of Vector3
  23654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23655. */
  23656. getFacetLocalPositions(): Vector3[];
  23657. /**
  23658. * Returns the facetLocalPartioning array
  23659. * @returns an array of array of numbers
  23660. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23661. */
  23662. getFacetLocalPartitioning(): number[][];
  23663. /**
  23664. * Returns the i-th facet position in the world system.
  23665. * This method allocates a new Vector3 per call
  23666. * @param i defines the facet index
  23667. * @returns a new Vector3
  23668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23669. */
  23670. getFacetPosition(i: number): Vector3;
  23671. /**
  23672. * Sets the reference Vector3 with the i-th facet position in the world system
  23673. * @param i defines the facet index
  23674. * @param ref defines the target vector
  23675. * @returns the current mesh
  23676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23677. */
  23678. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  23679. /**
  23680. * Returns the i-th facet normal in the world system.
  23681. * This method allocates a new Vector3 per call
  23682. * @param i defines the facet index
  23683. * @returns a new Vector3
  23684. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23685. */
  23686. getFacetNormal(i: number): Vector3;
  23687. /**
  23688. * Sets the reference Vector3 with the i-th facet normal in the world system
  23689. * @param i defines the facet index
  23690. * @param ref defines the target vector
  23691. * @returns the current mesh
  23692. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23693. */
  23694. getFacetNormalToRef(i: number, ref: Vector3): this;
  23695. /**
  23696. * 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)
  23697. * @param x defines x coordinate
  23698. * @param y defines y coordinate
  23699. * @param z defines z coordinate
  23700. * @returns the array of facet indexes
  23701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23702. */
  23703. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  23704. /**
  23705. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  23706. * @param projected sets as the (x,y,z) world projection on the facet
  23707. * @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
  23708. * @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
  23709. * @param x defines x coordinate
  23710. * @param y defines y coordinate
  23711. * @param z defines z coordinate
  23712. * @returns the face index if found (or null instead)
  23713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23714. */
  23715. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23716. /**
  23717. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  23718. * @param projected sets as the (x,y,z) local projection on the facet
  23719. * @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
  23720. * @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
  23721. * @param x defines x coordinate
  23722. * @param y defines y coordinate
  23723. * @param z defines z coordinate
  23724. * @returns the face index if found (or null instead)
  23725. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23726. */
  23727. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  23728. /**
  23729. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  23730. * @returns the parameters
  23731. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23732. */
  23733. getFacetDataParameters(): any;
  23734. /**
  23735. * Disables the feature FacetData and frees the related memory
  23736. * @returns the current mesh
  23737. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  23738. */
  23739. disableFacetData(): AbstractMesh;
  23740. /**
  23741. * Updates the AbstractMesh indices array
  23742. * @param indices defines the data source
  23743. * @returns the current mesh
  23744. */
  23745. updateIndices(indices: IndicesArray): AbstractMesh;
  23746. /**
  23747. * Creates new normals data for the mesh
  23748. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  23749. * @returns the current mesh
  23750. */
  23751. createNormals(updatable: boolean): AbstractMesh;
  23752. /**
  23753. * Align the mesh with a normal
  23754. * @param normal defines the normal to use
  23755. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  23756. * @returns the current mesh
  23757. */
  23758. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  23759. /** @hidden */
  23760. _checkOcclusionQuery(): boolean;
  23761. }
  23762. }
  23763. declare module "babylonjs/Bones/skeleton" {
  23764. import { Bone } from "babylonjs/Bones/bone";
  23765. import { IAnimatable } from "babylonjs/Misc/tools";
  23766. import { Observable } from "babylonjs/Misc/observable";
  23767. import { Vector3, Matrix } from "babylonjs/Maths/math";
  23768. import { Scene } from "babylonjs/scene";
  23769. import { Nullable } from "babylonjs/types";
  23770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23771. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  23772. import { Animatable } from "babylonjs/Animations/animatable";
  23773. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23774. import { Animation } from "babylonjs/Animations/animation";
  23775. import { AnimationRange } from "babylonjs/Animations/animationRange";
  23776. /**
  23777. * Class used to handle skinning animations
  23778. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23779. */
  23780. export class Skeleton implements IAnimatable {
  23781. /** defines the skeleton name */
  23782. name: string;
  23783. /** defines the skeleton Id */
  23784. id: string;
  23785. /**
  23786. * Defines the list of child bones
  23787. */
  23788. bones: Bone[];
  23789. /**
  23790. * Defines an estimate of the dimension of the skeleton at rest
  23791. */
  23792. dimensionsAtRest: Vector3;
  23793. /**
  23794. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  23795. */
  23796. needInitialSkinMatrix: boolean;
  23797. /**
  23798. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  23799. */
  23800. overrideMesh: Nullable<AbstractMesh>;
  23801. /**
  23802. * Gets the list of animations attached to this skeleton
  23803. */
  23804. animations: Array<Animation>;
  23805. private _scene;
  23806. private _isDirty;
  23807. private _transformMatrices;
  23808. private _transformMatrixTexture;
  23809. private _meshesWithPoseMatrix;
  23810. private _animatables;
  23811. private _identity;
  23812. private _synchronizedWithMesh;
  23813. private _ranges;
  23814. private _lastAbsoluteTransformsUpdateId;
  23815. private _canUseTextureForBones;
  23816. /** @hidden */
  23817. _numBonesWithLinkedTransformNode: number;
  23818. /**
  23819. * Specifies if the skeleton should be serialized
  23820. */
  23821. doNotSerialize: boolean;
  23822. /**
  23823. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  23824. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  23825. */
  23826. useTextureToStoreBoneMatrices: boolean;
  23827. private _animationPropertiesOverride;
  23828. /**
  23829. * Gets or sets the animation properties override
  23830. */
  23831. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  23832. /**
  23833. * An observable triggered before computing the skeleton's matrices
  23834. */
  23835. onBeforeComputeObservable: Observable<Skeleton>;
  23836. /**
  23837. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  23838. */
  23839. readonly isUsingTextureForMatrices: boolean;
  23840. /**
  23841. * Creates a new skeleton
  23842. * @param name defines the skeleton name
  23843. * @param id defines the skeleton Id
  23844. * @param scene defines the hosting scene
  23845. */
  23846. constructor(
  23847. /** defines the skeleton name */
  23848. name: string,
  23849. /** defines the skeleton Id */
  23850. id: string, scene: Scene);
  23851. /**
  23852. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  23853. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  23854. * @returns a Float32Array containing matrices data
  23855. */
  23856. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  23857. /**
  23858. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  23859. * @returns a raw texture containing the data
  23860. */
  23861. getTransformMatrixTexture(): Nullable<RawTexture>;
  23862. /**
  23863. * Gets the current hosting scene
  23864. * @returns a scene object
  23865. */
  23866. getScene(): Scene;
  23867. /**
  23868. * Gets a string representing the current skeleton data
  23869. * @param fullDetails defines a boolean indicating if we want a verbose version
  23870. * @returns a string representing the current skeleton data
  23871. */
  23872. toString(fullDetails?: boolean): string;
  23873. /**
  23874. * Get bone's index searching by name
  23875. * @param name defines bone's name to search for
  23876. * @return the indice of the bone. Returns -1 if not found
  23877. */
  23878. getBoneIndexByName(name: string): number;
  23879. /**
  23880. * Creater a new animation range
  23881. * @param name defines the name of the range
  23882. * @param from defines the start key
  23883. * @param to defines the end key
  23884. */
  23885. createAnimationRange(name: string, from: number, to: number): void;
  23886. /**
  23887. * Delete a specific animation range
  23888. * @param name defines the name of the range
  23889. * @param deleteFrames defines if frames must be removed as well
  23890. */
  23891. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  23892. /**
  23893. * Gets a specific animation range
  23894. * @param name defines the name of the range to look for
  23895. * @returns the requested animation range or null if not found
  23896. */
  23897. getAnimationRange(name: string): Nullable<AnimationRange>;
  23898. /**
  23899. * Gets the list of all animation ranges defined on this skeleton
  23900. * @returns an array
  23901. */
  23902. getAnimationRanges(): Nullable<AnimationRange>[];
  23903. /**
  23904. * Copy animation range from a source skeleton.
  23905. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  23906. * @param source defines the source skeleton
  23907. * @param name defines the name of the range to copy
  23908. * @param rescaleAsRequired defines if rescaling must be applied if required
  23909. * @returns true if operation was successful
  23910. */
  23911. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  23912. /**
  23913. * Forces the skeleton to go to rest pose
  23914. */
  23915. returnToRest(): void;
  23916. private _getHighestAnimationFrame;
  23917. /**
  23918. * Begin a specific animation range
  23919. * @param name defines the name of the range to start
  23920. * @param loop defines if looping must be turned on (false by default)
  23921. * @param speedRatio defines the speed ratio to apply (1 by default)
  23922. * @param onAnimationEnd defines a callback which will be called when animation will end
  23923. * @returns a new animatable
  23924. */
  23925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  23926. /** @hidden */
  23927. _markAsDirty(): void;
  23928. /** @hidden */
  23929. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23930. /** @hidden */
  23931. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  23932. private _computeTransformMatrices;
  23933. /**
  23934. * Build all resources required to render a skeleton
  23935. */
  23936. prepare(): void;
  23937. /**
  23938. * Gets the list of animatables currently running for this skeleton
  23939. * @returns an array of animatables
  23940. */
  23941. getAnimatables(): IAnimatable[];
  23942. /**
  23943. * Clone the current skeleton
  23944. * @param name defines the name of the new skeleton
  23945. * @param id defines the id of the enw skeleton
  23946. * @returns the new skeleton
  23947. */
  23948. clone(name: string, id: string): Skeleton;
  23949. /**
  23950. * Enable animation blending for this skeleton
  23951. * @param blendingSpeed defines the blending speed to apply
  23952. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  23953. */
  23954. enableBlending(blendingSpeed?: number): void;
  23955. /**
  23956. * Releases all resources associated with the current skeleton
  23957. */
  23958. dispose(): void;
  23959. /**
  23960. * Serialize the skeleton in a JSON object
  23961. * @returns a JSON object
  23962. */
  23963. serialize(): any;
  23964. /**
  23965. * Creates a new skeleton from serialized data
  23966. * @param parsedSkeleton defines the serialized data
  23967. * @param scene defines the hosting scene
  23968. * @returns a new skeleton
  23969. */
  23970. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  23971. /**
  23972. * Compute all node absolute transforms
  23973. * @param forceUpdate defines if computation must be done even if cache is up to date
  23974. */
  23975. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  23976. /**
  23977. * Gets the root pose matrix
  23978. * @returns a matrix
  23979. */
  23980. getPoseMatrix(): Nullable<Matrix>;
  23981. /**
  23982. * Sorts bones per internal index
  23983. */
  23984. sortBones(): void;
  23985. private _sortBones;
  23986. }
  23987. }
  23988. declare module "babylonjs/Bones/bone" {
  23989. import { Skeleton } from "babylonjs/Bones/skeleton";
  23990. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  23991. import { Nullable } from "babylonjs/types";
  23992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23993. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23994. import { Node } from "babylonjs/node";
  23995. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23996. /**
  23997. * Class used to store bone information
  23998. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23999. */
  24000. export class Bone extends Node {
  24001. /**
  24002. * defines the bone name
  24003. */
  24004. name: string;
  24005. private static _tmpVecs;
  24006. private static _tmpQuat;
  24007. private static _tmpMats;
  24008. /**
  24009. * Gets the list of child bones
  24010. */
  24011. children: Bone[];
  24012. /** Gets the animations associated with this bone */
  24013. animations: import("babylonjs/Animations/animation").Animation[];
  24014. /**
  24015. * Gets or sets bone length
  24016. */
  24017. length: number;
  24018. /**
  24019. * @hidden Internal only
  24020. * Set this value to map this bone to a different index in the transform matrices
  24021. * Set this value to -1 to exclude the bone from the transform matrices
  24022. */
  24023. _index: Nullable<number>;
  24024. private _skeleton;
  24025. private _localMatrix;
  24026. private _restPose;
  24027. private _baseMatrix;
  24028. private _absoluteTransform;
  24029. private _invertedAbsoluteTransform;
  24030. private _parent;
  24031. private _scalingDeterminant;
  24032. private _worldTransform;
  24033. private _localScaling;
  24034. private _localRotation;
  24035. private _localPosition;
  24036. private _needToDecompose;
  24037. private _needToCompose;
  24038. /** @hidden */
  24039. _linkedTransformNode: Nullable<TransformNode>;
  24040. /** @hidden */
  24041. /** @hidden */
  24042. _matrix: Matrix;
  24043. /**
  24044. * Create a new bone
  24045. * @param name defines the bone name
  24046. * @param skeleton defines the parent skeleton
  24047. * @param parentBone defines the parent (can be null if the bone is the root)
  24048. * @param localMatrix defines the local matrix
  24049. * @param restPose defines the rest pose matrix
  24050. * @param baseMatrix defines the base matrix
  24051. * @param index defines index of the bone in the hiearchy
  24052. */
  24053. constructor(
  24054. /**
  24055. * defines the bone name
  24056. */
  24057. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  24058. /**
  24059. * Gets the parent skeleton
  24060. * @returns a skeleton
  24061. */
  24062. getSkeleton(): Skeleton;
  24063. /**
  24064. * Gets parent bone
  24065. * @returns a bone or null if the bone is the root of the bone hierarchy
  24066. */
  24067. getParent(): Nullable<Bone>;
  24068. /**
  24069. * Sets the parent bone
  24070. * @param parent defines the parent (can be null if the bone is the root)
  24071. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24072. */
  24073. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  24074. /**
  24075. * Gets the local matrix
  24076. * @returns a matrix
  24077. */
  24078. getLocalMatrix(): Matrix;
  24079. /**
  24080. * Gets the base matrix (initial matrix which remains unchanged)
  24081. * @returns a matrix
  24082. */
  24083. getBaseMatrix(): Matrix;
  24084. /**
  24085. * Gets the rest pose matrix
  24086. * @returns a matrix
  24087. */
  24088. getRestPose(): Matrix;
  24089. /**
  24090. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  24091. */
  24092. getWorldMatrix(): Matrix;
  24093. /**
  24094. * Sets the local matrix to rest pose matrix
  24095. */
  24096. returnToRest(): void;
  24097. /**
  24098. * Gets the inverse of the absolute transform matrix.
  24099. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  24100. * @returns a matrix
  24101. */
  24102. getInvertedAbsoluteTransform(): Matrix;
  24103. /**
  24104. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  24105. * @returns a matrix
  24106. */
  24107. getAbsoluteTransform(): Matrix;
  24108. /**
  24109. * Links with the given transform node.
  24110. * The local matrix of this bone is copied from the transform node every frame.
  24111. * @param transformNode defines the transform node to link to
  24112. */
  24113. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  24114. /** Gets or sets current position (in local space) */
  24115. position: Vector3;
  24116. /** Gets or sets current rotation (in local space) */
  24117. rotation: Vector3;
  24118. /** Gets or sets current rotation quaternion (in local space) */
  24119. rotationQuaternion: Quaternion;
  24120. /** Gets or sets current scaling (in local space) */
  24121. scaling: Vector3;
  24122. /**
  24123. * Gets the animation properties override
  24124. */
  24125. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24126. private _decompose;
  24127. private _compose;
  24128. /**
  24129. * Update the base and local matrices
  24130. * @param matrix defines the new base or local matrix
  24131. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  24132. * @param updateLocalMatrix defines if the local matrix should be updated
  24133. */
  24134. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  24135. /** @hidden */
  24136. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  24137. /**
  24138. * Flag the bone as dirty (Forcing it to update everything)
  24139. */
  24140. markAsDirty(): void;
  24141. private _markAsDirtyAndCompose;
  24142. private _markAsDirtyAndDecompose;
  24143. /**
  24144. * Translate the bone in local or world space
  24145. * @param vec The amount to translate the bone
  24146. * @param space The space that the translation is in
  24147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24148. */
  24149. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24150. /**
  24151. * Set the postion of the bone in local or world space
  24152. * @param position The position to set the bone
  24153. * @param space The space that the position is in
  24154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24155. */
  24156. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24157. /**
  24158. * Set the absolute position of the bone (world space)
  24159. * @param position The position to set the bone
  24160. * @param mesh The mesh that this bone is attached to
  24161. */
  24162. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  24163. /**
  24164. * Scale the bone on the x, y and z axes (in local space)
  24165. * @param x The amount to scale the bone on the x axis
  24166. * @param y The amount to scale the bone on the y axis
  24167. * @param z The amount to scale the bone on the z axis
  24168. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  24169. */
  24170. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  24171. /**
  24172. * Set the bone scaling in local space
  24173. * @param scale defines the scaling vector
  24174. */
  24175. setScale(scale: Vector3): void;
  24176. /**
  24177. * Gets the current scaling in local space
  24178. * @returns the current scaling vector
  24179. */
  24180. getScale(): Vector3;
  24181. /**
  24182. * Gets the current scaling in local space and stores it in a target vector
  24183. * @param result defines the target vector
  24184. */
  24185. getScaleToRef(result: Vector3): void;
  24186. /**
  24187. * Set the yaw, pitch, and roll of the bone in local or world space
  24188. * @param yaw The rotation of the bone on the y axis
  24189. * @param pitch The rotation of the bone on the x axis
  24190. * @param roll The rotation of the bone on the z axis
  24191. * @param space The space that the axes of rotation are in
  24192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24193. */
  24194. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  24195. /**
  24196. * Add a rotation to the bone on an axis in local or world space
  24197. * @param axis The axis to rotate the bone on
  24198. * @param amount The amount to rotate the bone
  24199. * @param space The space that the axis is in
  24200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24201. */
  24202. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  24203. /**
  24204. * Set the rotation of the bone to a particular axis angle in local or world space
  24205. * @param axis The axis to rotate the bone on
  24206. * @param angle The angle that the bone should be rotated to
  24207. * @param space The space that the axis is in
  24208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24209. */
  24210. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  24211. /**
  24212. * Set the euler rotation of the bone in local of world space
  24213. * @param rotation The euler rotation that the bone should be set to
  24214. * @param space The space that the rotation is in
  24215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24216. */
  24217. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  24218. /**
  24219. * Set the quaternion rotation of the bone in local of world space
  24220. * @param quat The quaternion rotation that the bone should be set to
  24221. * @param space The space that the rotation is in
  24222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24223. */
  24224. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  24225. /**
  24226. * Set the rotation matrix of the bone in local of world space
  24227. * @param rotMat The rotation matrix that the bone should be set to
  24228. * @param space The space that the rotation is in
  24229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24230. */
  24231. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  24232. private _rotateWithMatrix;
  24233. private _getNegativeRotationToRef;
  24234. /**
  24235. * Get the position of the bone in local or world space
  24236. * @param space The space that the returned position is in
  24237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24238. * @returns The position of the bone
  24239. */
  24240. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24241. /**
  24242. * Copy the position of the bone to a vector3 in local or world space
  24243. * @param space The space that the returned position is in
  24244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24245. * @param result The vector3 to copy the position to
  24246. */
  24247. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  24248. /**
  24249. * Get the absolute position of the bone (world space)
  24250. * @param mesh The mesh that this bone is attached to
  24251. * @returns The absolute position of the bone
  24252. */
  24253. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  24254. /**
  24255. * Copy the absolute position of the bone (world space) to the result param
  24256. * @param mesh The mesh that this bone is attached to
  24257. * @param result The vector3 to copy the absolute position to
  24258. */
  24259. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  24260. /**
  24261. * Compute the absolute transforms of this bone and its children
  24262. */
  24263. computeAbsoluteTransforms(): void;
  24264. /**
  24265. * Get the world direction from an axis that is in the local space of the bone
  24266. * @param localAxis The local direction that is used to compute the world direction
  24267. * @param mesh The mesh that this bone is attached to
  24268. * @returns The world direction
  24269. */
  24270. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24271. /**
  24272. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  24273. * @param localAxis The local direction that is used to compute the world direction
  24274. * @param mesh The mesh that this bone is attached to
  24275. * @param result The vector3 that the world direction will be copied to
  24276. */
  24277. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24278. /**
  24279. * Get the euler rotation of the bone in local or world space
  24280. * @param space The space that the rotation should be in
  24281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24282. * @returns The euler rotation
  24283. */
  24284. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  24285. /**
  24286. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  24287. * @param space The space that the rotation should be in
  24288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24289. * @param result The vector3 that the rotation should be copied to
  24290. */
  24291. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24292. /**
  24293. * Get the quaternion rotation of the bone in either local or world space
  24294. * @param space The space that the rotation should be in
  24295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24296. * @returns The quaternion rotation
  24297. */
  24298. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  24299. /**
  24300. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  24301. * @param space The space that the rotation should be in
  24302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24303. * @param result The quaternion that the rotation should be copied to
  24304. */
  24305. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  24306. /**
  24307. * Get the rotation matrix of the bone in local or world space
  24308. * @param space The space that the rotation should be in
  24309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24310. * @returns The rotation matrix
  24311. */
  24312. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  24313. /**
  24314. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  24315. * @param space The space that the rotation should be in
  24316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  24317. * @param result The quaternion that the rotation should be copied to
  24318. */
  24319. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  24320. /**
  24321. * Get the world position of a point that is in the local space of the bone
  24322. * @param position The local position
  24323. * @param mesh The mesh that this bone is attached to
  24324. * @returns The world position
  24325. */
  24326. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24327. /**
  24328. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  24329. * @param position The local position
  24330. * @param mesh The mesh that this bone is attached to
  24331. * @param result The vector3 that the world position should be copied to
  24332. */
  24333. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24334. /**
  24335. * Get the local position of a point that is in world space
  24336. * @param position The world position
  24337. * @param mesh The mesh that this bone is attached to
  24338. * @returns The local position
  24339. */
  24340. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  24341. /**
  24342. * Get the local position of a point that is in world space and copy it to the result param
  24343. * @param position The world position
  24344. * @param mesh The mesh that this bone is attached to
  24345. * @param result The vector3 that the local position should be copied to
  24346. */
  24347. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  24348. }
  24349. }
  24350. declare module "babylonjs/Animations/animatable" {
  24351. import { Animation } from "babylonjs/Animations/animation";
  24352. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24353. import { Nullable } from "babylonjs/types";
  24354. import { Observable } from "babylonjs/Misc/observable";
  24355. import { Scene } from "babylonjs/scene";
  24356. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  24357. import { Node } from "babylonjs/node";
  24358. /**
  24359. * Class used to store an actual running animation
  24360. */
  24361. export class Animatable {
  24362. /** defines the target object */
  24363. target: any;
  24364. /** defines the starting frame number (default is 0) */
  24365. fromFrame: number;
  24366. /** defines the ending frame number (default is 100) */
  24367. toFrame: number;
  24368. /** defines if the animation must loop (default is false) */
  24369. loopAnimation: boolean;
  24370. /** defines a callback to call when animation ends if it is not looping */
  24371. onAnimationEnd?: (() => void) | null | undefined;
  24372. /** defines a callback to call when animation loops */
  24373. onAnimationLoop?: (() => void) | null | undefined;
  24374. private _localDelayOffset;
  24375. private _pausedDelay;
  24376. private _runtimeAnimations;
  24377. private _paused;
  24378. private _scene;
  24379. private _speedRatio;
  24380. private _weight;
  24381. private _syncRoot;
  24382. /**
  24383. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  24384. * This will only apply for non looping animation (default is true)
  24385. */
  24386. disposeOnEnd: boolean;
  24387. /**
  24388. * Gets a boolean indicating if the animation has started
  24389. */
  24390. animationStarted: boolean;
  24391. /**
  24392. * Observer raised when the animation ends
  24393. */
  24394. onAnimationEndObservable: Observable<Animatable>;
  24395. /**
  24396. * Observer raised when the animation loops
  24397. */
  24398. onAnimationLoopObservable: Observable<Animatable>;
  24399. /**
  24400. * Gets the root Animatable used to synchronize and normalize animations
  24401. */
  24402. readonly syncRoot: Animatable;
  24403. /**
  24404. * Gets the current frame of the first RuntimeAnimation
  24405. * Used to synchronize Animatables
  24406. */
  24407. readonly masterFrame: number;
  24408. /**
  24409. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  24410. */
  24411. weight: number;
  24412. /**
  24413. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  24414. */
  24415. speedRatio: number;
  24416. /**
  24417. * Creates a new Animatable
  24418. * @param scene defines the hosting scene
  24419. * @param target defines the target object
  24420. * @param fromFrame defines the starting frame number (default is 0)
  24421. * @param toFrame defines the ending frame number (default is 100)
  24422. * @param loopAnimation defines if the animation must loop (default is false)
  24423. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  24424. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  24425. * @param animations defines a group of animation to add to the new Animatable
  24426. * @param onAnimationLoop defines a callback to call when animation loops
  24427. */
  24428. constructor(scene: Scene,
  24429. /** defines the target object */
  24430. target: any,
  24431. /** defines the starting frame number (default is 0) */
  24432. fromFrame?: number,
  24433. /** defines the ending frame number (default is 100) */
  24434. toFrame?: number,
  24435. /** defines if the animation must loop (default is false) */
  24436. loopAnimation?: boolean, speedRatio?: number,
  24437. /** defines a callback to call when animation ends if it is not looping */
  24438. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  24439. /** defines a callback to call when animation loops */
  24440. onAnimationLoop?: (() => void) | null | undefined);
  24441. /**
  24442. * Synchronize and normalize current Animatable with a source Animatable
  24443. * This is useful when using animation weights and when animations are not of the same length
  24444. * @param root defines the root Animatable to synchronize with
  24445. * @returns the current Animatable
  24446. */
  24447. syncWith(root: Animatable): Animatable;
  24448. /**
  24449. * Gets the list of runtime animations
  24450. * @returns an array of RuntimeAnimation
  24451. */
  24452. getAnimations(): RuntimeAnimation[];
  24453. /**
  24454. * Adds more animations to the current animatable
  24455. * @param target defines the target of the animations
  24456. * @param animations defines the new animations to add
  24457. */
  24458. appendAnimations(target: any, animations: Animation[]): void;
  24459. /**
  24460. * Gets the source animation for a specific property
  24461. * @param property defines the propertyu to look for
  24462. * @returns null or the source animation for the given property
  24463. */
  24464. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  24465. /**
  24466. * Gets the runtime animation for a specific property
  24467. * @param property defines the propertyu to look for
  24468. * @returns null or the runtime animation for the given property
  24469. */
  24470. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  24471. /**
  24472. * Resets the animatable to its original state
  24473. */
  24474. reset(): void;
  24475. /**
  24476. * Allows the animatable to blend with current running animations
  24477. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24478. * @param blendingSpeed defines the blending speed to use
  24479. */
  24480. enableBlending(blendingSpeed: number): void;
  24481. /**
  24482. * Disable animation blending
  24483. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  24484. */
  24485. disableBlending(): void;
  24486. /**
  24487. * Jump directly to a given frame
  24488. * @param frame defines the frame to jump to
  24489. */
  24490. goToFrame(frame: number): void;
  24491. /**
  24492. * Pause the animation
  24493. */
  24494. pause(): void;
  24495. /**
  24496. * Restart the animation
  24497. */
  24498. restart(): void;
  24499. private _raiseOnAnimationEnd;
  24500. /**
  24501. * Stop and delete the current animation
  24502. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  24503. * @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)
  24504. */
  24505. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  24506. /**
  24507. * Wait asynchronously for the animation to end
  24508. * @returns a promise which will be fullfilled when the animation ends
  24509. */
  24510. waitAsync(): Promise<Animatable>;
  24511. /** @hidden */
  24512. _animate(delay: number): boolean;
  24513. }
  24514. module "babylonjs/scene" {
  24515. interface Scene {
  24516. /** @hidden */
  24517. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  24518. /** @hidden */
  24519. _processLateAnimationBindingsForMatrices(holder: {
  24520. totalWeight: number;
  24521. animations: RuntimeAnimation[];
  24522. originalValue: Matrix;
  24523. }): any;
  24524. /** @hidden */
  24525. _processLateAnimationBindingsForQuaternions(holder: {
  24526. totalWeight: number;
  24527. animations: RuntimeAnimation[];
  24528. originalValue: Quaternion;
  24529. }, refQuaternion: Quaternion): Quaternion;
  24530. /** @hidden */
  24531. _processLateAnimationBindings(): void;
  24532. /** @hidden */
  24533. _animate(): void;
  24534. /**
  24535. * Will start the animation sequence of a given target
  24536. * @param target defines the target
  24537. * @param from defines from which frame should animation start
  24538. * @param to defines until which frame should animation run.
  24539. * @param weight defines the weight to apply to the animation (1.0 by default)
  24540. * @param loop defines if the animation loops
  24541. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24542. * @param onAnimationEnd defines the function to be executed when the animation ends
  24543. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24544. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24545. * @param onAnimationLoop defines the callback to call when an animation loops
  24546. * @returns the animatable object created for this animation
  24547. */
  24548. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24549. /**
  24550. * Will start the animation sequence of a given target
  24551. * @param target defines the target
  24552. * @param from defines from which frame should animation start
  24553. * @param to defines until which frame should animation run.
  24554. * @param loop defines if the animation loops
  24555. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24556. * @param onAnimationEnd defines the function to be executed when the animation ends
  24557. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24558. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24559. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  24560. * @param onAnimationLoop defines the callback to call when an animation loops
  24561. * @returns the animatable object created for this animation
  24562. */
  24563. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  24564. /**
  24565. * Will start the animation sequence of a given target and its hierarchy
  24566. * @param target defines the target
  24567. * @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.
  24568. * @param from defines from which frame should animation start
  24569. * @param to defines until which frame should animation run.
  24570. * @param loop defines if the animation loops
  24571. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  24572. * @param onAnimationEnd defines the function to be executed when the animation ends
  24573. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  24574. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  24575. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  24576. * @param onAnimationLoop defines the callback to call when an animation loops
  24577. * @returns the list of created animatables
  24578. */
  24579. 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[];
  24580. /**
  24581. * Begin a new animation on a given node
  24582. * @param target defines the target where the animation will take place
  24583. * @param animations defines the list of animations to start
  24584. * @param from defines the initial value
  24585. * @param to defines the final value
  24586. * @param loop defines if you want animation to loop (off by default)
  24587. * @param speedRatio defines the speed ratio to apply to all animations
  24588. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24589. * @param onAnimationLoop defines the callback to call when an animation loops
  24590. * @returns the list of created animatables
  24591. */
  24592. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  24593. /**
  24594. * Begin a new animation on a given node and its hierarchy
  24595. * @param target defines the root node where the animation will take place
  24596. * @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.
  24597. * @param animations defines the list of animations to start
  24598. * @param from defines the initial value
  24599. * @param to defines the final value
  24600. * @param loop defines if you want animation to loop (off by default)
  24601. * @param speedRatio defines the speed ratio to apply to all animations
  24602. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24603. * @param onAnimationLoop defines the callback to call when an animation loops
  24604. * @returns the list of animatables created for all nodes
  24605. */
  24606. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  24607. /**
  24608. * Gets the animatable associated with a specific target
  24609. * @param target defines the target of the animatable
  24610. * @returns the required animatable if found
  24611. */
  24612. getAnimatableByTarget(target: any): Nullable<Animatable>;
  24613. /**
  24614. * Gets all animatables associated with a given target
  24615. * @param target defines the target to look animatables for
  24616. * @returns an array of Animatables
  24617. */
  24618. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  24619. /**
  24620. * Will stop the animation of the given target
  24621. * @param target - the target
  24622. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  24623. * @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)
  24624. */
  24625. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  24626. /**
  24627. * Stops and removes all animations that have been applied to the scene
  24628. */
  24629. stopAllAnimations(): void;
  24630. }
  24631. }
  24632. module "babylonjs/Bones/bone" {
  24633. interface Bone {
  24634. /**
  24635. * Copy an animation range from another bone
  24636. * @param source defines the source bone
  24637. * @param rangeName defines the range name to copy
  24638. * @param frameOffset defines the frame offset
  24639. * @param rescaleAsRequired defines if rescaling must be applied if required
  24640. * @param skelDimensionsRatio defines the scaling ratio
  24641. * @returns true if operation was successful
  24642. */
  24643. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  24644. }
  24645. }
  24646. }
  24647. declare module "babylonjs/node" {
  24648. import { Scene } from "babylonjs/scene";
  24649. import { Nullable } from "babylonjs/types";
  24650. import { Matrix } from "babylonjs/Maths/math";
  24651. import { Engine } from "babylonjs/Engines/engine";
  24652. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  24653. import { Observable } from "babylonjs/Misc/observable";
  24654. import { Animatable } from "babylonjs/Animations/animatable";
  24655. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  24656. import { Animation } from "babylonjs/Animations/animation";
  24657. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24659. /**
  24660. * Defines how a node can be built from a string name.
  24661. */
  24662. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24663. /**
  24664. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24665. */
  24666. export class Node implements IBehaviorAware<Node> {
  24667. /** @hidden */
  24668. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  24669. private static _NodeConstructors;
  24670. /**
  24671. * Add a new node constructor
  24672. * @param type defines the type name of the node to construct
  24673. * @param constructorFunc defines the constructor function
  24674. */
  24675. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24676. /**
  24677. * Returns a node constructor based on type name
  24678. * @param type defines the type name
  24679. * @param name defines the new node name
  24680. * @param scene defines the hosting scene
  24681. * @param options defines optional options to transmit to constructors
  24682. * @returns the new constructor or null
  24683. */
  24684. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24685. /**
  24686. * Gets or sets the name of the node
  24687. */
  24688. name: string;
  24689. /**
  24690. * Gets or sets the id of the node
  24691. */
  24692. id: string;
  24693. /**
  24694. * Gets or sets the unique id of the node
  24695. */
  24696. uniqueId: number;
  24697. /**
  24698. * Gets or sets a string used to store user defined state for the node
  24699. */
  24700. state: string;
  24701. /**
  24702. * Gets or sets an object used to store user defined information for the node
  24703. */
  24704. metadata: any;
  24705. /**
  24706. * For internal use only. Please do not use.
  24707. */
  24708. reservedDataStore: any;
  24709. /**
  24710. * Gets or sets a boolean used to define if the node must be serialized
  24711. */
  24712. doNotSerialize: boolean;
  24713. /** @hidden */
  24714. _isDisposed: boolean;
  24715. /**
  24716. * Gets a list of Animations associated with the node
  24717. */
  24718. animations: import("babylonjs/Animations/animation").Animation[];
  24719. protected _ranges: {
  24720. [name: string]: Nullable<AnimationRange>;
  24721. };
  24722. /**
  24723. * Callback raised when the node is ready to be used
  24724. */
  24725. onReady: (node: Node) => void;
  24726. private _isEnabled;
  24727. private _isParentEnabled;
  24728. private _isReady;
  24729. /** @hidden */
  24730. _currentRenderId: number;
  24731. private _parentRenderId;
  24732. protected _childRenderId: number;
  24733. /** @hidden */
  24734. _waitingParentId: Nullable<string>;
  24735. /** @hidden */
  24736. _scene: Scene;
  24737. /** @hidden */
  24738. _cache: any;
  24739. private _parentNode;
  24740. private _children;
  24741. /** @hidden */
  24742. _worldMatrix: Matrix;
  24743. /** @hidden */
  24744. _worldMatrixDeterminant: number;
  24745. /** @hidden */
  24746. private _sceneRootNodesIndex;
  24747. /**
  24748. * Gets a boolean indicating if the node has been disposed
  24749. * @returns true if the node was disposed
  24750. */
  24751. isDisposed(): boolean;
  24752. /**
  24753. * Gets or sets the parent of the node
  24754. */
  24755. parent: Nullable<Node>;
  24756. private addToSceneRootNodes;
  24757. private removeFromSceneRootNodes;
  24758. private _animationPropertiesOverride;
  24759. /**
  24760. * Gets or sets the animation properties override
  24761. */
  24762. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24763. /**
  24764. * Gets a string idenfifying the name of the class
  24765. * @returns "Node" string
  24766. */
  24767. getClassName(): string;
  24768. /** @hidden */
  24769. readonly _isNode: boolean;
  24770. /**
  24771. * An event triggered when the mesh is disposed
  24772. */
  24773. onDisposeObservable: Observable<Node>;
  24774. private _onDisposeObserver;
  24775. /**
  24776. * Sets a callback that will be raised when the node will be disposed
  24777. */
  24778. onDispose: () => void;
  24779. /**
  24780. * Creates a new Node
  24781. * @param name the name and id to be given to this node
  24782. * @param scene the scene this node will be added to
  24783. * @param addToRootNodes the node will be added to scene.rootNodes
  24784. */
  24785. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24786. /**
  24787. * Gets the scene of the node
  24788. * @returns a scene
  24789. */
  24790. getScene(): Scene;
  24791. /**
  24792. * Gets the engine of the node
  24793. * @returns a Engine
  24794. */
  24795. getEngine(): Engine;
  24796. private _behaviors;
  24797. /**
  24798. * Attach a behavior to the node
  24799. * @see http://doc.babylonjs.com/features/behaviour
  24800. * @param behavior defines the behavior to attach
  24801. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24802. * @returns the current Node
  24803. */
  24804. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24805. /**
  24806. * Remove an attached behavior
  24807. * @see http://doc.babylonjs.com/features/behaviour
  24808. * @param behavior defines the behavior to attach
  24809. * @returns the current Node
  24810. */
  24811. removeBehavior(behavior: Behavior<Node>): Node;
  24812. /**
  24813. * Gets the list of attached behaviors
  24814. * @see http://doc.babylonjs.com/features/behaviour
  24815. */
  24816. readonly behaviors: Behavior<Node>[];
  24817. /**
  24818. * Gets an attached behavior by name
  24819. * @param name defines the name of the behavior to look for
  24820. * @see http://doc.babylonjs.com/features/behaviour
  24821. * @returns null if behavior was not found else the requested behavior
  24822. */
  24823. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24824. /**
  24825. * Returns the latest update of the World matrix
  24826. * @returns a Matrix
  24827. */
  24828. getWorldMatrix(): Matrix;
  24829. /** @hidden */
  24830. _getWorldMatrixDeterminant(): number;
  24831. /**
  24832. * Returns directly the latest state of the mesh World matrix.
  24833. * A Matrix is returned.
  24834. */
  24835. readonly worldMatrixFromCache: Matrix;
  24836. /** @hidden */
  24837. _initCache(): void;
  24838. /** @hidden */
  24839. updateCache(force?: boolean): void;
  24840. /** @hidden */
  24841. _updateCache(ignoreParentClass?: boolean): void;
  24842. /** @hidden */
  24843. _isSynchronized(): boolean;
  24844. /** @hidden */
  24845. _markSyncedWithParent(): void;
  24846. /** @hidden */
  24847. isSynchronizedWithParent(): boolean;
  24848. /** @hidden */
  24849. isSynchronized(): boolean;
  24850. /**
  24851. * Is this node ready to be used/rendered
  24852. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24853. * @return true if the node is ready
  24854. */
  24855. isReady(completeCheck?: boolean): boolean;
  24856. /**
  24857. * Is this node enabled?
  24858. * 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
  24859. * @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
  24860. * @return whether this node (and its parent) is enabled
  24861. */
  24862. isEnabled(checkAncestors?: boolean): boolean;
  24863. /** @hidden */
  24864. protected _syncParentEnabledState(): void;
  24865. /**
  24866. * Set the enabled state of this node
  24867. * @param value defines the new enabled state
  24868. */
  24869. setEnabled(value: boolean): void;
  24870. /**
  24871. * Is this node a descendant of the given node?
  24872. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24873. * @param ancestor defines the parent node to inspect
  24874. * @returns a boolean indicating if this node is a descendant of the given node
  24875. */
  24876. isDescendantOf(ancestor: Node): boolean;
  24877. /** @hidden */
  24878. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24879. /**
  24880. * Will return all nodes that have this node as ascendant
  24881. * @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
  24882. * @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
  24883. * @return all children nodes of all types
  24884. */
  24885. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24886. /**
  24887. * Get all child-meshes of this node
  24888. * @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
  24889. * @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
  24890. * @returns an array of AbstractMesh
  24891. */
  24892. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24893. /**
  24894. * Get all direct children of this node
  24895. * @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
  24896. * @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)
  24897. * @returns an array of Node
  24898. */
  24899. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24900. /** @hidden */
  24901. _setReady(state: boolean): void;
  24902. /**
  24903. * Get an animation by name
  24904. * @param name defines the name of the animation to look for
  24905. * @returns null if not found else the requested animation
  24906. */
  24907. getAnimationByName(name: string): Nullable<Animation>;
  24908. /**
  24909. * Creates an animation range for this node
  24910. * @param name defines the name of the range
  24911. * @param from defines the starting key
  24912. * @param to defines the end key
  24913. */
  24914. createAnimationRange(name: string, from: number, to: number): void;
  24915. /**
  24916. * Delete a specific animation range
  24917. * @param name defines the name of the range to delete
  24918. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24919. */
  24920. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24921. /**
  24922. * Get an animation range by name
  24923. * @param name defines the name of the animation range to look for
  24924. * @returns null if not found else the requested animation range
  24925. */
  24926. getAnimationRange(name: string): Nullable<AnimationRange>;
  24927. /**
  24928. * Will start the animation sequence
  24929. * @param name defines the range frames for animation sequence
  24930. * @param loop defines if the animation should loop (false by default)
  24931. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24932. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24933. * @returns the object created for this animation. If range does not exist, it will return null
  24934. */
  24935. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24936. /**
  24937. * Serialize animation ranges into a JSON compatible object
  24938. * @returns serialization object
  24939. */
  24940. serializeAnimationRanges(): any;
  24941. /**
  24942. * Computes the world matrix of the node
  24943. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24944. * @returns the world matrix
  24945. */
  24946. computeWorldMatrix(force?: boolean): Matrix;
  24947. /**
  24948. * Releases resources associated with this node.
  24949. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24950. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24951. */
  24952. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24953. /**
  24954. * Parse animation range data from a serialization object and store them into a given node
  24955. * @param node defines where to store the animation ranges
  24956. * @param parsedNode defines the serialization object to read data from
  24957. * @param scene defines the hosting scene
  24958. */
  24959. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24960. }
  24961. }
  24962. declare module "babylonjs/Animations/animation" {
  24963. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  24964. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  24965. import { Nullable } from "babylonjs/types";
  24966. import { Scene } from "babylonjs/scene";
  24967. import { IAnimatable } from "babylonjs/Misc/tools";
  24968. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  24969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  24970. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  24971. import { Node } from "babylonjs/node";
  24972. import { Animatable } from "babylonjs/Animations/animatable";
  24973. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  24974. /**
  24975. * Class used to store any kind of animation
  24976. */
  24977. export class Animation {
  24978. /**Name of the animation */
  24979. name: string;
  24980. /**Property to animate */
  24981. targetProperty: string;
  24982. /**The frames per second of the animation */
  24983. framePerSecond: number;
  24984. /**The data type of the animation */
  24985. dataType: number;
  24986. /**The loop mode of the animation */
  24987. loopMode?: number | undefined;
  24988. /**Specifies if blending should be enabled */
  24989. enableBlending?: boolean | undefined;
  24990. /**
  24991. * Use matrix interpolation instead of using direct key value when animating matrices
  24992. */
  24993. static AllowMatricesInterpolation: boolean;
  24994. /**
  24995. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24996. */
  24997. static AllowMatrixDecomposeForInterpolation: boolean;
  24998. /**
  24999. * Stores the key frames of the animation
  25000. */
  25001. private _keys;
  25002. /**
  25003. * Stores the easing function of the animation
  25004. */
  25005. private _easingFunction;
  25006. /**
  25007. * @hidden Internal use only
  25008. */
  25009. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25010. /**
  25011. * The set of event that will be linked to this animation
  25012. */
  25013. private _events;
  25014. /**
  25015. * Stores an array of target property paths
  25016. */
  25017. targetPropertyPath: string[];
  25018. /**
  25019. * Stores the blending speed of the animation
  25020. */
  25021. blendingSpeed: number;
  25022. /**
  25023. * Stores the animation ranges for the animation
  25024. */
  25025. private _ranges;
  25026. /**
  25027. * @hidden Internal use
  25028. */
  25029. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25030. /**
  25031. * Sets up an animation
  25032. * @param property The property to animate
  25033. * @param animationType The animation type to apply
  25034. * @param framePerSecond The frames per second of the animation
  25035. * @param easingFunction The easing function used in the animation
  25036. * @returns The created animation
  25037. */
  25038. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25039. /**
  25040. * Create and start an animation on a node
  25041. * @param name defines the name of the global animation that will be run on all nodes
  25042. * @param node defines the root node where the animation will take place
  25043. * @param targetProperty defines property to animate
  25044. * @param framePerSecond defines the number of frame per second yo use
  25045. * @param totalFrame defines the number of frames in total
  25046. * @param from defines the initial value
  25047. * @param to defines the final value
  25048. * @param loopMode defines which loop mode you want to use (off by default)
  25049. * @param easingFunction defines the easing function to use (linear by default)
  25050. * @param onAnimationEnd defines the callback to call when animation end
  25051. * @returns the animatable created for this animation
  25052. */
  25053. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25054. /**
  25055. * Create and start an animation on a node and its descendants
  25056. * @param name defines the name of the global animation that will be run on all nodes
  25057. * @param node defines the root node where the animation will take place
  25058. * @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
  25059. * @param targetProperty defines property to animate
  25060. * @param framePerSecond defines the number of frame per second to use
  25061. * @param totalFrame defines the number of frames in total
  25062. * @param from defines the initial value
  25063. * @param to defines the final value
  25064. * @param loopMode defines which loop mode you want to use (off by default)
  25065. * @param easingFunction defines the easing function to use (linear by default)
  25066. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25067. * @returns the list of animatables created for all nodes
  25068. * @example https://www.babylonjs-playground.com/#MH0VLI
  25069. */
  25070. 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[]>;
  25071. /**
  25072. * Creates a new animation, merges it with the existing animations and starts it
  25073. * @param name Name of the animation
  25074. * @param node Node which contains the scene that begins the animations
  25075. * @param targetProperty Specifies which property to animate
  25076. * @param framePerSecond The frames per second of the animation
  25077. * @param totalFrame The total number of frames
  25078. * @param from The frame at the beginning of the animation
  25079. * @param to The frame at the end of the animation
  25080. * @param loopMode Specifies the loop mode of the animation
  25081. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25082. * @param onAnimationEnd Callback to run once the animation is complete
  25083. * @returns Nullable animation
  25084. */
  25085. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25086. /**
  25087. * Transition property of an host to the target Value
  25088. * @param property The property to transition
  25089. * @param targetValue The target Value of the property
  25090. * @param host The object where the property to animate belongs
  25091. * @param scene Scene used to run the animation
  25092. * @param frameRate Framerate (in frame/s) to use
  25093. * @param transition The transition type we want to use
  25094. * @param duration The duration of the animation, in milliseconds
  25095. * @param onAnimationEnd Callback trigger at the end of the animation
  25096. * @returns Nullable animation
  25097. */
  25098. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25099. /**
  25100. * Return the array of runtime animations currently using this animation
  25101. */
  25102. readonly runtimeAnimations: RuntimeAnimation[];
  25103. /**
  25104. * Specifies if any of the runtime animations are currently running
  25105. */
  25106. readonly hasRunningRuntimeAnimations: boolean;
  25107. /**
  25108. * Initializes the animation
  25109. * @param name Name of the animation
  25110. * @param targetProperty Property to animate
  25111. * @param framePerSecond The frames per second of the animation
  25112. * @param dataType The data type of the animation
  25113. * @param loopMode The loop mode of the animation
  25114. * @param enableBlending Specifies if blending should be enabled
  25115. */
  25116. constructor(
  25117. /**Name of the animation */
  25118. name: string,
  25119. /**Property to animate */
  25120. targetProperty: string,
  25121. /**The frames per second of the animation */
  25122. framePerSecond: number,
  25123. /**The data type of the animation */
  25124. dataType: number,
  25125. /**The loop mode of the animation */
  25126. loopMode?: number | undefined,
  25127. /**Specifies if blending should be enabled */
  25128. enableBlending?: boolean | undefined);
  25129. /**
  25130. * Converts the animation to a string
  25131. * @param fullDetails support for multiple levels of logging within scene loading
  25132. * @returns String form of the animation
  25133. */
  25134. toString(fullDetails?: boolean): string;
  25135. /**
  25136. * Add an event to this animation
  25137. * @param event Event to add
  25138. */
  25139. addEvent(event: AnimationEvent): void;
  25140. /**
  25141. * Remove all events found at the given frame
  25142. * @param frame The frame to remove events from
  25143. */
  25144. removeEvents(frame: number): void;
  25145. /**
  25146. * Retrieves all the events from the animation
  25147. * @returns Events from the animation
  25148. */
  25149. getEvents(): AnimationEvent[];
  25150. /**
  25151. * Creates an animation range
  25152. * @param name Name of the animation range
  25153. * @param from Starting frame of the animation range
  25154. * @param to Ending frame of the animation
  25155. */
  25156. createRange(name: string, from: number, to: number): void;
  25157. /**
  25158. * Deletes an animation range by name
  25159. * @param name Name of the animation range to delete
  25160. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25161. */
  25162. deleteRange(name: string, deleteFrames?: boolean): void;
  25163. /**
  25164. * Gets the animation range by name, or null if not defined
  25165. * @param name Name of the animation range
  25166. * @returns Nullable animation range
  25167. */
  25168. getRange(name: string): Nullable<AnimationRange>;
  25169. /**
  25170. * Gets the key frames from the animation
  25171. * @returns The key frames of the animation
  25172. */
  25173. getKeys(): Array<IAnimationKey>;
  25174. /**
  25175. * Gets the highest frame rate of the animation
  25176. * @returns Highest frame rate of the animation
  25177. */
  25178. getHighestFrame(): number;
  25179. /**
  25180. * Gets the easing function of the animation
  25181. * @returns Easing function of the animation
  25182. */
  25183. getEasingFunction(): IEasingFunction;
  25184. /**
  25185. * Sets the easing function of the animation
  25186. * @param easingFunction A custom mathematical formula for animation
  25187. */
  25188. setEasingFunction(easingFunction: EasingFunction): void;
  25189. /**
  25190. * Interpolates a scalar linearly
  25191. * @param startValue Start value of the animation curve
  25192. * @param endValue End value of the animation curve
  25193. * @param gradient Scalar amount to interpolate
  25194. * @returns Interpolated scalar value
  25195. */
  25196. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25197. /**
  25198. * Interpolates a scalar cubically
  25199. * @param startValue Start value of the animation curve
  25200. * @param outTangent End tangent of the animation
  25201. * @param endValue End value of the animation curve
  25202. * @param inTangent Start tangent of the animation curve
  25203. * @param gradient Scalar amount to interpolate
  25204. * @returns Interpolated scalar value
  25205. */
  25206. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25207. /**
  25208. * Interpolates a quaternion using a spherical linear interpolation
  25209. * @param startValue Start value of the animation curve
  25210. * @param endValue End value of the animation curve
  25211. * @param gradient Scalar amount to interpolate
  25212. * @returns Interpolated quaternion value
  25213. */
  25214. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25215. /**
  25216. * Interpolates a quaternion cubically
  25217. * @param startValue Start value of the animation curve
  25218. * @param outTangent End tangent of the animation curve
  25219. * @param endValue End value of the animation curve
  25220. * @param inTangent Start tangent of the animation curve
  25221. * @param gradient Scalar amount to interpolate
  25222. * @returns Interpolated quaternion value
  25223. */
  25224. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25225. /**
  25226. * Interpolates a Vector3 linearl
  25227. * @param startValue Start value of the animation curve
  25228. * @param endValue End value of the animation curve
  25229. * @param gradient Scalar amount to interpolate
  25230. * @returns Interpolated scalar value
  25231. */
  25232. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25233. /**
  25234. * Interpolates a Vector3 cubically
  25235. * @param startValue Start value of the animation curve
  25236. * @param outTangent End tangent of the animation
  25237. * @param endValue End value of the animation curve
  25238. * @param inTangent Start tangent of the animation curve
  25239. * @param gradient Scalar amount to interpolate
  25240. * @returns InterpolatedVector3 value
  25241. */
  25242. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25243. /**
  25244. * Interpolates a Vector2 linearly
  25245. * @param startValue Start value of the animation curve
  25246. * @param endValue End value of the animation curve
  25247. * @param gradient Scalar amount to interpolate
  25248. * @returns Interpolated Vector2 value
  25249. */
  25250. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25251. /**
  25252. * Interpolates a Vector2 cubically
  25253. * @param startValue Start value of the animation curve
  25254. * @param outTangent End tangent of the animation
  25255. * @param endValue End value of the animation curve
  25256. * @param inTangent Start tangent of the animation curve
  25257. * @param gradient Scalar amount to interpolate
  25258. * @returns Interpolated Vector2 value
  25259. */
  25260. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25261. /**
  25262. * Interpolates a size linearly
  25263. * @param startValue Start value of the animation curve
  25264. * @param endValue End value of the animation curve
  25265. * @param gradient Scalar amount to interpolate
  25266. * @returns Interpolated Size value
  25267. */
  25268. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25269. /**
  25270. * Interpolates a Color3 linearly
  25271. * @param startValue Start value of the animation curve
  25272. * @param endValue End value of the animation curve
  25273. * @param gradient Scalar amount to interpolate
  25274. * @returns Interpolated Color3 value
  25275. */
  25276. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25277. /**
  25278. * @hidden Internal use only
  25279. */
  25280. _getKeyValue(value: any): any;
  25281. /**
  25282. * @hidden Internal use only
  25283. */
  25284. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  25285. /**
  25286. * Defines the function to use to interpolate matrices
  25287. * @param startValue defines the start matrix
  25288. * @param endValue defines the end matrix
  25289. * @param gradient defines the gradient between both matrices
  25290. * @param result defines an optional target matrix where to store the interpolation
  25291. * @returns the interpolated matrix
  25292. */
  25293. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25294. /**
  25295. * Makes a copy of the animation
  25296. * @returns Cloned animation
  25297. */
  25298. clone(): Animation;
  25299. /**
  25300. * Sets the key frames of the animation
  25301. * @param values The animation key frames to set
  25302. */
  25303. setKeys(values: Array<IAnimationKey>): void;
  25304. /**
  25305. * Serializes the animation to an object
  25306. * @returns Serialized object
  25307. */
  25308. serialize(): any;
  25309. /**
  25310. * Float animation type
  25311. */
  25312. private static _ANIMATIONTYPE_FLOAT;
  25313. /**
  25314. * Vector3 animation type
  25315. */
  25316. private static _ANIMATIONTYPE_VECTOR3;
  25317. /**
  25318. * Quaternion animation type
  25319. */
  25320. private static _ANIMATIONTYPE_QUATERNION;
  25321. /**
  25322. * Matrix animation type
  25323. */
  25324. private static _ANIMATIONTYPE_MATRIX;
  25325. /**
  25326. * Color3 animation type
  25327. */
  25328. private static _ANIMATIONTYPE_COLOR3;
  25329. /**
  25330. * Vector2 animation type
  25331. */
  25332. private static _ANIMATIONTYPE_VECTOR2;
  25333. /**
  25334. * Size animation type
  25335. */
  25336. private static _ANIMATIONTYPE_SIZE;
  25337. /**
  25338. * Relative Loop Mode
  25339. */
  25340. private static _ANIMATIONLOOPMODE_RELATIVE;
  25341. /**
  25342. * Cycle Loop Mode
  25343. */
  25344. private static _ANIMATIONLOOPMODE_CYCLE;
  25345. /**
  25346. * Constant Loop Mode
  25347. */
  25348. private static _ANIMATIONLOOPMODE_CONSTANT;
  25349. /**
  25350. * Get the float animation type
  25351. */
  25352. static readonly ANIMATIONTYPE_FLOAT: number;
  25353. /**
  25354. * Get the Vector3 animation type
  25355. */
  25356. static readonly ANIMATIONTYPE_VECTOR3: number;
  25357. /**
  25358. * Get the Vector2 animation type
  25359. */
  25360. static readonly ANIMATIONTYPE_VECTOR2: number;
  25361. /**
  25362. * Get the Size animation type
  25363. */
  25364. static readonly ANIMATIONTYPE_SIZE: number;
  25365. /**
  25366. * Get the Quaternion animation type
  25367. */
  25368. static readonly ANIMATIONTYPE_QUATERNION: number;
  25369. /**
  25370. * Get the Matrix animation type
  25371. */
  25372. static readonly ANIMATIONTYPE_MATRIX: number;
  25373. /**
  25374. * Get the Color3 animation type
  25375. */
  25376. static readonly ANIMATIONTYPE_COLOR3: number;
  25377. /**
  25378. * Get the Relative Loop Mode
  25379. */
  25380. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25381. /**
  25382. * Get the Cycle Loop Mode
  25383. */
  25384. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25385. /**
  25386. * Get the Constant Loop Mode
  25387. */
  25388. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25389. /** @hidden */
  25390. static _UniversalLerp(left: any, right: any, amount: number): any;
  25391. /**
  25392. * Parses an animation object and creates an animation
  25393. * @param parsedAnimation Parsed animation object
  25394. * @returns Animation object
  25395. */
  25396. static Parse(parsedAnimation: any): Animation;
  25397. /**
  25398. * Appends the serialized animations from the source animations
  25399. * @param source Source containing the animations
  25400. * @param destination Target to store the animations
  25401. */
  25402. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25403. }
  25404. }
  25405. declare module "babylonjs/Materials/Textures/baseTexture" {
  25406. import { Observable } from "babylonjs/Misc/observable";
  25407. import { IAnimatable } from "babylonjs/Misc/tools";
  25408. import { Nullable } from "babylonjs/types";
  25409. import { Scene } from "babylonjs/scene";
  25410. import { Matrix, ISize } from "babylonjs/Maths/math";
  25411. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  25412. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25413. /**
  25414. * Base class of all the textures in babylon.
  25415. * It groups all the common properties the materials, post process, lights... might need
  25416. * in order to make a correct use of the texture.
  25417. */
  25418. export class BaseTexture implements IAnimatable {
  25419. /**
  25420. * Default anisotropic filtering level for the application.
  25421. * It is set to 4 as a good tradeoff between perf and quality.
  25422. */
  25423. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25424. /**
  25425. * Gets or sets the unique id of the texture
  25426. */
  25427. uniqueId: number;
  25428. /**
  25429. * Define the name of the texture.
  25430. */
  25431. name: string;
  25432. /**
  25433. * Gets or sets an object used to store user defined information.
  25434. */
  25435. metadata: any;
  25436. /**
  25437. * For internal use only. Please do not use.
  25438. */
  25439. reservedDataStore: any;
  25440. private _hasAlpha;
  25441. /**
  25442. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25443. */
  25444. hasAlpha: boolean;
  25445. /**
  25446. * Defines if the alpha value should be determined via the rgb values.
  25447. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25448. */
  25449. getAlphaFromRGB: boolean;
  25450. /**
  25451. * Intensity or strength of the texture.
  25452. * It is commonly used by materials to fine tune the intensity of the texture
  25453. */
  25454. level: number;
  25455. /**
  25456. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25457. * This is part of the texture as textures usually maps to one uv set.
  25458. */
  25459. coordinatesIndex: number;
  25460. private _coordinatesMode;
  25461. /**
  25462. * How a texture is mapped.
  25463. *
  25464. * | Value | Type | Description |
  25465. * | ----- | ----------------------------------- | ----------- |
  25466. * | 0 | EXPLICIT_MODE | |
  25467. * | 1 | SPHERICAL_MODE | |
  25468. * | 2 | PLANAR_MODE | |
  25469. * | 3 | CUBIC_MODE | |
  25470. * | 4 | PROJECTION_MODE | |
  25471. * | 5 | SKYBOX_MODE | |
  25472. * | 6 | INVCUBIC_MODE | |
  25473. * | 7 | EQUIRECTANGULAR_MODE | |
  25474. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25475. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25476. */
  25477. coordinatesMode: number;
  25478. /**
  25479. * | Value | Type | Description |
  25480. * | ----- | ------------------ | ----------- |
  25481. * | 0 | CLAMP_ADDRESSMODE | |
  25482. * | 1 | WRAP_ADDRESSMODE | |
  25483. * | 2 | MIRROR_ADDRESSMODE | |
  25484. */
  25485. wrapU: number;
  25486. /**
  25487. * | Value | Type | Description |
  25488. * | ----- | ------------------ | ----------- |
  25489. * | 0 | CLAMP_ADDRESSMODE | |
  25490. * | 1 | WRAP_ADDRESSMODE | |
  25491. * | 2 | MIRROR_ADDRESSMODE | |
  25492. */
  25493. wrapV: number;
  25494. /**
  25495. * | Value | Type | Description |
  25496. * | ----- | ------------------ | ----------- |
  25497. * | 0 | CLAMP_ADDRESSMODE | |
  25498. * | 1 | WRAP_ADDRESSMODE | |
  25499. * | 2 | MIRROR_ADDRESSMODE | |
  25500. */
  25501. wrapR: number;
  25502. /**
  25503. * With compliant hardware and browser (supporting anisotropic filtering)
  25504. * this defines the level of anisotropic filtering in the texture.
  25505. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25506. */
  25507. anisotropicFilteringLevel: number;
  25508. /**
  25509. * Define if the texture is a cube texture or if false a 2d texture.
  25510. */
  25511. isCube: boolean;
  25512. /**
  25513. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25514. */
  25515. is3D: boolean;
  25516. /**
  25517. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25518. * HDR texture are usually stored in linear space.
  25519. * This only impacts the PBR and Background materials
  25520. */
  25521. gammaSpace: boolean;
  25522. /**
  25523. * Gets whether or not the texture contains RGBD data.
  25524. */
  25525. readonly isRGBD: boolean;
  25526. /**
  25527. * Is Z inverted in the texture (useful in a cube texture).
  25528. */
  25529. invertZ: boolean;
  25530. /**
  25531. * Are mip maps generated for this texture or not.
  25532. */
  25533. readonly noMipmap: boolean;
  25534. /**
  25535. * @hidden
  25536. */
  25537. lodLevelInAlpha: boolean;
  25538. /**
  25539. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25540. */
  25541. lodGenerationOffset: number;
  25542. /**
  25543. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25544. */
  25545. lodGenerationScale: number;
  25546. /**
  25547. * Define if the texture is a render target.
  25548. */
  25549. isRenderTarget: boolean;
  25550. /**
  25551. * Define the unique id of the texture in the scene.
  25552. */
  25553. readonly uid: string;
  25554. /**
  25555. * Return a string representation of the texture.
  25556. * @returns the texture as a string
  25557. */
  25558. toString(): string;
  25559. /**
  25560. * Get the class name of the texture.
  25561. * @returns "BaseTexture"
  25562. */
  25563. getClassName(): string;
  25564. /**
  25565. * Define the list of animation attached to the texture.
  25566. */
  25567. animations: import("babylonjs/Animations/animation").Animation[];
  25568. /**
  25569. * An event triggered when the texture is disposed.
  25570. */
  25571. onDisposeObservable: Observable<BaseTexture>;
  25572. private _onDisposeObserver;
  25573. /**
  25574. * Callback triggered when the texture has been disposed.
  25575. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25576. */
  25577. onDispose: () => void;
  25578. /**
  25579. * Define the current state of the loading sequence when in delayed load mode.
  25580. */
  25581. delayLoadState: number;
  25582. private _scene;
  25583. /** @hidden */
  25584. _texture: Nullable<InternalTexture>;
  25585. private _uid;
  25586. /**
  25587. * Define if the texture is preventinga material to render or not.
  25588. * If not and the texture is not ready, the engine will use a default black texture instead.
  25589. */
  25590. readonly isBlocking: boolean;
  25591. /**
  25592. * Instantiates a new BaseTexture.
  25593. * Base class of all the textures in babylon.
  25594. * It groups all the common properties the materials, post process, lights... might need
  25595. * in order to make a correct use of the texture.
  25596. * @param scene Define the scene the texture blongs to
  25597. */
  25598. constructor(scene: Nullable<Scene>);
  25599. /**
  25600. * Get the scene the texture belongs to.
  25601. * @returns the scene or null if undefined
  25602. */
  25603. getScene(): Nullable<Scene>;
  25604. /**
  25605. * Get the texture transform matrix used to offset tile the texture for istance.
  25606. * @returns the transformation matrix
  25607. */
  25608. getTextureMatrix(): Matrix;
  25609. /**
  25610. * Get the texture reflection matrix used to rotate/transform the reflection.
  25611. * @returns the reflection matrix
  25612. */
  25613. getReflectionTextureMatrix(): Matrix;
  25614. /**
  25615. * Get the underlying lower level texture from Babylon.
  25616. * @returns the insternal texture
  25617. */
  25618. getInternalTexture(): Nullable<InternalTexture>;
  25619. /**
  25620. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25621. * @returns true if ready or not blocking
  25622. */
  25623. isReadyOrNotBlocking(): boolean;
  25624. /**
  25625. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25626. * @returns true if fully ready
  25627. */
  25628. isReady(): boolean;
  25629. private _cachedSize;
  25630. /**
  25631. * Get the size of the texture.
  25632. * @returns the texture size.
  25633. */
  25634. getSize(): ISize;
  25635. /**
  25636. * Get the base size of the texture.
  25637. * It can be different from the size if the texture has been resized for POT for instance
  25638. * @returns the base size
  25639. */
  25640. getBaseSize(): ISize;
  25641. /**
  25642. * Update the sampling mode of the texture.
  25643. * Default is Trilinear mode.
  25644. *
  25645. * | Value | Type | Description |
  25646. * | ----- | ------------------ | ----------- |
  25647. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25648. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25649. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25650. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25651. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25652. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25653. * | 7 | NEAREST_LINEAR | |
  25654. * | 8 | NEAREST_NEAREST | |
  25655. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25656. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25657. * | 11 | LINEAR_LINEAR | |
  25658. * | 12 | LINEAR_NEAREST | |
  25659. *
  25660. * > _mag_: magnification filter (close to the viewer)
  25661. * > _min_: minification filter (far from the viewer)
  25662. * > _mip_: filter used between mip map levels
  25663. *@param samplingMode Define the new sampling mode of the texture
  25664. */
  25665. updateSamplingMode(samplingMode: number): void;
  25666. /**
  25667. * Scales the texture if is `canRescale()`
  25668. * @param ratio the resize factor we want to use to rescale
  25669. */
  25670. scale(ratio: number): void;
  25671. /**
  25672. * Get if the texture can rescale.
  25673. */
  25674. readonly canRescale: boolean;
  25675. /** @hidden */
  25676. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  25677. /** @hidden */
  25678. _rebuild(): void;
  25679. /**
  25680. * Triggers the load sequence in delayed load mode.
  25681. */
  25682. delayLoad(): void;
  25683. /**
  25684. * Clones the texture.
  25685. * @returns the cloned texture
  25686. */
  25687. clone(): Nullable<BaseTexture>;
  25688. /**
  25689. * Get the texture underlying type (INT, FLOAT...)
  25690. */
  25691. readonly textureType: number;
  25692. /**
  25693. * Get the texture underlying format (RGB, RGBA...)
  25694. */
  25695. readonly textureFormat: number;
  25696. /**
  25697. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25698. * This will returns an RGBA array buffer containing either in values (0-255) or
  25699. * float values (0-1) depending of the underlying buffer type.
  25700. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25701. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25702. * @param buffer defines a user defined buffer to fill with data (can be null)
  25703. * @returns The Array buffer containing the pixels data.
  25704. */
  25705. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25706. /**
  25707. * Release and destroy the underlying lower level texture aka internalTexture.
  25708. */
  25709. releaseInternalTexture(): void;
  25710. /**
  25711. * Get the polynomial representation of the texture data.
  25712. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25713. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25714. */
  25715. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25716. /** @hidden */
  25717. readonly _lodTextureHigh: Nullable<BaseTexture>;
  25718. /** @hidden */
  25719. readonly _lodTextureMid: Nullable<BaseTexture>;
  25720. /** @hidden */
  25721. readonly _lodTextureLow: Nullable<BaseTexture>;
  25722. /**
  25723. * Dispose the texture and release its associated resources.
  25724. */
  25725. dispose(): void;
  25726. /**
  25727. * Serialize the texture into a JSON representation that can be parsed later on.
  25728. * @returns the JSON representation of the texture
  25729. */
  25730. serialize(): any;
  25731. /**
  25732. * Helper function to be called back once a list of texture contains only ready textures.
  25733. * @param textures Define the list of textures to wait for
  25734. * @param callback Define the callback triggered once the entire list will be ready
  25735. */
  25736. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25737. }
  25738. }
  25739. declare module "babylonjs/Materials/uniformBuffer" {
  25740. import { Nullable, FloatArray } from "babylonjs/types";
  25741. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  25742. import { Engine } from "babylonjs/Engines/engine";
  25743. import { Effect } from "babylonjs/Materials/effect";
  25744. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25745. /**
  25746. * Uniform buffer objects.
  25747. *
  25748. * Handles blocks of uniform on the GPU.
  25749. *
  25750. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25751. *
  25752. * For more information, please refer to :
  25753. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25754. */
  25755. export class UniformBuffer {
  25756. private _engine;
  25757. private _buffer;
  25758. private _data;
  25759. private _bufferData;
  25760. private _dynamic?;
  25761. private _uniformLocations;
  25762. private _uniformSizes;
  25763. private _uniformLocationPointer;
  25764. private _needSync;
  25765. private _noUBO;
  25766. private _currentEffect;
  25767. private static _MAX_UNIFORM_SIZE;
  25768. private static _tempBuffer;
  25769. /**
  25770. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25771. * This is dynamic to allow compat with webgl 1 and 2.
  25772. * You will need to pass the name of the uniform as well as the value.
  25773. */
  25774. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25775. /**
  25776. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25777. * This is dynamic to allow compat with webgl 1 and 2.
  25778. * You will need to pass the name of the uniform as well as the value.
  25779. */
  25780. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25781. /**
  25782. * Lambda to Update a single float in a uniform buffer.
  25783. * This is dynamic to allow compat with webgl 1 and 2.
  25784. * You will need to pass the name of the uniform as well as the value.
  25785. */
  25786. updateFloat: (name: string, x: number) => void;
  25787. /**
  25788. * Lambda to Update a vec2 of float in a uniform buffer.
  25789. * This is dynamic to allow compat with webgl 1 and 2.
  25790. * You will need to pass the name of the uniform as well as the value.
  25791. */
  25792. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25793. /**
  25794. * Lambda to Update a vec3 of float in a uniform buffer.
  25795. * This is dynamic to allow compat with webgl 1 and 2.
  25796. * You will need to pass the name of the uniform as well as the value.
  25797. */
  25798. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25799. /**
  25800. * Lambda to Update a vec4 of float in a uniform buffer.
  25801. * This is dynamic to allow compat with webgl 1 and 2.
  25802. * You will need to pass the name of the uniform as well as the value.
  25803. */
  25804. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25805. /**
  25806. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25807. * This is dynamic to allow compat with webgl 1 and 2.
  25808. * You will need to pass the name of the uniform as well as the value.
  25809. */
  25810. updateMatrix: (name: string, mat: Matrix) => void;
  25811. /**
  25812. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25813. * This is dynamic to allow compat with webgl 1 and 2.
  25814. * You will need to pass the name of the uniform as well as the value.
  25815. */
  25816. updateVector3: (name: string, vector: Vector3) => void;
  25817. /**
  25818. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25819. * This is dynamic to allow compat with webgl 1 and 2.
  25820. * You will need to pass the name of the uniform as well as the value.
  25821. */
  25822. updateVector4: (name: string, vector: Vector4) => void;
  25823. /**
  25824. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25825. * This is dynamic to allow compat with webgl 1 and 2.
  25826. * You will need to pass the name of the uniform as well as the value.
  25827. */
  25828. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25829. /**
  25830. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25831. * This is dynamic to allow compat with webgl 1 and 2.
  25832. * You will need to pass the name of the uniform as well as the value.
  25833. */
  25834. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25835. /**
  25836. * Instantiates a new Uniform buffer objects.
  25837. *
  25838. * Handles blocks of uniform on the GPU.
  25839. *
  25840. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25841. *
  25842. * For more information, please refer to :
  25843. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25844. * @param engine Define the engine the buffer is associated with
  25845. * @param data Define the data contained in the buffer
  25846. * @param dynamic Define if the buffer is updatable
  25847. */
  25848. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25849. /**
  25850. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25851. * or just falling back on setUniformXXX calls.
  25852. */
  25853. readonly useUbo: boolean;
  25854. /**
  25855. * Indicates if the WebGL underlying uniform buffer is in sync
  25856. * with the javascript cache data.
  25857. */
  25858. readonly isSync: boolean;
  25859. /**
  25860. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25861. * Also, a dynamic UniformBuffer will disable cache verification and always
  25862. * update the underlying WebGL uniform buffer to the GPU.
  25863. * @returns if Dynamic, otherwise false
  25864. */
  25865. isDynamic(): boolean;
  25866. /**
  25867. * The data cache on JS side.
  25868. * @returns the underlying data as a float array
  25869. */
  25870. getData(): Float32Array;
  25871. /**
  25872. * The underlying WebGL Uniform buffer.
  25873. * @returns the webgl buffer
  25874. */
  25875. getBuffer(): Nullable<WebGLBuffer>;
  25876. /**
  25877. * std140 layout specifies how to align data within an UBO structure.
  25878. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25879. * for specs.
  25880. */
  25881. private _fillAlignment;
  25882. /**
  25883. * Adds an uniform in the buffer.
  25884. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25885. * for the layout to be correct !
  25886. * @param name Name of the uniform, as used in the uniform block in the shader.
  25887. * @param size Data size, or data directly.
  25888. */
  25889. addUniform(name: string, size: number | number[]): void;
  25890. /**
  25891. * Adds a Matrix 4x4 to the uniform buffer.
  25892. * @param name Name of the uniform, as used in the uniform block in the shader.
  25893. * @param mat A 4x4 matrix.
  25894. */
  25895. addMatrix(name: string, mat: Matrix): void;
  25896. /**
  25897. * Adds a vec2 to the uniform buffer.
  25898. * @param name Name of the uniform, as used in the uniform block in the shader.
  25899. * @param x Define the x component value of the vec2
  25900. * @param y Define the y component value of the vec2
  25901. */
  25902. addFloat2(name: string, x: number, y: number): void;
  25903. /**
  25904. * Adds a vec3 to the uniform buffer.
  25905. * @param name Name of the uniform, as used in the uniform block in the shader.
  25906. * @param x Define the x component value of the vec3
  25907. * @param y Define the y component value of the vec3
  25908. * @param z Define the z component value of the vec3
  25909. */
  25910. addFloat3(name: string, x: number, y: number, z: number): void;
  25911. /**
  25912. * Adds a vec3 to the uniform buffer.
  25913. * @param name Name of the uniform, as used in the uniform block in the shader.
  25914. * @param color Define the vec3 from a Color
  25915. */
  25916. addColor3(name: string, color: Color3): void;
  25917. /**
  25918. * Adds a vec4 to the uniform buffer.
  25919. * @param name Name of the uniform, as used in the uniform block in the shader.
  25920. * @param color Define the rgb components from a Color
  25921. * @param alpha Define the a component of the vec4
  25922. */
  25923. addColor4(name: string, color: Color3, alpha: number): void;
  25924. /**
  25925. * Adds a vec3 to the uniform buffer.
  25926. * @param name Name of the uniform, as used in the uniform block in the shader.
  25927. * @param vector Define the vec3 components from a Vector
  25928. */
  25929. addVector3(name: string, vector: Vector3): void;
  25930. /**
  25931. * Adds a Matrix 3x3 to the uniform buffer.
  25932. * @param name Name of the uniform, as used in the uniform block in the shader.
  25933. */
  25934. addMatrix3x3(name: string): void;
  25935. /**
  25936. * Adds a Matrix 2x2 to the uniform buffer.
  25937. * @param name Name of the uniform, as used in the uniform block in the shader.
  25938. */
  25939. addMatrix2x2(name: string): void;
  25940. /**
  25941. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25942. */
  25943. create(): void;
  25944. /** @hidden */
  25945. _rebuild(): void;
  25946. /**
  25947. * Updates the WebGL Uniform Buffer on the GPU.
  25948. * If the `dynamic` flag is set to true, no cache comparison is done.
  25949. * Otherwise, the buffer will be updated only if the cache differs.
  25950. */
  25951. update(): void;
  25952. /**
  25953. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25954. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25955. * @param data Define the flattened data
  25956. * @param size Define the size of the data.
  25957. */
  25958. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25959. private _updateMatrix3x3ForUniform;
  25960. private _updateMatrix3x3ForEffect;
  25961. private _updateMatrix2x2ForEffect;
  25962. private _updateMatrix2x2ForUniform;
  25963. private _updateFloatForEffect;
  25964. private _updateFloatForUniform;
  25965. private _updateFloat2ForEffect;
  25966. private _updateFloat2ForUniform;
  25967. private _updateFloat3ForEffect;
  25968. private _updateFloat3ForUniform;
  25969. private _updateFloat4ForEffect;
  25970. private _updateFloat4ForUniform;
  25971. private _updateMatrixForEffect;
  25972. private _updateMatrixForUniform;
  25973. private _updateVector3ForEffect;
  25974. private _updateVector3ForUniform;
  25975. private _updateVector4ForEffect;
  25976. private _updateVector4ForUniform;
  25977. private _updateColor3ForEffect;
  25978. private _updateColor3ForUniform;
  25979. private _updateColor4ForEffect;
  25980. private _updateColor4ForUniform;
  25981. /**
  25982. * Sets a sampler uniform on the effect.
  25983. * @param name Define the name of the sampler.
  25984. * @param texture Define the texture to set in the sampler
  25985. */
  25986. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25987. /**
  25988. * Directly updates the value of the uniform in the cache AND on the GPU.
  25989. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25990. * @param data Define the flattened data
  25991. */
  25992. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25993. /**
  25994. * Binds this uniform buffer to an effect.
  25995. * @param effect Define the effect to bind the buffer to
  25996. * @param name Name of the uniform block in the shader.
  25997. */
  25998. bindToEffect(effect: Effect, name: string): void;
  25999. /**
  26000. * Disposes the uniform buffer.
  26001. */
  26002. dispose(): void;
  26003. }
  26004. }
  26005. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26006. import { Nullable } from "babylonjs/types";
  26007. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26008. /**
  26009. * This represents the required contract to create a new type of texture loader.
  26010. */
  26011. export interface IInternalTextureLoader {
  26012. /**
  26013. * Defines wether the loader supports cascade loading the different faces.
  26014. */
  26015. supportCascades: boolean;
  26016. /**
  26017. * This returns if the loader support the current file information.
  26018. * @param extension defines the file extension of the file being loaded
  26019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26020. * @param fallback defines the fallback internal texture if any
  26021. * @param isBase64 defines whether the texture is encoded as a base64
  26022. * @param isBuffer defines whether the texture data are stored as a buffer
  26023. * @returns true if the loader can load the specified file
  26024. */
  26025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26026. /**
  26027. * Transform the url before loading if required.
  26028. * @param rootUrl the url of the texture
  26029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26030. * @returns the transformed texture
  26031. */
  26032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26033. /**
  26034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26035. * @param rootUrl the url of the texture
  26036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26037. * @returns the fallback texture
  26038. */
  26039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26040. /**
  26041. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26042. * @param data contains the texture data
  26043. * @param texture defines the BabylonJS internal texture
  26044. * @param createPolynomials will be true if polynomials have been requested
  26045. * @param onLoad defines the callback to trigger once the texture is ready
  26046. * @param onError defines the callback to trigger in case of error
  26047. */
  26048. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26049. /**
  26050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26051. * @param data contains the texture data
  26052. * @param texture defines the BabylonJS internal texture
  26053. * @param callback defines the method to call once ready to upload
  26054. */
  26055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26056. }
  26057. }
  26058. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26059. import { Scene } from "babylonjs/scene";
  26060. import { Engine } from "babylonjs/Engines/engine";
  26061. import { Texture } from "babylonjs/Materials/Textures/texture";
  26062. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26063. /**
  26064. * Creation options of the multi render target texture.
  26065. */
  26066. export interface IMultiRenderTargetOptions {
  26067. /**
  26068. * Define if the texture needs to create mip maps after render.
  26069. */
  26070. generateMipMaps?: boolean;
  26071. /**
  26072. * Define the types of all the draw buffers we want to create
  26073. */
  26074. types?: number[];
  26075. /**
  26076. * Define the sampling modes of all the draw buffers we want to create
  26077. */
  26078. samplingModes?: number[];
  26079. /**
  26080. * Define if a depth buffer is required
  26081. */
  26082. generateDepthBuffer?: boolean;
  26083. /**
  26084. * Define if a stencil buffer is required
  26085. */
  26086. generateStencilBuffer?: boolean;
  26087. /**
  26088. * Define if a depth texture is required instead of a depth buffer
  26089. */
  26090. generateDepthTexture?: boolean;
  26091. /**
  26092. * Define the number of desired draw buffers
  26093. */
  26094. textureCount?: number;
  26095. /**
  26096. * Define if aspect ratio should be adapted to the texture or stay the scene one
  26097. */
  26098. doNotChangeAspectRatio?: boolean;
  26099. /**
  26100. * Define the default type of the buffers we are creating
  26101. */
  26102. defaultType?: number;
  26103. }
  26104. /**
  26105. * A multi render target, like a render target provides the ability to render to a texture.
  26106. * Unlike the render target, it can render to several draw buffers in one draw.
  26107. * This is specially interesting in deferred rendering or for any effects requiring more than
  26108. * just one color from a single pass.
  26109. */
  26110. export class MultiRenderTarget extends RenderTargetTexture {
  26111. private _internalTextures;
  26112. private _textures;
  26113. private _multiRenderTargetOptions;
  26114. /**
  26115. * Get if draw buffers are currently supported by the used hardware and browser.
  26116. */
  26117. readonly isSupported: boolean;
  26118. /**
  26119. * Get the list of textures generated by the multi render target.
  26120. */
  26121. readonly textures: Texture[];
  26122. /**
  26123. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  26124. */
  26125. readonly depthTexture: Texture;
  26126. /**
  26127. * Set the wrapping mode on U of all the textures we are rendering to.
  26128. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26129. */
  26130. wrapU: number;
  26131. /**
  26132. * Set the wrapping mode on V of all the textures we are rendering to.
  26133. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  26134. */
  26135. wrapV: number;
  26136. /**
  26137. * Instantiate a new multi render target texture.
  26138. * A multi render target, like a render target provides the ability to render to a texture.
  26139. * Unlike the render target, it can render to several draw buffers in one draw.
  26140. * This is specially interesting in deferred rendering or for any effects requiring more than
  26141. * just one color from a single pass.
  26142. * @param name Define the name of the texture
  26143. * @param size Define the size of the buffers to render to
  26144. * @param count Define the number of target we are rendering into
  26145. * @param scene Define the scene the texture belongs to
  26146. * @param options Define the options used to create the multi render target
  26147. */
  26148. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  26149. /** @hidden */
  26150. _rebuild(): void;
  26151. private _createInternalTextures;
  26152. private _createTextures;
  26153. /**
  26154. * Define the number of samples used if MSAA is enabled.
  26155. */
  26156. samples: number;
  26157. /**
  26158. * Resize all the textures in the multi render target.
  26159. * Be carrefull as it will recreate all the data in the new texture.
  26160. * @param size Define the new size
  26161. */
  26162. resize(size: any): void;
  26163. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  26164. /**
  26165. * Dispose the render targets and their associated resources
  26166. */
  26167. dispose(): void;
  26168. /**
  26169. * Release all the underlying texture used as draw buffers.
  26170. */
  26171. releaseInternalTextures(): void;
  26172. }
  26173. }
  26174. declare module "babylonjs/Audio/analyser" {
  26175. import { Scene } from "babylonjs/scene";
  26176. /**
  26177. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26179. */
  26180. export class Analyser {
  26181. /**
  26182. * Gets or sets the smoothing
  26183. * @ignorenaming
  26184. */
  26185. SMOOTHING: number;
  26186. /**
  26187. * Gets or sets the FFT table size
  26188. * @ignorenaming
  26189. */
  26190. FFT_SIZE: number;
  26191. /**
  26192. * Gets or sets the bar graph amplitude
  26193. * @ignorenaming
  26194. */
  26195. BARGRAPHAMPLITUDE: number;
  26196. /**
  26197. * Gets or sets the position of the debug canvas
  26198. * @ignorenaming
  26199. */
  26200. DEBUGCANVASPOS: {
  26201. x: number;
  26202. y: number;
  26203. };
  26204. /**
  26205. * Gets or sets the debug canvas size
  26206. * @ignorenaming
  26207. */
  26208. DEBUGCANVASSIZE: {
  26209. width: number;
  26210. height: number;
  26211. };
  26212. private _byteFreqs;
  26213. private _byteTime;
  26214. private _floatFreqs;
  26215. private _webAudioAnalyser;
  26216. private _debugCanvas;
  26217. private _debugCanvasContext;
  26218. private _scene;
  26219. private _registerFunc;
  26220. private _audioEngine;
  26221. /**
  26222. * Creates a new analyser
  26223. * @param scene defines hosting scene
  26224. */
  26225. constructor(scene: Scene);
  26226. /**
  26227. * Get the number of data values you will have to play with for the visualization
  26228. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26229. * @returns a number
  26230. */
  26231. getFrequencyBinCount(): number;
  26232. /**
  26233. * Gets the current frequency data as a byte array
  26234. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26235. * @returns a Uint8Array
  26236. */
  26237. getByteFrequencyData(): Uint8Array;
  26238. /**
  26239. * Gets the current waveform as a byte array
  26240. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26241. * @returns a Uint8Array
  26242. */
  26243. getByteTimeDomainData(): Uint8Array;
  26244. /**
  26245. * Gets the current frequency data as a float array
  26246. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26247. * @returns a Float32Array
  26248. */
  26249. getFloatFrequencyData(): Float32Array;
  26250. /**
  26251. * Renders the debug canvas
  26252. */
  26253. drawDebugCanvas(): void;
  26254. /**
  26255. * Stops rendering the debug canvas and removes it
  26256. */
  26257. stopDebugCanvas(): void;
  26258. /**
  26259. * Connects two audio nodes
  26260. * @param inputAudioNode defines first node to connect
  26261. * @param outputAudioNode defines second node to connect
  26262. */
  26263. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26264. /**
  26265. * Releases all associated resources
  26266. */
  26267. dispose(): void;
  26268. }
  26269. }
  26270. declare module "babylonjs/Audio/audioEngine" {
  26271. import { IDisposable } from "babylonjs/scene";
  26272. import { Analyser } from "babylonjs/Audio/analyser";
  26273. import { Nullable } from "babylonjs/types";
  26274. import { Observable } from "babylonjs/Misc/observable";
  26275. /**
  26276. * This represents an audio engine and it is responsible
  26277. * to play, synchronize and analyse sounds throughout the application.
  26278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26279. */
  26280. export interface IAudioEngine extends IDisposable {
  26281. /**
  26282. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26283. */
  26284. readonly canUseWebAudio: boolean;
  26285. /**
  26286. * Gets the current AudioContext if available.
  26287. */
  26288. readonly audioContext: Nullable<AudioContext>;
  26289. /**
  26290. * The master gain node defines the global audio volume of your audio engine.
  26291. */
  26292. readonly masterGain: GainNode;
  26293. /**
  26294. * Gets whether or not mp3 are supported by your browser.
  26295. */
  26296. readonly isMP3supported: boolean;
  26297. /**
  26298. * Gets whether or not ogg are supported by your browser.
  26299. */
  26300. readonly isOGGsupported: boolean;
  26301. /**
  26302. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26303. * @ignoreNaming
  26304. */
  26305. WarnedWebAudioUnsupported: boolean;
  26306. /**
  26307. * Defines if the audio engine relies on a custom unlocked button.
  26308. * In this case, the embedded button will not be displayed.
  26309. */
  26310. useCustomUnlockedButton: boolean;
  26311. /**
  26312. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26313. */
  26314. readonly unlocked: boolean;
  26315. /**
  26316. * Event raised when audio has been unlocked on the browser.
  26317. */
  26318. onAudioUnlockedObservable: Observable<AudioEngine>;
  26319. /**
  26320. * Event raised when audio has been locked on the browser.
  26321. */
  26322. onAudioLockedObservable: Observable<AudioEngine>;
  26323. /**
  26324. * Flags the audio engine in Locked state.
  26325. * This happens due to new browser policies preventing audio to autoplay.
  26326. */
  26327. lock(): void;
  26328. /**
  26329. * Unlocks the audio engine once a user action has been done on the dom.
  26330. * This is helpful to resume play once browser policies have been satisfied.
  26331. */
  26332. unlock(): void;
  26333. }
  26334. /**
  26335. * This represents the default audio engine used in babylon.
  26336. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26338. */
  26339. export class AudioEngine implements IAudioEngine {
  26340. private _audioContext;
  26341. private _audioContextInitialized;
  26342. private _muteButton;
  26343. private _hostElement;
  26344. /**
  26345. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26346. */
  26347. canUseWebAudio: boolean;
  26348. /**
  26349. * The master gain node defines the global audio volume of your audio engine.
  26350. */
  26351. masterGain: GainNode;
  26352. /**
  26353. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26354. * @ignoreNaming
  26355. */
  26356. WarnedWebAudioUnsupported: boolean;
  26357. /**
  26358. * Gets whether or not mp3 are supported by your browser.
  26359. */
  26360. isMP3supported: boolean;
  26361. /**
  26362. * Gets whether or not ogg are supported by your browser.
  26363. */
  26364. isOGGsupported: boolean;
  26365. /**
  26366. * Gets whether audio has been unlocked on the device.
  26367. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26368. * a user interaction has happened.
  26369. */
  26370. unlocked: boolean;
  26371. /**
  26372. * Defines if the audio engine relies on a custom unlocked button.
  26373. * In this case, the embedded button will not be displayed.
  26374. */
  26375. useCustomUnlockedButton: boolean;
  26376. /**
  26377. * Event raised when audio has been unlocked on the browser.
  26378. */
  26379. onAudioUnlockedObservable: Observable<AudioEngine>;
  26380. /**
  26381. * Event raised when audio has been locked on the browser.
  26382. */
  26383. onAudioLockedObservable: Observable<AudioEngine>;
  26384. /**
  26385. * Gets the current AudioContext if available.
  26386. */
  26387. readonly audioContext: Nullable<AudioContext>;
  26388. private _connectedAnalyser;
  26389. /**
  26390. * Instantiates a new audio engine.
  26391. *
  26392. * There should be only one per page as some browsers restrict the number
  26393. * of audio contexts you can create.
  26394. * @param hostElement defines the host element where to display the mute icon if necessary
  26395. */
  26396. constructor(hostElement?: Nullable<HTMLElement>);
  26397. /**
  26398. * Flags the audio engine in Locked state.
  26399. * This happens due to new browser policies preventing audio to autoplay.
  26400. */
  26401. lock(): void;
  26402. /**
  26403. * Unlocks the audio engine once a user action has been done on the dom.
  26404. * This is helpful to resume play once browser policies have been satisfied.
  26405. */
  26406. unlock(): void;
  26407. private _resumeAudioContext;
  26408. private _initializeAudioContext;
  26409. private _tryToRun;
  26410. private _triggerRunningState;
  26411. private _triggerSuspendedState;
  26412. private _displayMuteButton;
  26413. private _moveButtonToTopLeft;
  26414. private _onResize;
  26415. private _hideMuteButton;
  26416. /**
  26417. * Destroy and release the resources associated with the audio ccontext.
  26418. */
  26419. dispose(): void;
  26420. /**
  26421. * Gets the global volume sets on the master gain.
  26422. * @returns the global volume if set or -1 otherwise
  26423. */
  26424. getGlobalVolume(): number;
  26425. /**
  26426. * Sets the global volume of your experience (sets on the master gain).
  26427. * @param newVolume Defines the new global volume of the application
  26428. */
  26429. setGlobalVolume(newVolume: number): void;
  26430. /**
  26431. * Connect the audio engine to an audio analyser allowing some amazing
  26432. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26434. * @param analyser The analyser to connect to the engine
  26435. */
  26436. connectToAnalyser(analyser: Analyser): void;
  26437. }
  26438. }
  26439. declare module "babylonjs/Loading/loadingScreen" {
  26440. /**
  26441. * Interface used to present a loading screen while loading a scene
  26442. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26443. */
  26444. export interface ILoadingScreen {
  26445. /**
  26446. * Function called to display the loading screen
  26447. */
  26448. displayLoadingUI: () => void;
  26449. /**
  26450. * Function called to hide the loading screen
  26451. */
  26452. hideLoadingUI: () => void;
  26453. /**
  26454. * Gets or sets the color to use for the background
  26455. */
  26456. loadingUIBackgroundColor: string;
  26457. /**
  26458. * Gets or sets the text to display while loading
  26459. */
  26460. loadingUIText: string;
  26461. }
  26462. /**
  26463. * Class used for the default loading screen
  26464. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26465. */
  26466. export class DefaultLoadingScreen implements ILoadingScreen {
  26467. private _renderingCanvas;
  26468. private _loadingText;
  26469. private _loadingDivBackgroundColor;
  26470. private _loadingDiv;
  26471. private _loadingTextDiv;
  26472. /**
  26473. * Creates a new default loading screen
  26474. * @param _renderingCanvas defines the canvas used to render the scene
  26475. * @param _loadingText defines the default text to display
  26476. * @param _loadingDivBackgroundColor defines the default background color
  26477. */
  26478. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26479. /**
  26480. * Function called to display the loading screen
  26481. */
  26482. displayLoadingUI(): void;
  26483. /**
  26484. * Function called to hide the loading screen
  26485. */
  26486. hideLoadingUI(): void;
  26487. /**
  26488. * Gets or sets the text to display while loading
  26489. */
  26490. loadingUIText: string;
  26491. /**
  26492. * Gets or sets the color to use for the background
  26493. */
  26494. loadingUIBackgroundColor: string;
  26495. private _resizeLoadingUI;
  26496. }
  26497. }
  26498. declare module "babylonjs/Materials/Textures/videoTexture" {
  26499. import { Observable } from "babylonjs/Misc/observable";
  26500. import { Nullable } from "babylonjs/types";
  26501. import { Scene } from "babylonjs/scene";
  26502. import { Texture } from "babylonjs/Materials/Textures/texture";
  26503. /**
  26504. * Settings for finer control over video usage
  26505. */
  26506. export interface VideoTextureSettings {
  26507. /**
  26508. * Applies `autoplay` to video, if specified
  26509. */
  26510. autoPlay?: boolean;
  26511. /**
  26512. * Applies `loop` to video, if specified
  26513. */
  26514. loop?: boolean;
  26515. /**
  26516. * Automatically updates internal texture from video at every frame in the render loop
  26517. */
  26518. autoUpdateTexture: boolean;
  26519. /**
  26520. * Image src displayed during the video loading or until the user interacts with the video.
  26521. */
  26522. poster?: string;
  26523. }
  26524. /**
  26525. * If you want to display a video in your scene, this is the special texture for that.
  26526. * This special texture works similar to other textures, with the exception of a few parameters.
  26527. * @see https://doc.babylonjs.com/how_to/video_texture
  26528. */
  26529. export class VideoTexture extends Texture {
  26530. /**
  26531. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26532. */
  26533. readonly autoUpdateTexture: boolean;
  26534. /**
  26535. * The video instance used by the texture internally
  26536. */
  26537. readonly video: HTMLVideoElement;
  26538. private _onUserActionRequestedObservable;
  26539. /**
  26540. * Event triggerd when a dom action is required by the user to play the video.
  26541. * This happens due to recent changes in browser policies preventing video to auto start.
  26542. */
  26543. readonly onUserActionRequestedObservable: Observable<Texture>;
  26544. private _generateMipMaps;
  26545. private _engine;
  26546. private _stillImageCaptured;
  26547. private _displayingPosterTexture;
  26548. private _settings;
  26549. private _createInternalTextureOnEvent;
  26550. /**
  26551. * Creates a video texture.
  26552. * If you want to display a video in your scene, this is the special texture for that.
  26553. * This special texture works similar to other textures, with the exception of a few parameters.
  26554. * @see https://doc.babylonjs.com/how_to/video_texture
  26555. * @param name optional name, will detect from video source, if not defined
  26556. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26557. * @param scene is obviously the current scene.
  26558. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26559. * @param invertY is false by default but can be used to invert video on Y axis
  26560. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26561. * @param settings allows finer control over video usage
  26562. */
  26563. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26564. private _getName;
  26565. private _getVideo;
  26566. private _createInternalTexture;
  26567. private reset;
  26568. /**
  26569. * @hidden Internal method to initiate `update`.
  26570. */
  26571. _rebuild(): void;
  26572. /**
  26573. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26574. */
  26575. update(): void;
  26576. /**
  26577. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26578. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26579. */
  26580. updateTexture(isVisible: boolean): void;
  26581. protected _updateInternalTexture: () => void;
  26582. /**
  26583. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26584. * @param url New url.
  26585. */
  26586. updateURL(url: string): void;
  26587. /**
  26588. * Dispose the texture and release its associated resources.
  26589. */
  26590. dispose(): void;
  26591. /**
  26592. * Creates a video texture straight from your WebCam video feed.
  26593. * @param scene Define the scene the texture should be created in
  26594. * @param onReady Define a callback to triggered once the texture will be ready
  26595. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26596. */
  26597. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26598. minWidth: number;
  26599. maxWidth: number;
  26600. minHeight: number;
  26601. maxHeight: number;
  26602. deviceId: string;
  26603. }): void;
  26604. }
  26605. }
  26606. declare module "babylonjs/Engines/engine" {
  26607. import { Observable } from "babylonjs/Misc/observable";
  26608. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  26609. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  26610. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26611. import { Camera } from "babylonjs/Cameras/camera";
  26612. import { Scene } from "babylonjs/scene";
  26613. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  26614. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  26615. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26616. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26617. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  26618. import { Material } from "babylonjs/Materials/material";
  26619. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  26620. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26621. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26622. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  26623. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  26624. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  26625. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  26626. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  26627. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  26628. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26630. /**
  26631. * Interface for attribute information associated with buffer instanciation
  26632. */
  26633. export class InstancingAttributeInfo {
  26634. /**
  26635. * Index/offset of the attribute in the vertex shader
  26636. */
  26637. index: number;
  26638. /**
  26639. * size of the attribute, 1, 2, 3 or 4
  26640. */
  26641. attributeSize: number;
  26642. /**
  26643. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26644. * default is FLOAT
  26645. */
  26646. attribyteType: number;
  26647. /**
  26648. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26649. */
  26650. normalized: boolean;
  26651. /**
  26652. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26653. */
  26654. offset: number;
  26655. /**
  26656. * Name of the GLSL attribute, for debugging purpose only
  26657. */
  26658. attributeName: string;
  26659. }
  26660. /**
  26661. * Define options used to create a depth texture
  26662. */
  26663. export class DepthTextureCreationOptions {
  26664. /** Specifies whether or not a stencil should be allocated in the texture */
  26665. generateStencil?: boolean;
  26666. /** Specifies whether or not bilinear filtering is enable on the texture */
  26667. bilinearFiltering?: boolean;
  26668. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26669. comparisonFunction?: number;
  26670. /** Specifies if the created texture is a cube texture */
  26671. isCube?: boolean;
  26672. }
  26673. /**
  26674. * Class used to describe the capabilities of the engine relatively to the current browser
  26675. */
  26676. export class EngineCapabilities {
  26677. /** Maximum textures units per fragment shader */
  26678. maxTexturesImageUnits: number;
  26679. /** Maximum texture units per vertex shader */
  26680. maxVertexTextureImageUnits: number;
  26681. /** Maximum textures units in the entire pipeline */
  26682. maxCombinedTexturesImageUnits: number;
  26683. /** Maximum texture size */
  26684. maxTextureSize: number;
  26685. /** Maximum cube texture size */
  26686. maxCubemapTextureSize: number;
  26687. /** Maximum render texture size */
  26688. maxRenderTextureSize: number;
  26689. /** Maximum number of vertex attributes */
  26690. maxVertexAttribs: number;
  26691. /** Maximum number of varyings */
  26692. maxVaryingVectors: number;
  26693. /** Maximum number of uniforms per vertex shader */
  26694. maxVertexUniformVectors: number;
  26695. /** Maximum number of uniforms per fragment shader */
  26696. maxFragmentUniformVectors: number;
  26697. /** Defines if standard derivates (dx/dy) are supported */
  26698. standardDerivatives: boolean;
  26699. /** Defines if s3tc texture compression is supported */
  26700. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26701. /** Defines if pvrtc texture compression is supported */
  26702. pvrtc: any;
  26703. /** Defines if etc1 texture compression is supported */
  26704. etc1: any;
  26705. /** Defines if etc2 texture compression is supported */
  26706. etc2: any;
  26707. /** Defines if astc texture compression is supported */
  26708. astc: any;
  26709. /** Defines if float textures are supported */
  26710. textureFloat: boolean;
  26711. /** Defines if vertex array objects are supported */
  26712. vertexArrayObject: boolean;
  26713. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26714. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26715. /** Gets the maximum level of anisotropy supported */
  26716. maxAnisotropy: number;
  26717. /** Defines if instancing is supported */
  26718. instancedArrays: boolean;
  26719. /** Defines if 32 bits indices are supported */
  26720. uintIndices: boolean;
  26721. /** Defines if high precision shaders are supported */
  26722. highPrecisionShaderSupported: boolean;
  26723. /** Defines if depth reading in the fragment shader is supported */
  26724. fragmentDepthSupported: boolean;
  26725. /** Defines if float texture linear filtering is supported*/
  26726. textureFloatLinearFiltering: boolean;
  26727. /** Defines if rendering to float textures is supported */
  26728. textureFloatRender: boolean;
  26729. /** Defines if half float textures are supported*/
  26730. textureHalfFloat: boolean;
  26731. /** Defines if half float texture linear filtering is supported*/
  26732. textureHalfFloatLinearFiltering: boolean;
  26733. /** Defines if rendering to half float textures is supported */
  26734. textureHalfFloatRender: boolean;
  26735. /** Defines if textureLOD shader command is supported */
  26736. textureLOD: boolean;
  26737. /** Defines if draw buffers extension is supported */
  26738. drawBuffersExtension: boolean;
  26739. /** Defines if depth textures are supported */
  26740. depthTextureExtension: boolean;
  26741. /** Defines if float color buffer are supported */
  26742. colorBufferFloat: boolean;
  26743. /** Gets disjoint timer query extension (null if not supported) */
  26744. timerQuery: EXT_disjoint_timer_query;
  26745. /** Defines if timestamp can be used with timer query */
  26746. canUseTimestampForTimerQuery: boolean;
  26747. /** Function used to let the system compiles shaders in background */
  26748. parallelShaderCompile: {
  26749. MAX_SHADER_COMPILER_THREADS_KHR: number;
  26750. maxShaderCompilerThreadsKHR: (thread: number) => void;
  26751. COMPLETION_STATUS_KHR: number;
  26752. };
  26753. }
  26754. /** Interface defining initialization parameters for Engine class */
  26755. export interface EngineOptions extends WebGLContextAttributes {
  26756. /**
  26757. * Defines if the engine should no exceed a specified device ratio
  26758. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26759. */
  26760. limitDeviceRatio?: number;
  26761. /**
  26762. * Defines if webvr should be enabled automatically
  26763. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26764. */
  26765. autoEnableWebVR?: boolean;
  26766. /**
  26767. * Defines if webgl2 should be turned off even if supported
  26768. * @see http://doc.babylonjs.com/features/webgl2
  26769. */
  26770. disableWebGL2Support?: boolean;
  26771. /**
  26772. * Defines if webaudio should be initialized as well
  26773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26774. */
  26775. audioEngine?: boolean;
  26776. /**
  26777. * Defines if animations should run using a deterministic lock step
  26778. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26779. */
  26780. deterministicLockstep?: boolean;
  26781. /** Defines the maximum steps to use with deterministic lock step mode */
  26782. lockstepMaxSteps?: number;
  26783. /**
  26784. * Defines that engine should ignore context lost events
  26785. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26786. */
  26787. doNotHandleContextLost?: boolean;
  26788. /**
  26789. * Defines that engine should ignore modifying touch action attribute and style
  26790. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26791. */
  26792. doNotHandleTouchAction?: boolean;
  26793. }
  26794. /**
  26795. * Defines the interface used by display changed events
  26796. */
  26797. export interface IDisplayChangedEventArgs {
  26798. /** Gets the vrDisplay object (if any) */
  26799. vrDisplay: Nullable<any>;
  26800. /** Gets a boolean indicating if webVR is supported */
  26801. vrSupported: boolean;
  26802. }
  26803. /**
  26804. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26805. */
  26806. export class Engine {
  26807. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26808. static ExceptionList: ({
  26809. key: string;
  26810. capture: string;
  26811. captureConstraint: number;
  26812. targets: string[];
  26813. } | {
  26814. key: string;
  26815. capture: null;
  26816. captureConstraint: null;
  26817. targets: string[];
  26818. })[];
  26819. /** Gets the list of created engines */
  26820. static readonly Instances: Engine[];
  26821. /**
  26822. * Gets the latest created engine
  26823. */
  26824. static readonly LastCreatedEngine: Nullable<Engine>;
  26825. /**
  26826. * Gets the latest created scene
  26827. */
  26828. static readonly LastCreatedScene: Nullable<Scene>;
  26829. /**
  26830. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26831. * @param flag defines which part of the materials must be marked as dirty
  26832. * @param predicate defines a predicate used to filter which materials should be affected
  26833. */
  26834. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26835. /**
  26836. * Hidden
  26837. */
  26838. static _TextureLoaders: IInternalTextureLoader[];
  26839. /** Defines that alpha blending is disabled */
  26840. static readonly ALPHA_DISABLE: number;
  26841. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26842. static readonly ALPHA_ADD: number;
  26843. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26844. static readonly ALPHA_COMBINE: number;
  26845. /** Defines that alpha blending to DEST - SRC * DEST */
  26846. static readonly ALPHA_SUBTRACT: number;
  26847. /** Defines that alpha blending to SRC * DEST */
  26848. static readonly ALPHA_MULTIPLY: number;
  26849. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26850. static readonly ALPHA_MAXIMIZED: number;
  26851. /** Defines that alpha blending to SRC + DEST */
  26852. static readonly ALPHA_ONEONE: number;
  26853. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26854. static readonly ALPHA_PREMULTIPLIED: number;
  26855. /**
  26856. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26857. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26858. */
  26859. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26860. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26861. static readonly ALPHA_INTERPOLATE: number;
  26862. /**
  26863. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26864. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26865. */
  26866. static readonly ALPHA_SCREENMODE: number;
  26867. /** Defines that the ressource is not delayed*/
  26868. static readonly DELAYLOADSTATE_NONE: number;
  26869. /** Defines that the ressource was successfully delay loaded */
  26870. static readonly DELAYLOADSTATE_LOADED: number;
  26871. /** Defines that the ressource is currently delay loading */
  26872. static readonly DELAYLOADSTATE_LOADING: number;
  26873. /** Defines that the ressource is delayed and has not started loading */
  26874. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26875. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26876. static readonly NEVER: number;
  26877. /** 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 */
  26878. static readonly ALWAYS: number;
  26879. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26880. static readonly LESS: number;
  26881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26882. static readonly EQUAL: number;
  26883. /** 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 */
  26884. static readonly LEQUAL: number;
  26885. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26886. static readonly GREATER: number;
  26887. /** 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 */
  26888. static readonly GEQUAL: number;
  26889. /** 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 */
  26890. static readonly NOTEQUAL: number;
  26891. /** Passed to stencilOperation to specify that stencil value must be kept */
  26892. static readonly KEEP: number;
  26893. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26894. static readonly REPLACE: number;
  26895. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26896. static readonly INCR: number;
  26897. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26898. static readonly DECR: number;
  26899. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26900. static readonly INVERT: number;
  26901. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26902. static readonly INCR_WRAP: number;
  26903. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26904. static readonly DECR_WRAP: number;
  26905. /** Texture is not repeating outside of 0..1 UVs */
  26906. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26907. /** Texture is repeating outside of 0..1 UVs */
  26908. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26909. /** Texture is repeating and mirrored */
  26910. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26911. /** ALPHA */
  26912. static readonly TEXTUREFORMAT_ALPHA: number;
  26913. /** LUMINANCE */
  26914. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26915. /** LUMINANCE_ALPHA */
  26916. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26917. /** RGB */
  26918. static readonly TEXTUREFORMAT_RGB: number;
  26919. /** RGBA */
  26920. static readonly TEXTUREFORMAT_RGBA: number;
  26921. /** RED */
  26922. static readonly TEXTUREFORMAT_RED: number;
  26923. /** RED (2nd reference) */
  26924. static readonly TEXTUREFORMAT_R: number;
  26925. /** RG */
  26926. static readonly TEXTUREFORMAT_RG: number;
  26927. /** RED_INTEGER */
  26928. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26929. /** RED_INTEGER (2nd reference) */
  26930. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26931. /** RG_INTEGER */
  26932. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26933. /** RGB_INTEGER */
  26934. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26935. /** RGBA_INTEGER */
  26936. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26937. /** UNSIGNED_BYTE */
  26938. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26939. /** UNSIGNED_BYTE (2nd reference) */
  26940. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26941. /** FLOAT */
  26942. static readonly TEXTURETYPE_FLOAT: number;
  26943. /** HALF_FLOAT */
  26944. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26945. /** BYTE */
  26946. static readonly TEXTURETYPE_BYTE: number;
  26947. /** SHORT */
  26948. static readonly TEXTURETYPE_SHORT: number;
  26949. /** UNSIGNED_SHORT */
  26950. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26951. /** INT */
  26952. static readonly TEXTURETYPE_INT: number;
  26953. /** UNSIGNED_INT */
  26954. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26955. /** UNSIGNED_SHORT_4_4_4_4 */
  26956. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26957. /** UNSIGNED_SHORT_5_5_5_1 */
  26958. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26959. /** UNSIGNED_SHORT_5_6_5 */
  26960. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26961. /** UNSIGNED_INT_2_10_10_10_REV */
  26962. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26963. /** UNSIGNED_INT_24_8 */
  26964. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26965. /** UNSIGNED_INT_10F_11F_11F_REV */
  26966. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26967. /** UNSIGNED_INT_5_9_9_9_REV */
  26968. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26969. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26970. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26971. /** nearest is mag = nearest and min = nearest and mip = linear */
  26972. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26973. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26974. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26975. /** Trilinear is mag = linear and min = linear and mip = linear */
  26976. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26977. /** nearest is mag = nearest and min = nearest and mip = linear */
  26978. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26979. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26980. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26981. /** Trilinear is mag = linear and min = linear and mip = linear */
  26982. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26983. /** mag = nearest and min = nearest and mip = nearest */
  26984. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26985. /** mag = nearest and min = linear and mip = nearest */
  26986. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26987. /** mag = nearest and min = linear and mip = linear */
  26988. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26989. /** mag = nearest and min = linear and mip = none */
  26990. static readonly TEXTURE_NEAREST_LINEAR: number;
  26991. /** mag = nearest and min = nearest and mip = none */
  26992. static readonly TEXTURE_NEAREST_NEAREST: number;
  26993. /** mag = linear and min = nearest and mip = nearest */
  26994. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26995. /** mag = linear and min = nearest and mip = linear */
  26996. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26997. /** mag = linear and min = linear and mip = none */
  26998. static readonly TEXTURE_LINEAR_LINEAR: number;
  26999. /** mag = linear and min = nearest and mip = none */
  27000. static readonly TEXTURE_LINEAR_NEAREST: number;
  27001. /** Explicit coordinates mode */
  27002. static readonly TEXTURE_EXPLICIT_MODE: number;
  27003. /** Spherical coordinates mode */
  27004. static readonly TEXTURE_SPHERICAL_MODE: number;
  27005. /** Planar coordinates mode */
  27006. static readonly TEXTURE_PLANAR_MODE: number;
  27007. /** Cubic coordinates mode */
  27008. static readonly TEXTURE_CUBIC_MODE: number;
  27009. /** Projection coordinates mode */
  27010. static readonly TEXTURE_PROJECTION_MODE: number;
  27011. /** Skybox coordinates mode */
  27012. static readonly TEXTURE_SKYBOX_MODE: number;
  27013. /** Inverse Cubic coordinates mode */
  27014. static readonly TEXTURE_INVCUBIC_MODE: number;
  27015. /** Equirectangular coordinates mode */
  27016. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27017. /** Equirectangular Fixed coordinates mode */
  27018. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27019. /** Equirectangular Fixed Mirrored coordinates mode */
  27020. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27021. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27022. static readonly SCALEMODE_FLOOR: number;
  27023. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27024. static readonly SCALEMODE_NEAREST: number;
  27025. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27026. static readonly SCALEMODE_CEILING: number;
  27027. /**
  27028. * Returns the current version of the framework
  27029. */
  27030. static readonly Version: string;
  27031. /**
  27032. * Returns a string describing the current engine
  27033. */
  27034. readonly description: string;
  27035. /**
  27036. * Gets or sets the epsilon value used by collision engine
  27037. */
  27038. static CollisionsEpsilon: number;
  27039. /**
  27040. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27041. */
  27042. static ShadersRepository: string;
  27043. /**
  27044. * Method called to create the default loading screen.
  27045. * This can be overriden in your own app.
  27046. * @param canvas The rendering canvas element
  27047. * @returns The loading screen
  27048. */
  27049. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  27050. /**
  27051. * Method called to create the default rescale post process on each engine.
  27052. */
  27053. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  27054. /**
  27055. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27056. */
  27057. forcePOTTextures: boolean;
  27058. /**
  27059. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27060. */
  27061. isFullscreen: boolean;
  27062. /**
  27063. * Gets a boolean indicating if the pointer is currently locked
  27064. */
  27065. isPointerLock: boolean;
  27066. /**
  27067. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27068. */
  27069. cullBackFaces: boolean;
  27070. /**
  27071. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27072. */
  27073. renderEvenInBackground: boolean;
  27074. /**
  27075. * Gets or sets a boolean indicating that cache can be kept between frames
  27076. */
  27077. preventCacheWipeBetweenFrames: boolean;
  27078. /**
  27079. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27080. **/
  27081. enableOfflineSupport: boolean;
  27082. /**
  27083. * 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)
  27084. **/
  27085. disableManifestCheck: boolean;
  27086. /**
  27087. * Gets the list of created scenes
  27088. */
  27089. scenes: Scene[];
  27090. /**
  27091. * Event raised when a new scene is created
  27092. */
  27093. onNewSceneAddedObservable: Observable<Scene>;
  27094. /**
  27095. * Gets the list of created postprocesses
  27096. */
  27097. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  27098. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27099. validateShaderPrograms: boolean;
  27100. /**
  27101. * Observable event triggered each time the rendering canvas is resized
  27102. */
  27103. onResizeObservable: Observable<Engine>;
  27104. /**
  27105. * Observable event triggered each time the canvas loses focus
  27106. */
  27107. onCanvasBlurObservable: Observable<Engine>;
  27108. /**
  27109. * Observable event triggered each time the canvas gains focus
  27110. */
  27111. onCanvasFocusObservable: Observable<Engine>;
  27112. /**
  27113. * Observable event triggered each time the canvas receives pointerout event
  27114. */
  27115. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27116. /**
  27117. * Observable event triggered before each texture is initialized
  27118. */
  27119. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  27120. private _vrDisplay;
  27121. private _vrSupported;
  27122. private _oldSize;
  27123. private _oldHardwareScaleFactor;
  27124. private _vrExclusivePointerMode;
  27125. private _webVRInitPromise;
  27126. /**
  27127. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27128. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27129. */
  27130. readonly isInVRExclusivePointerMode: boolean;
  27131. /**
  27132. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27133. */
  27134. disableUniformBuffers: boolean;
  27135. /** @hidden */
  27136. _uniformBuffers: UniformBuffer[];
  27137. /**
  27138. * Gets a boolean indicating that the engine supports uniform buffers
  27139. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27140. */
  27141. readonly supportsUniformBuffers: boolean;
  27142. /**
  27143. * Observable raised when the engine begins a new frame
  27144. */
  27145. onBeginFrameObservable: Observable<Engine>;
  27146. /**
  27147. * If set, will be used to request the next animation frame for the render loop
  27148. */
  27149. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27150. /**
  27151. * Observable raised when the engine ends the current frame
  27152. */
  27153. onEndFrameObservable: Observable<Engine>;
  27154. /**
  27155. * Observable raised when the engine is about to compile a shader
  27156. */
  27157. onBeforeShaderCompilationObservable: Observable<Engine>;
  27158. /**
  27159. * Observable raised when the engine has jsut compiled a shader
  27160. */
  27161. onAfterShaderCompilationObservable: Observable<Engine>;
  27162. /** @hidden */
  27163. _gl: WebGLRenderingContext;
  27164. private _renderingCanvas;
  27165. private _windowIsBackground;
  27166. private _webGLVersion;
  27167. /**
  27168. * Gets a boolean indicating that only power of 2 textures are supported
  27169. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27170. */
  27171. readonly needPOTTextures: boolean;
  27172. /** @hidden */
  27173. _badOS: boolean;
  27174. /** @hidden */
  27175. _badDesktopOS: boolean;
  27176. /**
  27177. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27178. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27179. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27180. */
  27181. disableTextureBindingOptimization: boolean;
  27182. /**
  27183. * Gets the audio engine
  27184. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27185. * @ignorenaming
  27186. */
  27187. static audioEngine: IAudioEngine;
  27188. /**
  27189. * Default AudioEngine factory responsible of creating the Audio Engine.
  27190. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27191. */
  27192. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27193. /**
  27194. * Default offline support factory responsible of creating a tool used to store data locally.
  27195. * By default, this will create a Database object if the workload has been embedded.
  27196. */
  27197. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27198. private _onFocus;
  27199. private _onBlur;
  27200. private _onCanvasPointerOut;
  27201. private _onCanvasBlur;
  27202. private _onCanvasFocus;
  27203. private _onFullscreenChange;
  27204. private _onPointerLockChange;
  27205. private _onVRDisplayPointerRestricted;
  27206. private _onVRDisplayPointerUnrestricted;
  27207. private _onVrDisplayConnect;
  27208. private _onVrDisplayDisconnect;
  27209. private _onVrDisplayPresentChange;
  27210. /**
  27211. * Observable signaled when VR display mode changes
  27212. */
  27213. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27214. /**
  27215. * Observable signaled when VR request present is complete
  27216. */
  27217. onVRRequestPresentComplete: Observable<boolean>;
  27218. /**
  27219. * Observable signaled when VR request present starts
  27220. */
  27221. onVRRequestPresentStart: Observable<Engine>;
  27222. private _hardwareScalingLevel;
  27223. /** @hidden */
  27224. protected _caps: EngineCapabilities;
  27225. private _pointerLockRequested;
  27226. private _isStencilEnable;
  27227. private _colorWrite;
  27228. private _loadingScreen;
  27229. /** @hidden */
  27230. _drawCalls: PerfCounter;
  27231. /** @hidden */
  27232. _textureCollisions: PerfCounter;
  27233. private _glVersion;
  27234. private _glRenderer;
  27235. private _glVendor;
  27236. private _videoTextureSupported;
  27237. private _renderingQueueLaunched;
  27238. private _activeRenderLoops;
  27239. private _deterministicLockstep;
  27240. private _lockstepMaxSteps;
  27241. /**
  27242. * Observable signaled when a context lost event is raised
  27243. */
  27244. onContextLostObservable: Observable<Engine>;
  27245. /**
  27246. * Observable signaled when a context restored event is raised
  27247. */
  27248. onContextRestoredObservable: Observable<Engine>;
  27249. private _onContextLost;
  27250. private _onContextRestored;
  27251. private _contextWasLost;
  27252. private _doNotHandleContextLost;
  27253. /**
  27254. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27255. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27256. */
  27257. doNotHandleContextLost: boolean;
  27258. private _performanceMonitor;
  27259. private _fps;
  27260. private _deltaTime;
  27261. /**
  27262. * Turn this value on if you want to pause FPS computation when in background
  27263. */
  27264. disablePerformanceMonitorInBackground: boolean;
  27265. /**
  27266. * Gets the performance monitor attached to this engine
  27267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27268. */
  27269. readonly performanceMonitor: PerformanceMonitor;
  27270. /** @hidden */
  27271. protected _depthCullingState: _DepthCullingState;
  27272. /** @hidden */
  27273. protected _stencilState: _StencilState;
  27274. /** @hidden */
  27275. protected _alphaState: _AlphaState;
  27276. /** @hidden */
  27277. protected _alphaMode: number;
  27278. protected _internalTexturesCache: InternalTexture[];
  27279. /** @hidden */
  27280. protected _activeChannel: number;
  27281. private _currentTextureChannel;
  27282. /** @hidden */
  27283. protected _boundTexturesCache: {
  27284. [key: string]: Nullable<InternalTexture>;
  27285. };
  27286. /** @hidden */
  27287. protected _currentEffect: Nullable<Effect>;
  27288. /** @hidden */
  27289. protected _currentProgram: Nullable<WebGLProgram>;
  27290. private _compiledEffects;
  27291. private _vertexAttribArraysEnabled;
  27292. /** @hidden */
  27293. protected _cachedViewport: Nullable<Viewport>;
  27294. private _cachedVertexArrayObject;
  27295. /** @hidden */
  27296. protected _cachedVertexBuffers: any;
  27297. /** @hidden */
  27298. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  27299. /** @hidden */
  27300. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27301. /** @hidden */
  27302. protected _currentRenderTarget: Nullable<InternalTexture>;
  27303. private _uintIndicesCurrentlySet;
  27304. private _currentBoundBuffer;
  27305. /** @hidden */
  27306. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27307. private _currentBufferPointers;
  27308. private _currentInstanceLocations;
  27309. private _currentInstanceBuffers;
  27310. private _textureUnits;
  27311. private _firstBoundInternalTextureTracker;
  27312. private _lastBoundInternalTextureTracker;
  27313. private _workingCanvas;
  27314. private _workingContext;
  27315. private _rescalePostProcess;
  27316. private _dummyFramebuffer;
  27317. private _externalData;
  27318. private _bindedRenderFunction;
  27319. private _vaoRecordInProgress;
  27320. private _mustWipeVertexAttributes;
  27321. private _emptyTexture;
  27322. private _emptyCubeTexture;
  27323. private _emptyTexture3D;
  27324. /** @hidden */
  27325. _frameHandler: number;
  27326. private _nextFreeTextureSlots;
  27327. private _maxSimultaneousTextures;
  27328. private _activeRequests;
  27329. private _texturesSupported;
  27330. private _textureFormatInUse;
  27331. /**
  27332. * Gets the list of texture formats supported
  27333. */
  27334. readonly texturesSupported: Array<string>;
  27335. /**
  27336. * Gets the list of texture formats in use
  27337. */
  27338. readonly textureFormatInUse: Nullable<string>;
  27339. /**
  27340. * Gets the current viewport
  27341. */
  27342. readonly currentViewport: Nullable<Viewport>;
  27343. /**
  27344. * Gets the default empty texture
  27345. */
  27346. readonly emptyTexture: InternalTexture;
  27347. /**
  27348. * Gets the default empty 3D texture
  27349. */
  27350. readonly emptyTexture3D: InternalTexture;
  27351. /**
  27352. * Gets the default empty cube texture
  27353. */
  27354. readonly emptyCubeTexture: InternalTexture;
  27355. /**
  27356. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27357. */
  27358. readonly premultipliedAlpha: boolean;
  27359. /**
  27360. * Creates a new engine
  27361. * @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
  27362. * @param antialias defines enable antialiasing (default: false)
  27363. * @param options defines further options to be sent to the getContext() function
  27364. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27365. */
  27366. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27367. private _disableTouchAction;
  27368. private _rebuildInternalTextures;
  27369. private _rebuildEffects;
  27370. /**
  27371. * Gets a boolean indicating if all created effects are ready
  27372. * @returns true if all effects are ready
  27373. */
  27374. areAllEffectsReady(): boolean;
  27375. private _rebuildBuffers;
  27376. private _initGLContext;
  27377. /**
  27378. * Gets version of the current webGL context
  27379. */
  27380. readonly webGLVersion: number;
  27381. /**
  27382. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27383. */
  27384. readonly isStencilEnable: boolean;
  27385. private _prepareWorkingCanvas;
  27386. /**
  27387. * Reset the texture cache to empty state
  27388. */
  27389. resetTextureCache(): void;
  27390. /**
  27391. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27393. * @returns true if engine is in deterministic lock step mode
  27394. */
  27395. isDeterministicLockStep(): boolean;
  27396. /**
  27397. * Gets the max steps when engine is running in deterministic lock step
  27398. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27399. * @returns the max steps
  27400. */
  27401. getLockstepMaxSteps(): number;
  27402. /**
  27403. * Gets an object containing information about the current webGL context
  27404. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27405. */
  27406. getGlInfo(): {
  27407. vendor: string;
  27408. renderer: string;
  27409. version: string;
  27410. };
  27411. /**
  27412. * Gets current aspect ratio
  27413. * @param camera defines the camera to use to get the aspect ratio
  27414. * @param useScreen defines if screen size must be used (or the current render target if any)
  27415. * @returns a number defining the aspect ratio
  27416. */
  27417. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27418. /**
  27419. * Gets current screen aspect ratio
  27420. * @returns a number defining the aspect ratio
  27421. */
  27422. getScreenAspectRatio(): number;
  27423. /**
  27424. * Gets the current render width
  27425. * @param useScreen defines if screen size must be used (or the current render target if any)
  27426. * @returns a number defining the current render width
  27427. */
  27428. getRenderWidth(useScreen?: boolean): number;
  27429. /**
  27430. * Gets the current render height
  27431. * @param useScreen defines if screen size must be used (or the current render target if any)
  27432. * @returns a number defining the current render height
  27433. */
  27434. getRenderHeight(useScreen?: boolean): number;
  27435. /**
  27436. * Gets the HTML canvas attached with the current webGL context
  27437. * @returns a HTML canvas
  27438. */
  27439. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27440. /**
  27441. * Gets the client rect of the HTML canvas attached with the current webGL context
  27442. * @returns a client rectanglee
  27443. */
  27444. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27445. /**
  27446. * Defines the hardware scaling level.
  27447. * By default the hardware scaling level is computed from the window device ratio.
  27448. * 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.
  27449. * @param level defines the level to use
  27450. */
  27451. setHardwareScalingLevel(level: number): void;
  27452. /**
  27453. * Gets the current hardware scaling level.
  27454. * By default the hardware scaling level is computed from the window device ratio.
  27455. * 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.
  27456. * @returns a number indicating the current hardware scaling level
  27457. */
  27458. getHardwareScalingLevel(): number;
  27459. /**
  27460. * Gets the list of loaded textures
  27461. * @returns an array containing all loaded textures
  27462. */
  27463. getLoadedTexturesCache(): InternalTexture[];
  27464. /**
  27465. * Gets the object containing all engine capabilities
  27466. * @returns the EngineCapabilities object
  27467. */
  27468. getCaps(): EngineCapabilities;
  27469. /**
  27470. * Gets the current depth function
  27471. * @returns a number defining the depth function
  27472. */
  27473. getDepthFunction(): Nullable<number>;
  27474. /**
  27475. * Sets the current depth function
  27476. * @param depthFunc defines the function to use
  27477. */
  27478. setDepthFunction(depthFunc: number): void;
  27479. /**
  27480. * Sets the current depth function to GREATER
  27481. */
  27482. setDepthFunctionToGreater(): void;
  27483. /**
  27484. * Sets the current depth function to GEQUAL
  27485. */
  27486. setDepthFunctionToGreaterOrEqual(): void;
  27487. /**
  27488. * Sets the current depth function to LESS
  27489. */
  27490. setDepthFunctionToLess(): void;
  27491. /**
  27492. * Sets the current depth function to LEQUAL
  27493. */
  27494. setDepthFunctionToLessOrEqual(): void;
  27495. /**
  27496. * Gets a boolean indicating if stencil buffer is enabled
  27497. * @returns the current stencil buffer state
  27498. */
  27499. getStencilBuffer(): boolean;
  27500. /**
  27501. * Enable or disable the stencil buffer
  27502. * @param enable defines if the stencil buffer must be enabled or disabled
  27503. */
  27504. setStencilBuffer(enable: boolean): void;
  27505. /**
  27506. * Gets the current stencil mask
  27507. * @returns a number defining the new stencil mask to use
  27508. */
  27509. getStencilMask(): number;
  27510. /**
  27511. * Sets the current stencil mask
  27512. * @param mask defines the new stencil mask to use
  27513. */
  27514. setStencilMask(mask: number): void;
  27515. /**
  27516. * Gets the current stencil function
  27517. * @returns a number defining the stencil function to use
  27518. */
  27519. getStencilFunction(): number;
  27520. /**
  27521. * Gets the current stencil reference value
  27522. * @returns a number defining the stencil reference value to use
  27523. */
  27524. getStencilFunctionReference(): number;
  27525. /**
  27526. * Gets the current stencil mask
  27527. * @returns a number defining the stencil mask to use
  27528. */
  27529. getStencilFunctionMask(): number;
  27530. /**
  27531. * Sets the current stencil function
  27532. * @param stencilFunc defines the new stencil function to use
  27533. */
  27534. setStencilFunction(stencilFunc: number): void;
  27535. /**
  27536. * Sets the current stencil reference
  27537. * @param reference defines the new stencil reference to use
  27538. */
  27539. setStencilFunctionReference(reference: number): void;
  27540. /**
  27541. * Sets the current stencil mask
  27542. * @param mask defines the new stencil mask to use
  27543. */
  27544. setStencilFunctionMask(mask: number): void;
  27545. /**
  27546. * Gets the current stencil operation when stencil fails
  27547. * @returns a number defining stencil operation to use when stencil fails
  27548. */
  27549. getStencilOperationFail(): number;
  27550. /**
  27551. * Gets the current stencil operation when depth fails
  27552. * @returns a number defining stencil operation to use when depth fails
  27553. */
  27554. getStencilOperationDepthFail(): number;
  27555. /**
  27556. * Gets the current stencil operation when stencil passes
  27557. * @returns a number defining stencil operation to use when stencil passes
  27558. */
  27559. getStencilOperationPass(): number;
  27560. /**
  27561. * Sets the stencil operation to use when stencil fails
  27562. * @param operation defines the stencil operation to use when stencil fails
  27563. */
  27564. setStencilOperationFail(operation: number): void;
  27565. /**
  27566. * Sets the stencil operation to use when depth fails
  27567. * @param operation defines the stencil operation to use when depth fails
  27568. */
  27569. setStencilOperationDepthFail(operation: number): void;
  27570. /**
  27571. * Sets the stencil operation to use when stencil passes
  27572. * @param operation defines the stencil operation to use when stencil passes
  27573. */
  27574. setStencilOperationPass(operation: number): void;
  27575. /**
  27576. * Sets a boolean indicating if the dithering state is enabled or disabled
  27577. * @param value defines the dithering state
  27578. */
  27579. setDitheringState(value: boolean): void;
  27580. /**
  27581. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27582. * @param value defines the rasterizer state
  27583. */
  27584. setRasterizerState(value: boolean): void;
  27585. /**
  27586. * stop executing a render loop function and remove it from the execution array
  27587. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27588. */
  27589. stopRenderLoop(renderFunction?: () => void): void;
  27590. /** @hidden */
  27591. _renderLoop(): void;
  27592. /**
  27593. * Register and execute a render loop. The engine can have more than one render function
  27594. * @param renderFunction defines the function to continuously execute
  27595. */
  27596. runRenderLoop(renderFunction: () => void): void;
  27597. /**
  27598. * Toggle full screen mode
  27599. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27600. */
  27601. switchFullscreen(requestPointerLock: boolean): void;
  27602. /**
  27603. * Clear the current render buffer or the current render target (if any is set up)
  27604. * @param color defines the color to use
  27605. * @param backBuffer defines if the back buffer must be cleared
  27606. * @param depth defines if the depth buffer must be cleared
  27607. * @param stencil defines if the stencil buffer must be cleared
  27608. */
  27609. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27610. /**
  27611. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27612. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27613. * @param y defines the y-coordinate of the corner of the clear rectangle
  27614. * @param width defines the width of the clear rectangle
  27615. * @param height defines the height of the clear rectangle
  27616. * @param clearColor defines the clear color
  27617. */
  27618. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27619. /**
  27620. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27621. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27622. * @param y defines the y-coordinate of the corner of the clear rectangle
  27623. * @param width defines the width of the clear rectangle
  27624. * @param height defines the height of the clear rectangle
  27625. */
  27626. enableScissor(x: number, y: number, width: number, height: number): void;
  27627. /**
  27628. * Disable previously set scissor test rectangle
  27629. */
  27630. disableScissor(): void;
  27631. private _viewportCached;
  27632. /** @hidden */
  27633. _viewport(x: number, y: number, width: number, height: number): void;
  27634. /**
  27635. * Set the WebGL's viewport
  27636. * @param viewport defines the viewport element to be used
  27637. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27638. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27639. */
  27640. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27641. /**
  27642. * Directly set the WebGL Viewport
  27643. * @param x defines the x coordinate of the viewport (in screen space)
  27644. * @param y defines the y coordinate of the viewport (in screen space)
  27645. * @param width defines the width of the viewport (in screen space)
  27646. * @param height defines the height of the viewport (in screen space)
  27647. * @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
  27648. */
  27649. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27650. /**
  27651. * Begin a new frame
  27652. */
  27653. beginFrame(): void;
  27654. /**
  27655. * Enf the current frame
  27656. */
  27657. endFrame(): void;
  27658. /**
  27659. * Resize the view according to the canvas' size
  27660. */
  27661. resize(): void;
  27662. /**
  27663. * Force a specific size of the canvas
  27664. * @param width defines the new canvas' width
  27665. * @param height defines the new canvas' height
  27666. */
  27667. setSize(width: number, height: number): void;
  27668. /**
  27669. * Gets a boolean indicating if a webVR device was detected
  27670. * @returns true if a webVR device was detected
  27671. */
  27672. isVRDevicePresent(): boolean;
  27673. /**
  27674. * Gets the current webVR device
  27675. * @returns the current webVR device (or null)
  27676. */
  27677. getVRDevice(): any;
  27678. /**
  27679. * Initializes a webVR display and starts listening to display change events
  27680. * The onVRDisplayChangedObservable will be notified upon these changes
  27681. * @returns The onVRDisplayChangedObservable
  27682. */
  27683. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27684. /**
  27685. * Initializes a webVR display and starts listening to display change events
  27686. * The onVRDisplayChangedObservable will be notified upon these changes
  27687. * @returns A promise containing a VRDisplay and if vr is supported
  27688. */
  27689. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27690. /**
  27691. * Call this function to switch to webVR mode
  27692. * Will do nothing if webVR is not supported or if there is no webVR device
  27693. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27694. */
  27695. enableVR(): void;
  27696. /**
  27697. * Call this function to leave webVR mode
  27698. * Will do nothing if webVR is not supported or if there is no webVR device
  27699. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27700. */
  27701. disableVR(): void;
  27702. private _onVRFullScreenTriggered;
  27703. private _getVRDisplaysAsync;
  27704. /**
  27705. * Binds the frame buffer to the specified texture.
  27706. * @param texture The texture to render to or null for the default canvas
  27707. * @param faceIndex The face of the texture to render to in case of cube texture
  27708. * @param requiredWidth The width of the target to render to
  27709. * @param requiredHeight The height of the target to render to
  27710. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27711. * @param depthStencilTexture The depth stencil texture to use to render
  27712. * @param lodLevel defines le lod level to bind to the frame buffer
  27713. */
  27714. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27715. private bindUnboundFramebuffer;
  27716. /**
  27717. * Unbind the current render target texture from the webGL context
  27718. * @param texture defines the render target texture to unbind
  27719. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27720. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27721. */
  27722. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27723. /**
  27724. * Unbind a list of render target textures from the webGL context
  27725. * This is used only when drawBuffer extension or webGL2 are active
  27726. * @param textures defines the render target textures to unbind
  27727. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27728. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27729. */
  27730. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27731. /**
  27732. * Force the mipmap generation for the given render target texture
  27733. * @param texture defines the render target texture to use
  27734. */
  27735. generateMipMapsForCubemap(texture: InternalTexture): void;
  27736. /**
  27737. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27738. */
  27739. flushFramebuffer(): void;
  27740. /**
  27741. * Unbind the current render target and bind the default framebuffer
  27742. */
  27743. restoreDefaultFramebuffer(): void;
  27744. /**
  27745. * Create an uniform buffer
  27746. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27747. * @param elements defines the content of the uniform buffer
  27748. * @returns the webGL uniform buffer
  27749. */
  27750. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27751. /**
  27752. * Create a dynamic uniform buffer
  27753. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27754. * @param elements defines the content of the uniform buffer
  27755. * @returns the webGL uniform buffer
  27756. */
  27757. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27758. /**
  27759. * Update an existing uniform buffer
  27760. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27761. * @param uniformBuffer defines the target uniform buffer
  27762. * @param elements defines the content to update
  27763. * @param offset defines the offset in the uniform buffer where update should start
  27764. * @param count defines the size of the data to update
  27765. */
  27766. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27767. private _resetVertexBufferBinding;
  27768. /**
  27769. * Creates a vertex buffer
  27770. * @param data the data for the vertex buffer
  27771. * @returns the new WebGL static buffer
  27772. */
  27773. createVertexBuffer(data: DataArray): WebGLBuffer;
  27774. /**
  27775. * Creates a dynamic vertex buffer
  27776. * @param data the data for the dynamic vertex buffer
  27777. * @returns the new WebGL dynamic buffer
  27778. */
  27779. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27780. /**
  27781. * Update a dynamic index buffer
  27782. * @param indexBuffer defines the target index buffer
  27783. * @param indices defines the data to update
  27784. * @param offset defines the offset in the target index buffer where update should start
  27785. */
  27786. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27787. /**
  27788. * Updates a dynamic vertex buffer.
  27789. * @param vertexBuffer the vertex buffer to update
  27790. * @param data the data used to update the vertex buffer
  27791. * @param byteOffset the byte offset of the data
  27792. * @param byteLength the byte length of the data
  27793. */
  27794. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27795. private _resetIndexBufferBinding;
  27796. /**
  27797. * Creates a new index buffer
  27798. * @param indices defines the content of the index buffer
  27799. * @param updatable defines if the index buffer must be updatable
  27800. * @returns a new webGL buffer
  27801. */
  27802. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27803. /**
  27804. * Bind a webGL buffer to the webGL context
  27805. * @param buffer defines the buffer to bind
  27806. */
  27807. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27808. /**
  27809. * Bind an uniform buffer to the current webGL context
  27810. * @param buffer defines the buffer to bind
  27811. */
  27812. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27813. /**
  27814. * Bind a buffer to the current webGL context at a given location
  27815. * @param buffer defines the buffer to bind
  27816. * @param location defines the index where to bind the buffer
  27817. */
  27818. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27819. /**
  27820. * Bind a specific block at a given index in a specific shader program
  27821. * @param shaderProgram defines the shader program
  27822. * @param blockName defines the block name
  27823. * @param index defines the index where to bind the block
  27824. */
  27825. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27826. private bindIndexBuffer;
  27827. private bindBuffer;
  27828. /**
  27829. * update the bound buffer with the given data
  27830. * @param data defines the data to update
  27831. */
  27832. updateArrayBuffer(data: Float32Array): void;
  27833. private _vertexAttribPointer;
  27834. private _bindIndexBufferWithCache;
  27835. private _bindVertexBuffersAttributes;
  27836. /**
  27837. * Records a vertex array object
  27838. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27839. * @param vertexBuffers defines the list of vertex buffers to store
  27840. * @param indexBuffer defines the index buffer to store
  27841. * @param effect defines the effect to store
  27842. * @returns the new vertex array object
  27843. */
  27844. recordVertexArrayObject(vertexBuffers: {
  27845. [key: string]: VertexBuffer;
  27846. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27847. /**
  27848. * Bind a specific vertex array object
  27849. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27850. * @param vertexArrayObject defines the vertex array object to bind
  27851. * @param indexBuffer defines the index buffer to bind
  27852. */
  27853. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27854. /**
  27855. * Bind webGl buffers directly to the webGL context
  27856. * @param vertexBuffer defines the vertex buffer to bind
  27857. * @param indexBuffer defines the index buffer to bind
  27858. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27859. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27860. * @param effect defines the effect associated with the vertex buffer
  27861. */
  27862. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27863. private _unbindVertexArrayObject;
  27864. /**
  27865. * Bind a list of vertex buffers to the webGL context
  27866. * @param vertexBuffers defines the list of vertex buffers to bind
  27867. * @param indexBuffer defines the index buffer to bind
  27868. * @param effect defines the effect associated with the vertex buffers
  27869. */
  27870. bindBuffers(vertexBuffers: {
  27871. [key: string]: Nullable<VertexBuffer>;
  27872. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27873. /**
  27874. * Unbind all instance attributes
  27875. */
  27876. unbindInstanceAttributes(): void;
  27877. /**
  27878. * Release and free the memory of a vertex array object
  27879. * @param vao defines the vertex array object to delete
  27880. */
  27881. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27882. /** @hidden */
  27883. _releaseBuffer(buffer: WebGLBuffer): boolean;
  27884. /**
  27885. * Creates a webGL buffer to use with instanciation
  27886. * @param capacity defines the size of the buffer
  27887. * @returns the webGL buffer
  27888. */
  27889. createInstancesBuffer(capacity: number): WebGLBuffer;
  27890. /**
  27891. * Delete a webGL buffer used with instanciation
  27892. * @param buffer defines the webGL buffer to delete
  27893. */
  27894. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27895. /**
  27896. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27897. * @param instancesBuffer defines the webGL buffer to update and bind
  27898. * @param data defines the data to store in the buffer
  27899. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27900. */
  27901. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27902. /**
  27903. * Apply all cached states (depth, culling, stencil and alpha)
  27904. */
  27905. applyStates(): void;
  27906. /**
  27907. * Send a draw order
  27908. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27909. * @param indexStart defines the starting index
  27910. * @param indexCount defines the number of index to draw
  27911. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27912. */
  27913. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27914. /**
  27915. * Draw a list of points
  27916. * @param verticesStart defines the index of first vertex to draw
  27917. * @param verticesCount defines the count of vertices to draw
  27918. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27919. */
  27920. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27921. /**
  27922. * Draw a list of unindexed primitives
  27923. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27924. * @param verticesStart defines the index of first vertex to draw
  27925. * @param verticesCount defines the count of vertices to draw
  27926. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27927. */
  27928. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27929. /**
  27930. * Draw a list of indexed primitives
  27931. * @param fillMode defines the primitive to use
  27932. * @param indexStart defines the starting index
  27933. * @param indexCount defines the number of index to draw
  27934. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27935. */
  27936. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27937. /**
  27938. * Draw a list of unindexed primitives
  27939. * @param fillMode defines the primitive to use
  27940. * @param verticesStart defines the index of first vertex to draw
  27941. * @param verticesCount defines the count of vertices to draw
  27942. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27943. */
  27944. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27945. private _drawMode;
  27946. /** @hidden */
  27947. _releaseEffect(effect: Effect): void;
  27948. /** @hidden */
  27949. _deleteProgram(program: WebGLProgram): void;
  27950. /**
  27951. * Create a new effect (used to store vertex/fragment shaders)
  27952. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27953. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27954. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27955. * @param samplers defines an array of string used to represent textures
  27956. * @param defines defines the string containing the defines to use to compile the shaders
  27957. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27958. * @param onCompiled defines a function to call when the effect creation is successful
  27959. * @param onError defines a function to call when the effect creation has failed
  27960. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27961. * @returns the new Effect
  27962. */
  27963. 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;
  27964. private _compileShader;
  27965. private _compileRawShader;
  27966. /**
  27967. * Directly creates a webGL program
  27968. * @param vertexCode defines the vertex shader code to use
  27969. * @param fragmentCode defines the fragment shader code to use
  27970. * @param context defines the webGL context to use (if not set, the current one will be used)
  27971. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27972. * @returns the new webGL program
  27973. */
  27974. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27975. /**
  27976. * Creates a webGL program
  27977. * @param vertexCode defines the vertex shader code to use
  27978. * @param fragmentCode defines the fragment shader code to use
  27979. * @param defines defines the string containing the defines to use to compile the shaders
  27980. * @param context defines the webGL context to use (if not set, the current one will be used)
  27981. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27982. * @returns the new webGL program
  27983. */
  27984. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27985. private _createShaderProgram;
  27986. private _finalizeProgram;
  27987. /** @hidden */
  27988. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27989. /** @hidden */
  27990. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27991. /**
  27992. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27993. * @param shaderProgram defines the webGL program to use
  27994. * @param uniformsNames defines the list of uniform names
  27995. * @returns an array of webGL uniform locations
  27996. */
  27997. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27998. /**
  27999. * Gets the lsit of active attributes for a given webGL program
  28000. * @param shaderProgram defines the webGL program to use
  28001. * @param attributesNames defines the list of attribute names to get
  28002. * @returns an array of indices indicating the offset of each attribute
  28003. */
  28004. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28005. /**
  28006. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  28007. * @param effect defines the effect to activate
  28008. */
  28009. enableEffect(effect: Nullable<Effect>): void;
  28010. /**
  28011. * Set the value of an uniform to an array of int32
  28012. * @param uniform defines the webGL uniform location where to store the value
  28013. * @param array defines the array of int32 to store
  28014. */
  28015. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28016. /**
  28017. * Set the value of an uniform to an array of int32 (stored as vec2)
  28018. * @param uniform defines the webGL uniform location where to store the value
  28019. * @param array defines the array of int32 to store
  28020. */
  28021. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28022. /**
  28023. * Set the value of an uniform to an array of int32 (stored as vec3)
  28024. * @param uniform defines the webGL uniform location where to store the value
  28025. * @param array defines the array of int32 to store
  28026. */
  28027. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28028. /**
  28029. * Set the value of an uniform to an array of int32 (stored as vec4)
  28030. * @param uniform defines the webGL uniform location where to store the value
  28031. * @param array defines the array of int32 to store
  28032. */
  28033. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  28034. /**
  28035. * Set the value of an uniform to an array of float32
  28036. * @param uniform defines the webGL uniform location where to store the value
  28037. * @param array defines the array of float32 to store
  28038. */
  28039. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28040. /**
  28041. * Set the value of an uniform to an array of float32 (stored as vec2)
  28042. * @param uniform defines the webGL uniform location where to store the value
  28043. * @param array defines the array of float32 to store
  28044. */
  28045. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28046. /**
  28047. * Set the value of an uniform to an array of float32 (stored as vec3)
  28048. * @param uniform defines the webGL uniform location where to store the value
  28049. * @param array defines the array of float32 to store
  28050. */
  28051. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28052. /**
  28053. * Set the value of an uniform to an array of float32 (stored as vec4)
  28054. * @param uniform defines the webGL uniform location where to store the value
  28055. * @param array defines the array of float32 to store
  28056. */
  28057. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  28058. /**
  28059. * Set the value of an uniform to an array of number
  28060. * @param uniform defines the webGL uniform location where to store the value
  28061. * @param array defines the array of number to store
  28062. */
  28063. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28064. /**
  28065. * Set the value of an uniform to an array of number (stored as vec2)
  28066. * @param uniform defines the webGL uniform location where to store the value
  28067. * @param array defines the array of number to store
  28068. */
  28069. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28070. /**
  28071. * Set the value of an uniform to an array of number (stored as vec3)
  28072. * @param uniform defines the webGL uniform location where to store the value
  28073. * @param array defines the array of number to store
  28074. */
  28075. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28076. /**
  28077. * Set the value of an uniform to an array of number (stored as vec4)
  28078. * @param uniform defines the webGL uniform location where to store the value
  28079. * @param array defines the array of number to store
  28080. */
  28081. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  28082. /**
  28083. * Set the value of an uniform to an array of float32 (stored as matrices)
  28084. * @param uniform defines the webGL uniform location where to store the value
  28085. * @param matrices defines the array of float32 to store
  28086. */
  28087. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  28088. /**
  28089. * Set the value of an uniform to a matrix
  28090. * @param uniform defines the webGL uniform location where to store the value
  28091. * @param matrix defines the matrix to store
  28092. */
  28093. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  28094. /**
  28095. * Set the value of an uniform to a matrix (3x3)
  28096. * @param uniform defines the webGL uniform location where to store the value
  28097. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  28098. */
  28099. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28100. /**
  28101. * Set the value of an uniform to a matrix (2x2)
  28102. * @param uniform defines the webGL uniform location where to store the value
  28103. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  28104. */
  28105. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  28106. /**
  28107. * Set the value of an uniform to a number (int)
  28108. * @param uniform defines the webGL uniform location where to store the value
  28109. * @param value defines the int number to store
  28110. */
  28111. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28112. /**
  28113. * Set the value of an uniform to a number (float)
  28114. * @param uniform defines the webGL uniform location where to store the value
  28115. * @param value defines the float number to store
  28116. */
  28117. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28118. /**
  28119. * Set the value of an uniform to a vec2
  28120. * @param uniform defines the webGL uniform location where to store the value
  28121. * @param x defines the 1st component of the value
  28122. * @param y defines the 2nd component of the value
  28123. */
  28124. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28125. /**
  28126. * Set the value of an uniform to a vec3
  28127. * @param uniform defines the webGL uniform location where to store the value
  28128. * @param x defines the 1st component of the value
  28129. * @param y defines the 2nd component of the value
  28130. * @param z defines the 3rd component of the value
  28131. */
  28132. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28133. /**
  28134. * Set the value of an uniform to a boolean
  28135. * @param uniform defines the webGL uniform location where to store the value
  28136. * @param bool defines the boolean to store
  28137. */
  28138. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28139. /**
  28140. * Set the value of an uniform to a vec4
  28141. * @param uniform defines the webGL uniform location where to store the value
  28142. * @param x defines the 1st component of the value
  28143. * @param y defines the 2nd component of the value
  28144. * @param z defines the 3rd component of the value
  28145. * @param w defines the 4th component of the value
  28146. */
  28147. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28148. /**
  28149. * Set the value of an uniform to a Color3
  28150. * @param uniform defines the webGL uniform location where to store the value
  28151. * @param color3 defines the color to store
  28152. */
  28153. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28154. /**
  28155. * Set the value of an uniform to a Color3 and an alpha value
  28156. * @param uniform defines the webGL uniform location where to store the value
  28157. * @param color3 defines the color to store
  28158. * @param alpha defines the alpha component to store
  28159. */
  28160. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28161. /**
  28162. * Sets a Color4 on a uniform variable
  28163. * @param uniform defines the uniform location
  28164. * @param color4 defines the value to be set
  28165. */
  28166. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28167. /**
  28168. * Set various states to the webGL context
  28169. * @param culling defines backface culling state
  28170. * @param zOffset defines the value to apply to zOffset (0 by default)
  28171. * @param force defines if states must be applied even if cache is up to date
  28172. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28173. */
  28174. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28175. /**
  28176. * Set the z offset to apply to current rendering
  28177. * @param value defines the offset to apply
  28178. */
  28179. setZOffset(value: number): void;
  28180. /**
  28181. * Gets the current value of the zOffset
  28182. * @returns the current zOffset state
  28183. */
  28184. getZOffset(): number;
  28185. /**
  28186. * Enable or disable depth buffering
  28187. * @param enable defines the state to set
  28188. */
  28189. setDepthBuffer(enable: boolean): void;
  28190. /**
  28191. * Gets a boolean indicating if depth writing is enabled
  28192. * @returns the current depth writing state
  28193. */
  28194. getDepthWrite(): boolean;
  28195. /**
  28196. * Enable or disable depth writing
  28197. * @param enable defines the state to set
  28198. */
  28199. setDepthWrite(enable: boolean): void;
  28200. /**
  28201. * Enable or disable color writing
  28202. * @param enable defines the state to set
  28203. */
  28204. setColorWrite(enable: boolean): void;
  28205. /**
  28206. * Gets a boolean indicating if color writing is enabled
  28207. * @returns the current color writing state
  28208. */
  28209. getColorWrite(): boolean;
  28210. /**
  28211. * Sets alpha constants used by some alpha blending modes
  28212. * @param r defines the red component
  28213. * @param g defines the green component
  28214. * @param b defines the blue component
  28215. * @param a defines the alpha component
  28216. */
  28217. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28218. /**
  28219. * Sets the current alpha mode
  28220. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28221. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28222. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28223. */
  28224. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28225. /**
  28226. * Gets the current alpha mode
  28227. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28228. * @returns the current alpha mode
  28229. */
  28230. getAlphaMode(): number;
  28231. /**
  28232. * Clears the list of texture accessible through engine.
  28233. * This can help preventing texture load conflict due to name collision.
  28234. */
  28235. clearInternalTexturesCache(): void;
  28236. /**
  28237. * Force the entire cache to be cleared
  28238. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28239. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28240. */
  28241. wipeCaches(bruteForce?: boolean): void;
  28242. /**
  28243. * Set the compressed texture format to use, based on the formats you have, and the formats
  28244. * supported by the hardware / browser.
  28245. *
  28246. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28247. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28248. * to API arguments needed to compressed textures. This puts the burden on the container
  28249. * generator to house the arcane code for determining these for current & future formats.
  28250. *
  28251. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28252. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28253. *
  28254. * Note: The result of this call is not taken into account when a texture is base64.
  28255. *
  28256. * @param formatsAvailable defines the list of those format families you have created
  28257. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28258. *
  28259. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28260. * @returns The extension selected.
  28261. */
  28262. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28263. private _getSamplingParameters;
  28264. private _partialLoadImg;
  28265. private _cascadeLoadImgs;
  28266. /** @hidden */
  28267. _createTexture(): WebGLTexture;
  28268. /**
  28269. * Usually called from Texture.ts.
  28270. * Passed information to create a WebGLTexture
  28271. * @param urlArg defines a value which contains one of the following:
  28272. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28273. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28274. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28275. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28276. * @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)
  28277. * @param scene needed for loading to the correct scene
  28278. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28279. * @param onLoad optional callback to be called upon successful completion
  28280. * @param onError optional callback to be called upon failure
  28281. * @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
  28282. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28283. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28284. * @param forcedExtension defines the extension to use to pick the right loader
  28285. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28286. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28287. */
  28288. 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;
  28289. private _rescaleTexture;
  28290. /**
  28291. * Update a raw texture
  28292. * @param texture defines the texture to update
  28293. * @param data defines the data to store in the texture
  28294. * @param format defines the format of the data
  28295. * @param invertY defines if data must be stored with Y axis inverted
  28296. * @param compression defines the compression used (null by default)
  28297. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28298. */
  28299. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  28300. /**
  28301. * Creates a raw texture
  28302. * @param data defines the data to store in the texture
  28303. * @param width defines the width of the texture
  28304. * @param height defines the height of the texture
  28305. * @param format defines the format of the data
  28306. * @param generateMipMaps defines if the engine should generate the mip levels
  28307. * @param invertY defines if data must be stored with Y axis inverted
  28308. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28309. * @param compression defines the compression used (null by default)
  28310. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28311. * @returns the raw texture inside an InternalTexture
  28312. */
  28313. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  28314. private _unpackFlipYCached;
  28315. /**
  28316. * In case you are sharing the context with other applications, it might
  28317. * be interested to not cache the unpack flip y state to ensure a consistent
  28318. * value would be set.
  28319. */
  28320. enableUnpackFlipYCached: boolean;
  28321. /** @hidden */
  28322. _unpackFlipY(value: boolean): void;
  28323. /** @hidden */
  28324. _getUnpackAlignement(): number;
  28325. /**
  28326. * Creates a dynamic texture
  28327. * @param width defines the width of the texture
  28328. * @param height defines the height of the texture
  28329. * @param generateMipMaps defines if the engine should generate the mip levels
  28330. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28331. * @returns the dynamic texture inside an InternalTexture
  28332. */
  28333. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28334. /**
  28335. * Update the sampling mode of a given texture
  28336. * @param samplingMode defines the required sampling mode
  28337. * @param texture defines the texture to update
  28338. */
  28339. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28340. /**
  28341. * Update the content of a dynamic texture
  28342. * @param texture defines the texture to update
  28343. * @param canvas defines the canvas containing the source
  28344. * @param invertY defines if data must be stored with Y axis inverted
  28345. * @param premulAlpha defines if alpha is stored as premultiplied
  28346. * @param format defines the format of the data
  28347. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28348. */
  28349. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28350. /**
  28351. * Update a video texture
  28352. * @param texture defines the texture to update
  28353. * @param video defines the video element to use
  28354. * @param invertY defines if data must be stored with Y axis inverted
  28355. */
  28356. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28357. /**
  28358. * Updates a depth texture Comparison Mode and Function.
  28359. * If the comparison Function is equal to 0, the mode will be set to none.
  28360. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28361. * @param texture The texture to set the comparison function for
  28362. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28363. */
  28364. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28365. private _setupDepthStencilTexture;
  28366. /**
  28367. * Creates a depth stencil texture.
  28368. * This is only available in WebGL 2 or with the depth texture extension available.
  28369. * @param size The size of face edge in the texture.
  28370. * @param options The options defining the texture.
  28371. * @returns The texture
  28372. */
  28373. createDepthStencilTexture(size: number | {
  28374. width: number;
  28375. height: number;
  28376. }, options: DepthTextureCreationOptions): InternalTexture;
  28377. /**
  28378. * Creates a depth stencil texture.
  28379. * This is only available in WebGL 2 or with the depth texture extension available.
  28380. * @param size The size of face edge in the texture.
  28381. * @param options The options defining the texture.
  28382. * @returns The texture
  28383. */
  28384. private _createDepthStencilTexture;
  28385. /**
  28386. * Creates a depth stencil cube texture.
  28387. * This is only available in WebGL 2.
  28388. * @param size The size of face edge in the cube texture.
  28389. * @param options The options defining the cube texture.
  28390. * @returns The cube texture
  28391. */
  28392. private _createDepthStencilCubeTexture;
  28393. /**
  28394. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28395. * @param renderTarget The render target to set the frame buffer for
  28396. */
  28397. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28398. /**
  28399. * Creates a new render target texture
  28400. * @param size defines the size of the texture
  28401. * @param options defines the options used to create the texture
  28402. * @returns a new render target texture stored in an InternalTexture
  28403. */
  28404. createRenderTargetTexture(size: number | {
  28405. width: number;
  28406. height: number;
  28407. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28408. /**
  28409. * Create a multi render target texture
  28410. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28411. * @param size defines the size of the texture
  28412. * @param options defines the creation options
  28413. * @returns the cube texture as an InternalTexture
  28414. */
  28415. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28416. private _setupFramebufferDepthAttachments;
  28417. /**
  28418. * Updates the sample count of a render target texture
  28419. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28420. * @param texture defines the texture to update
  28421. * @param samples defines the sample count to set
  28422. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28423. */
  28424. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28425. /**
  28426. * Update the sample count for a given multiple render target texture
  28427. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28428. * @param textures defines the textures to update
  28429. * @param samples defines the sample count to set
  28430. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28431. */
  28432. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28433. /** @hidden */
  28434. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28435. /** @hidden */
  28436. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28437. /** @hidden */
  28438. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28439. /** @hidden */
  28440. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28441. /**
  28442. * Creates a new render target cube texture
  28443. * @param size defines the size of the texture
  28444. * @param options defines the options used to create the texture
  28445. * @returns a new render target cube texture stored in an InternalTexture
  28446. */
  28447. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28448. /**
  28449. * Creates a cube texture
  28450. * @param rootUrl defines the url where the files to load is located
  28451. * @param scene defines the current scene
  28452. * @param files defines the list of files to load (1 per face)
  28453. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28454. * @param onLoad defines an optional callback raised when the texture is loaded
  28455. * @param onError defines an optional callback raised if there is an issue to load the texture
  28456. * @param format defines the format of the data
  28457. * @param forcedExtension defines the extension to use to pick the right loader
  28458. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28459. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28460. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28461. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28462. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28463. * @returns the cube texture as an InternalTexture
  28464. */
  28465. 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;
  28466. /**
  28467. * @hidden
  28468. */
  28469. _setCubeMapTextureParams(loadMipmap: boolean): void;
  28470. /**
  28471. * Update a raw cube texture
  28472. * @param texture defines the texture to udpdate
  28473. * @param data defines the data to store
  28474. * @param format defines the data format
  28475. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28476. * @param invertY defines if data must be stored with Y axis inverted
  28477. * @param compression defines the compression used (null by default)
  28478. * @param level defines which level of the texture to update
  28479. */
  28480. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28481. /**
  28482. * Creates a new raw cube texture
  28483. * @param data defines the array of data to use to create each face
  28484. * @param size defines the size of the textures
  28485. * @param format defines the format of the data
  28486. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28487. * @param generateMipMaps defines if the engine should generate the mip levels
  28488. * @param invertY defines if data must be stored with Y axis inverted
  28489. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28490. * @param compression defines the compression used (null by default)
  28491. * @returns the cube texture as an InternalTexture
  28492. */
  28493. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28494. /**
  28495. * Creates a new raw cube texture from a specified url
  28496. * @param url defines the url where the data is located
  28497. * @param scene defines the current scene
  28498. * @param size defines the size of the textures
  28499. * @param format defines the format of the data
  28500. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28501. * @param noMipmap defines if the engine should avoid generating the mip levels
  28502. * @param callback defines a callback used to extract texture data from loaded data
  28503. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28504. * @param onLoad defines a callback called when texture is loaded
  28505. * @param onError defines a callback called if there is an error
  28506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28507. * @param invertY defines if data must be stored with Y axis inverted
  28508. * @returns the cube texture as an InternalTexture
  28509. */
  28510. 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;
  28511. /**
  28512. * Update a raw 3D texture
  28513. * @param texture defines the texture to update
  28514. * @param data defines the data to store
  28515. * @param format defines the data format
  28516. * @param invertY defines if data must be stored with Y axis inverted
  28517. * @param compression defines the used compression (can be null)
  28518. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28519. */
  28520. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28521. /**
  28522. * Creates a new raw 3D texture
  28523. * @param data defines the data used to create the texture
  28524. * @param width defines the width of the texture
  28525. * @param height defines the height of the texture
  28526. * @param depth defines the depth of the texture
  28527. * @param format defines the format of the texture
  28528. * @param generateMipMaps defines if the engine must generate mip levels
  28529. * @param invertY defines if data must be stored with Y axis inverted
  28530. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28531. * @param compression defines the compressed used (can be null)
  28532. * @param textureType defines the compressed used (can be null)
  28533. * @returns a new raw 3D texture (stored in an InternalTexture)
  28534. */
  28535. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28536. private _prepareWebGLTextureContinuation;
  28537. private _prepareWebGLTexture;
  28538. private _convertRGBtoRGBATextureData;
  28539. /** @hidden */
  28540. _releaseFramebufferObjects(texture: InternalTexture): void;
  28541. /** @hidden */
  28542. _releaseTexture(texture: InternalTexture): void;
  28543. private setProgram;
  28544. private _boundUniforms;
  28545. /**
  28546. * Binds an effect to the webGL context
  28547. * @param effect defines the effect to bind
  28548. */
  28549. bindSamplers(effect: Effect): void;
  28550. private _moveBoundTextureOnTop;
  28551. private _getCorrectTextureChannel;
  28552. private _linkTrackers;
  28553. private _removeDesignatedSlot;
  28554. private _activateCurrentTexture;
  28555. /** @hidden */
  28556. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28557. /** @hidden */
  28558. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28559. /**
  28560. * Sets a texture to the webGL context from a postprocess
  28561. * @param channel defines the channel to use
  28562. * @param postProcess defines the source postprocess
  28563. */
  28564. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28565. /**
  28566. * Binds the output of the passed in post process to the texture channel specified
  28567. * @param channel The channel the texture should be bound to
  28568. * @param postProcess The post process which's output should be bound
  28569. */
  28570. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28571. /**
  28572. * Unbind all textures from the webGL context
  28573. */
  28574. unbindAllTextures(): void;
  28575. /**
  28576. * Sets a texture to the according uniform.
  28577. * @param channel The texture channel
  28578. * @param uniform The uniform to set
  28579. * @param texture The texture to apply
  28580. */
  28581. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28582. /**
  28583. * Sets a depth stencil texture from a render target to the according uniform.
  28584. * @param channel The texture channel
  28585. * @param uniform The uniform to set
  28586. * @param texture The render target texture containing the depth stencil texture to apply
  28587. */
  28588. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28589. private _bindSamplerUniformToChannel;
  28590. private _getTextureWrapMode;
  28591. private _setTexture;
  28592. /**
  28593. * Sets an array of texture to the webGL context
  28594. * @param channel defines the channel where the texture array must be set
  28595. * @param uniform defines the associated uniform location
  28596. * @param textures defines the array of textures to bind
  28597. */
  28598. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28599. /** @hidden */
  28600. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28601. private _setTextureParameterFloat;
  28602. private _setTextureParameterInteger;
  28603. /**
  28604. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28605. * @param x defines the x coordinate of the rectangle where pixels must be read
  28606. * @param y defines the y coordinate of the rectangle where pixels must be read
  28607. * @param width defines the width of the rectangle where pixels must be read
  28608. * @param height defines the height of the rectangle where pixels must be read
  28609. * @returns a Uint8Array containing RGBA colors
  28610. */
  28611. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28612. /**
  28613. * Add an externaly attached data from its key.
  28614. * This method call will fail and return false, if such key already exists.
  28615. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28616. * @param key the unique key that identifies the data
  28617. * @param data the data object to associate to the key for this Engine instance
  28618. * @return true if no such key were already present and the data was added successfully, false otherwise
  28619. */
  28620. addExternalData<T>(key: string, data: T): boolean;
  28621. /**
  28622. * Get an externaly attached data from its key
  28623. * @param key the unique key that identifies the data
  28624. * @return the associated data, if present (can be null), or undefined if not present
  28625. */
  28626. getExternalData<T>(key: string): T;
  28627. /**
  28628. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28629. * @param key the unique key that identifies the data
  28630. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28631. * @return the associated data, can be null if the factory returned null.
  28632. */
  28633. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28634. /**
  28635. * Remove an externaly attached data from the Engine instance
  28636. * @param key the unique key that identifies the data
  28637. * @return true if the data was successfully removed, false if it doesn't exist
  28638. */
  28639. removeExternalData(key: string): boolean;
  28640. /**
  28641. * Unbind all vertex attributes from the webGL context
  28642. */
  28643. unbindAllAttributes(): void;
  28644. /**
  28645. * 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
  28646. */
  28647. releaseEffects(): void;
  28648. /**
  28649. * Dispose and release all associated resources
  28650. */
  28651. dispose(): void;
  28652. /**
  28653. * Display the loading screen
  28654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28655. */
  28656. displayLoadingUI(): void;
  28657. /**
  28658. * Hide the loading screen
  28659. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28660. */
  28661. hideLoadingUI(): void;
  28662. /**
  28663. * Gets the current loading screen object
  28664. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28665. */
  28666. /**
  28667. * Sets the current loading screen object
  28668. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28669. */
  28670. loadingScreen: ILoadingScreen;
  28671. /**
  28672. * Sets the current loading screen text
  28673. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28674. */
  28675. loadingUIText: string;
  28676. /**
  28677. * Sets the current loading screen background color
  28678. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28679. */
  28680. loadingUIBackgroundColor: string;
  28681. /**
  28682. * Attach a new callback raised when context lost event is fired
  28683. * @param callback defines the callback to call
  28684. */
  28685. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28686. /**
  28687. * Attach a new callback raised when context restored event is fired
  28688. * @param callback defines the callback to call
  28689. */
  28690. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28691. /**
  28692. * Gets the source code of the vertex shader associated with a specific webGL program
  28693. * @param program defines the program to use
  28694. * @returns a string containing the source code of the vertex shader associated with the program
  28695. */
  28696. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28697. /**
  28698. * Gets the source code of the fragment shader associated with a specific webGL program
  28699. * @param program defines the program to use
  28700. * @returns a string containing the source code of the fragment shader associated with the program
  28701. */
  28702. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28703. /**
  28704. * Get the current error code of the webGL context
  28705. * @returns the error code
  28706. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28707. */
  28708. getError(): number;
  28709. /**
  28710. * Gets the current framerate
  28711. * @returns a number representing the framerate
  28712. */
  28713. getFps(): number;
  28714. /**
  28715. * Gets the time spent between current and previous frame
  28716. * @returns a number representing the delta time in ms
  28717. */
  28718. getDeltaTime(): number;
  28719. private _measureFps;
  28720. /** @hidden */
  28721. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28722. private _canRenderToFloatFramebuffer;
  28723. private _canRenderToHalfFloatFramebuffer;
  28724. private _canRenderToFramebuffer;
  28725. /** @hidden */
  28726. _getWebGLTextureType(type: number): number;
  28727. private _getInternalFormat;
  28728. /** @hidden */
  28729. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28730. /** @hidden */
  28731. _getRGBAMultiSampleBufferFormat(type: number): number;
  28732. /** @hidden */
  28733. _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;
  28734. /** @hidden */
  28735. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28736. private _partialLoadFile;
  28737. private _cascadeLoadFiles;
  28738. /**
  28739. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28740. * @returns true if the engine can be created
  28741. * @ignorenaming
  28742. */
  28743. static isSupported(): boolean;
  28744. }
  28745. }
  28746. declare module "babylonjs/Materials/effect" {
  28747. import { Observable } from "babylonjs/Misc/observable";
  28748. import { Nullable } from "babylonjs/types";
  28749. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  28750. import { Engine } from "babylonjs/Engines/engine";
  28751. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28752. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28753. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28754. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28756. /**
  28757. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28758. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28759. */
  28760. export class EffectFallbacks {
  28761. private _defines;
  28762. private _currentRank;
  28763. private _maxRank;
  28764. private _mesh;
  28765. /**
  28766. * Removes the fallback from the bound mesh.
  28767. */
  28768. unBindMesh(): void;
  28769. /**
  28770. * Adds a fallback on the specified property.
  28771. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28772. * @param define The name of the define in the shader
  28773. */
  28774. addFallback(rank: number, define: string): void;
  28775. /**
  28776. * Sets the mesh to use CPU skinning when needing to fallback.
  28777. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28778. * @param mesh The mesh to use the fallbacks.
  28779. */
  28780. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28781. /**
  28782. * Checks to see if more fallbacks are still availible.
  28783. */
  28784. readonly isMoreFallbacks: boolean;
  28785. /**
  28786. * Removes the defines that shoould be removed when falling back.
  28787. * @param currentDefines defines the current define statements for the shader.
  28788. * @param effect defines the current effect we try to compile
  28789. * @returns The resulting defines with defines of the current rank removed.
  28790. */
  28791. reduce(currentDefines: string, effect: Effect): string;
  28792. }
  28793. /**
  28794. * Options to be used when creating an effect.
  28795. */
  28796. export class EffectCreationOptions {
  28797. /**
  28798. * Atrributes that will be used in the shader.
  28799. */
  28800. attributes: string[];
  28801. /**
  28802. * Uniform varible names that will be set in the shader.
  28803. */
  28804. uniformsNames: string[];
  28805. /**
  28806. * Uniform buffer varible names that will be set in the shader.
  28807. */
  28808. uniformBuffersNames: string[];
  28809. /**
  28810. * Sampler texture variable names that will be set in the shader.
  28811. */
  28812. samplers: string[];
  28813. /**
  28814. * Define statements that will be set in the shader.
  28815. */
  28816. defines: any;
  28817. /**
  28818. * Possible fallbacks for this effect to improve performance when needed.
  28819. */
  28820. fallbacks: Nullable<EffectFallbacks>;
  28821. /**
  28822. * Callback that will be called when the shader is compiled.
  28823. */
  28824. onCompiled: Nullable<(effect: Effect) => void>;
  28825. /**
  28826. * Callback that will be called if an error occurs during shader compilation.
  28827. */
  28828. onError: Nullable<(effect: Effect, errors: string) => void>;
  28829. /**
  28830. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28831. */
  28832. indexParameters: any;
  28833. /**
  28834. * Max number of lights that can be used in the shader.
  28835. */
  28836. maxSimultaneousLights: number;
  28837. /**
  28838. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28839. */
  28840. transformFeedbackVaryings: Nullable<string[]>;
  28841. }
  28842. /**
  28843. * Effect containing vertex and fragment shader that can be executed on an object.
  28844. */
  28845. export class Effect {
  28846. /**
  28847. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28848. */
  28849. static ShadersRepository: string;
  28850. /**
  28851. * Name of the effect.
  28852. */
  28853. name: any;
  28854. /**
  28855. * String container all the define statements that should be set on the shader.
  28856. */
  28857. defines: string;
  28858. /**
  28859. * Callback that will be called when the shader is compiled.
  28860. */
  28861. onCompiled: Nullable<(effect: Effect) => void>;
  28862. /**
  28863. * Callback that will be called if an error occurs during shader compilation.
  28864. */
  28865. onError: Nullable<(effect: Effect, errors: string) => void>;
  28866. /**
  28867. * Callback that will be called when effect is bound.
  28868. */
  28869. onBind: Nullable<(effect: Effect) => void>;
  28870. /**
  28871. * Unique ID of the effect.
  28872. */
  28873. uniqueId: number;
  28874. /**
  28875. * Observable that will be called when the shader is compiled.
  28876. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28877. */
  28878. onCompileObservable: Observable<Effect>;
  28879. /**
  28880. * Observable that will be called if an error occurs during shader compilation.
  28881. */
  28882. onErrorObservable: Observable<Effect>;
  28883. /** @hidden */
  28884. _onBindObservable: Nullable<Observable<Effect>>;
  28885. /**
  28886. * Observable that will be called when effect is bound.
  28887. */
  28888. readonly onBindObservable: Observable<Effect>;
  28889. /** @hidden */
  28890. _bonesComputationForcedToCPU: boolean;
  28891. private static _uniqueIdSeed;
  28892. private _engine;
  28893. private _uniformBuffersNames;
  28894. private _uniformsNames;
  28895. private _samplers;
  28896. private _isReady;
  28897. private _compilationError;
  28898. private _attributesNames;
  28899. private _attributes;
  28900. private _uniforms;
  28901. /**
  28902. * Key for the effect.
  28903. * @hidden
  28904. */
  28905. _key: string;
  28906. private _indexParameters;
  28907. private _fallbacks;
  28908. private _vertexSourceCode;
  28909. private _fragmentSourceCode;
  28910. private _vertexSourceCodeOverride;
  28911. private _fragmentSourceCodeOverride;
  28912. private _transformFeedbackVaryings;
  28913. /**
  28914. * Compiled shader to webGL program.
  28915. * @hidden
  28916. */
  28917. _program: WebGLProgram;
  28918. private _valueCache;
  28919. private static _baseCache;
  28920. /**
  28921. * Instantiates an effect.
  28922. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28923. * @param baseName Name of the effect.
  28924. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28925. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28926. * @param samplers List of sampler variables that will be passed to the shader.
  28927. * @param engine Engine to be used to render the effect
  28928. * @param defines Define statements to be added to the shader.
  28929. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28930. * @param onCompiled Callback that will be called when the shader is compiled.
  28931. * @param onError Callback that will be called if an error occurs during shader compilation.
  28932. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28933. */
  28934. 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);
  28935. /**
  28936. * Unique key for this effect
  28937. */
  28938. readonly key: string;
  28939. /**
  28940. * If the effect has been compiled and prepared.
  28941. * @returns if the effect is compiled and prepared.
  28942. */
  28943. isReady(): boolean;
  28944. /**
  28945. * The engine the effect was initialized with.
  28946. * @returns the engine.
  28947. */
  28948. getEngine(): Engine;
  28949. /**
  28950. * The compiled webGL program for the effect
  28951. * @returns the webGL program.
  28952. */
  28953. getProgram(): WebGLProgram;
  28954. /**
  28955. * The set of names of attribute variables for the shader.
  28956. * @returns An array of attribute names.
  28957. */
  28958. getAttributesNames(): string[];
  28959. /**
  28960. * Returns the attribute at the given index.
  28961. * @param index The index of the attribute.
  28962. * @returns The location of the attribute.
  28963. */
  28964. getAttributeLocation(index: number): number;
  28965. /**
  28966. * Returns the attribute based on the name of the variable.
  28967. * @param name of the attribute to look up.
  28968. * @returns the attribute location.
  28969. */
  28970. getAttributeLocationByName(name: string): number;
  28971. /**
  28972. * The number of attributes.
  28973. * @returns the numnber of attributes.
  28974. */
  28975. getAttributesCount(): number;
  28976. /**
  28977. * Gets the index of a uniform variable.
  28978. * @param uniformName of the uniform to look up.
  28979. * @returns the index.
  28980. */
  28981. getUniformIndex(uniformName: string): number;
  28982. /**
  28983. * Returns the attribute based on the name of the variable.
  28984. * @param uniformName of the uniform to look up.
  28985. * @returns the location of the uniform.
  28986. */
  28987. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28988. /**
  28989. * Returns an array of sampler variable names
  28990. * @returns The array of sampler variable neames.
  28991. */
  28992. getSamplers(): string[];
  28993. /**
  28994. * The error from the last compilation.
  28995. * @returns the error string.
  28996. */
  28997. getCompilationError(): string;
  28998. /**
  28999. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29000. * @param func The callback to be used.
  29001. */
  29002. executeWhenCompiled(func: (effect: Effect) => void): void;
  29003. private _checkIsReady;
  29004. /** @hidden */
  29005. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29006. /** @hidden */
  29007. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29008. /** @hidden */
  29009. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29010. private _processShaderConversion;
  29011. private _processIncludes;
  29012. private _processPrecision;
  29013. /**
  29014. * Recompiles the webGL program
  29015. * @param vertexSourceCode The source code for the vertex shader.
  29016. * @param fragmentSourceCode The source code for the fragment shader.
  29017. * @param onCompiled Callback called when completed.
  29018. * @param onError Callback called on error.
  29019. * @hidden
  29020. */
  29021. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29022. /**
  29023. * Gets the uniform locations of the the specified variable names
  29024. * @param names THe names of the variables to lookup.
  29025. * @returns Array of locations in the same order as variable names.
  29026. */
  29027. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29028. /**
  29029. * Prepares the effect
  29030. * @hidden
  29031. */
  29032. _prepareEffect(): void;
  29033. /**
  29034. * Checks if the effect is supported. (Must be called after compilation)
  29035. */
  29036. readonly isSupported: boolean;
  29037. /**
  29038. * Binds a texture to the engine to be used as output of the shader.
  29039. * @param channel Name of the output variable.
  29040. * @param texture Texture to bind.
  29041. * @hidden
  29042. */
  29043. _bindTexture(channel: string, texture: InternalTexture): void;
  29044. /**
  29045. * Sets a texture on the engine to be used in the shader.
  29046. * @param channel Name of the sampler variable.
  29047. * @param texture Texture to set.
  29048. */
  29049. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29050. /**
  29051. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29052. * @param channel Name of the sampler variable.
  29053. * @param texture Texture to set.
  29054. */
  29055. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29056. /**
  29057. * Sets an array of textures on the engine to be used in the shader.
  29058. * @param channel Name of the variable.
  29059. * @param textures Textures to set.
  29060. */
  29061. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29062. /**
  29063. * 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)
  29064. * @param channel Name of the sampler variable.
  29065. * @param postProcess Post process to get the input texture from.
  29066. */
  29067. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29068. /**
  29069. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29070. * 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)
  29071. * @param channel Name of the sampler variable.
  29072. * @param postProcess Post process to get the output texture from.
  29073. */
  29074. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29075. /** @hidden */
  29076. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29077. /** @hidden */
  29078. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29079. /** @hidden */
  29080. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29081. /** @hidden */
  29082. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29083. /**
  29084. * Binds a buffer to a uniform.
  29085. * @param buffer Buffer to bind.
  29086. * @param name Name of the uniform variable to bind to.
  29087. */
  29088. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29089. /**
  29090. * Binds block to a uniform.
  29091. * @param blockName Name of the block to bind.
  29092. * @param index Index to bind.
  29093. */
  29094. bindUniformBlock(blockName: string, index: number): void;
  29095. /**
  29096. * Sets an interger value on a uniform variable.
  29097. * @param uniformName Name of the variable.
  29098. * @param value Value to be set.
  29099. * @returns this effect.
  29100. */
  29101. setInt(uniformName: string, value: number): Effect;
  29102. /**
  29103. * Sets an int array on a uniform variable.
  29104. * @param uniformName Name of the variable.
  29105. * @param array array to be set.
  29106. * @returns this effect.
  29107. */
  29108. setIntArray(uniformName: string, array: Int32Array): Effect;
  29109. /**
  29110. * 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)
  29111. * @param uniformName Name of the variable.
  29112. * @param array array to be set.
  29113. * @returns this effect.
  29114. */
  29115. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29116. /**
  29117. * 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)
  29118. * @param uniformName Name of the variable.
  29119. * @param array array to be set.
  29120. * @returns this effect.
  29121. */
  29122. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29123. /**
  29124. * 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)
  29125. * @param uniformName Name of the variable.
  29126. * @param array array to be set.
  29127. * @returns this effect.
  29128. */
  29129. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29130. /**
  29131. * Sets an float array on a uniform variable.
  29132. * @param uniformName Name of the variable.
  29133. * @param array array to be set.
  29134. * @returns this effect.
  29135. */
  29136. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29137. /**
  29138. * 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)
  29139. * @param uniformName Name of the variable.
  29140. * @param array array to be set.
  29141. * @returns this effect.
  29142. */
  29143. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29144. /**
  29145. * 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)
  29146. * @param uniformName Name of the variable.
  29147. * @param array array to be set.
  29148. * @returns this effect.
  29149. */
  29150. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29151. /**
  29152. * 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)
  29153. * @param uniformName Name of the variable.
  29154. * @param array array to be set.
  29155. * @returns this effect.
  29156. */
  29157. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29158. /**
  29159. * Sets an array on a uniform variable.
  29160. * @param uniformName Name of the variable.
  29161. * @param array array to be set.
  29162. * @returns this effect.
  29163. */
  29164. setArray(uniformName: string, array: number[]): Effect;
  29165. /**
  29166. * 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)
  29167. * @param uniformName Name of the variable.
  29168. * @param array array to be set.
  29169. * @returns this effect.
  29170. */
  29171. setArray2(uniformName: string, array: number[]): Effect;
  29172. /**
  29173. * 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)
  29174. * @param uniformName Name of the variable.
  29175. * @param array array to be set.
  29176. * @returns this effect.
  29177. */
  29178. setArray3(uniformName: string, array: number[]): Effect;
  29179. /**
  29180. * 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)
  29181. * @param uniformName Name of the variable.
  29182. * @param array array to be set.
  29183. * @returns this effect.
  29184. */
  29185. setArray4(uniformName: string, array: number[]): Effect;
  29186. /**
  29187. * Sets matrices on a uniform variable.
  29188. * @param uniformName Name of the variable.
  29189. * @param matrices matrices to be set.
  29190. * @returns this effect.
  29191. */
  29192. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29193. /**
  29194. * Sets matrix on a uniform variable.
  29195. * @param uniformName Name of the variable.
  29196. * @param matrix matrix to be set.
  29197. * @returns this effect.
  29198. */
  29199. setMatrix(uniformName: string, matrix: Matrix): Effect;
  29200. /**
  29201. * 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)
  29202. * @param uniformName Name of the variable.
  29203. * @param matrix matrix to be set.
  29204. * @returns this effect.
  29205. */
  29206. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29207. /**
  29208. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29209. * @param uniformName Name of the variable.
  29210. * @param matrix matrix to be set.
  29211. * @returns this effect.
  29212. */
  29213. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29214. /**
  29215. * Sets a float on a uniform variable.
  29216. * @param uniformName Name of the variable.
  29217. * @param value value to be set.
  29218. * @returns this effect.
  29219. */
  29220. setFloat(uniformName: string, value: number): Effect;
  29221. /**
  29222. * Sets a boolean on a uniform variable.
  29223. * @param uniformName Name of the variable.
  29224. * @param bool value to be set.
  29225. * @returns this effect.
  29226. */
  29227. setBool(uniformName: string, bool: boolean): Effect;
  29228. /**
  29229. * Sets a Vector2 on a uniform variable.
  29230. * @param uniformName Name of the variable.
  29231. * @param vector2 vector2 to be set.
  29232. * @returns this effect.
  29233. */
  29234. setVector2(uniformName: string, vector2: Vector2): Effect;
  29235. /**
  29236. * Sets a float2 on a uniform variable.
  29237. * @param uniformName Name of the variable.
  29238. * @param x First float in float2.
  29239. * @param y Second float in float2.
  29240. * @returns this effect.
  29241. */
  29242. setFloat2(uniformName: string, x: number, y: number): Effect;
  29243. /**
  29244. * Sets a Vector3 on a uniform variable.
  29245. * @param uniformName Name of the variable.
  29246. * @param vector3 Value to be set.
  29247. * @returns this effect.
  29248. */
  29249. setVector3(uniformName: string, vector3: Vector3): Effect;
  29250. /**
  29251. * Sets a float3 on a uniform variable.
  29252. * @param uniformName Name of the variable.
  29253. * @param x First float in float3.
  29254. * @param y Second float in float3.
  29255. * @param z Third float in float3.
  29256. * @returns this effect.
  29257. */
  29258. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29259. /**
  29260. * Sets a Vector4 on a uniform variable.
  29261. * @param uniformName Name of the variable.
  29262. * @param vector4 Value to be set.
  29263. * @returns this effect.
  29264. */
  29265. setVector4(uniformName: string, vector4: Vector4): Effect;
  29266. /**
  29267. * Sets a float4 on a uniform variable.
  29268. * @param uniformName Name of the variable.
  29269. * @param x First float in float4.
  29270. * @param y Second float in float4.
  29271. * @param z Third float in float4.
  29272. * @param w Fourth float in float4.
  29273. * @returns this effect.
  29274. */
  29275. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29276. /**
  29277. * Sets a Color3 on a uniform variable.
  29278. * @param uniformName Name of the variable.
  29279. * @param color3 Value to be set.
  29280. * @returns this effect.
  29281. */
  29282. setColor3(uniformName: string, color3: Color3): Effect;
  29283. /**
  29284. * Sets a Color4 on a uniform variable.
  29285. * @param uniformName Name of the variable.
  29286. * @param color3 Value to be set.
  29287. * @param alpha Alpha value to be set.
  29288. * @returns this effect.
  29289. */
  29290. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  29291. /**
  29292. * Sets a Color4 on a uniform variable
  29293. * @param uniformName defines the name of the variable
  29294. * @param color4 defines the value to be set
  29295. * @returns this effect.
  29296. */
  29297. setDirectColor4(uniformName: string, color4: Color4): Effect;
  29298. /**
  29299. * This function will add a new shader to the shader store
  29300. * @param name the name of the shader
  29301. * @param pixelShader optional pixel shader content
  29302. * @param vertexShader optional vertex shader content
  29303. */
  29304. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29305. /**
  29306. * Store of each shader (The can be looked up using effect.key)
  29307. */
  29308. static ShadersStore: {
  29309. [key: string]: string;
  29310. };
  29311. /**
  29312. * Store of each included file for a shader (The can be looked up using effect.key)
  29313. */
  29314. static IncludesShadersStore: {
  29315. [key: string]: string;
  29316. };
  29317. /**
  29318. * Resets the cache of effects.
  29319. */
  29320. static ResetCache(): void;
  29321. }
  29322. }
  29323. declare module "babylonjs/Materials/colorCurves" {
  29324. import { Effect } from "babylonjs/Materials/effect";
  29325. /**
  29326. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29327. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29328. * 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;
  29329. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29330. */
  29331. export class ColorCurves {
  29332. private _dirty;
  29333. private _tempColor;
  29334. private _globalCurve;
  29335. private _highlightsCurve;
  29336. private _midtonesCurve;
  29337. private _shadowsCurve;
  29338. private _positiveCurve;
  29339. private _negativeCurve;
  29340. private _globalHue;
  29341. private _globalDensity;
  29342. private _globalSaturation;
  29343. private _globalExposure;
  29344. /**
  29345. * Gets the global Hue value.
  29346. * 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).
  29347. */
  29348. /**
  29349. * Sets the global Hue value.
  29350. * 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).
  29351. */
  29352. globalHue: number;
  29353. /**
  29354. * Gets the global Density value.
  29355. * 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.
  29356. * Values less than zero provide a filter of opposite hue.
  29357. */
  29358. /**
  29359. * Sets the global Density value.
  29360. * 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.
  29361. * Values less than zero provide a filter of opposite hue.
  29362. */
  29363. globalDensity: number;
  29364. /**
  29365. * Gets the global Saturation value.
  29366. * 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.
  29367. */
  29368. /**
  29369. * Sets the global Saturation value.
  29370. * 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.
  29371. */
  29372. globalSaturation: number;
  29373. /**
  29374. * Gets the global Exposure value.
  29375. * 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.
  29376. */
  29377. /**
  29378. * Sets the global Exposure value.
  29379. * 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.
  29380. */
  29381. globalExposure: number;
  29382. private _highlightsHue;
  29383. private _highlightsDensity;
  29384. private _highlightsSaturation;
  29385. private _highlightsExposure;
  29386. /**
  29387. * Gets the highlights Hue value.
  29388. * 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).
  29389. */
  29390. /**
  29391. * Sets the highlights Hue value.
  29392. * 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).
  29393. */
  29394. highlightsHue: number;
  29395. /**
  29396. * Gets the highlights Density value.
  29397. * 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.
  29398. * Values less than zero provide a filter of opposite hue.
  29399. */
  29400. /**
  29401. * Sets the highlights Density value.
  29402. * 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.
  29403. * Values less than zero provide a filter of opposite hue.
  29404. */
  29405. highlightsDensity: number;
  29406. /**
  29407. * Gets the highlights Saturation value.
  29408. * 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.
  29409. */
  29410. /**
  29411. * Sets the highlights Saturation value.
  29412. * 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.
  29413. */
  29414. highlightsSaturation: number;
  29415. /**
  29416. * Gets the highlights Exposure value.
  29417. * 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.
  29418. */
  29419. /**
  29420. * Sets the highlights Exposure value.
  29421. * 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.
  29422. */
  29423. highlightsExposure: number;
  29424. private _midtonesHue;
  29425. private _midtonesDensity;
  29426. private _midtonesSaturation;
  29427. private _midtonesExposure;
  29428. /**
  29429. * Gets the midtones Hue value.
  29430. * 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).
  29431. */
  29432. /**
  29433. * Sets the midtones Hue value.
  29434. * 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).
  29435. */
  29436. midtonesHue: number;
  29437. /**
  29438. * Gets the midtones Density value.
  29439. * 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.
  29440. * Values less than zero provide a filter of opposite hue.
  29441. */
  29442. /**
  29443. * Sets the midtones Density value.
  29444. * 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.
  29445. * Values less than zero provide a filter of opposite hue.
  29446. */
  29447. midtonesDensity: number;
  29448. /**
  29449. * Gets the midtones Saturation value.
  29450. * 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.
  29451. */
  29452. /**
  29453. * Sets the midtones Saturation value.
  29454. * 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.
  29455. */
  29456. midtonesSaturation: number;
  29457. /**
  29458. * Gets the midtones Exposure value.
  29459. * 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.
  29460. */
  29461. /**
  29462. * Sets the midtones Exposure value.
  29463. * 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.
  29464. */
  29465. midtonesExposure: number;
  29466. private _shadowsHue;
  29467. private _shadowsDensity;
  29468. private _shadowsSaturation;
  29469. private _shadowsExposure;
  29470. /**
  29471. * Gets the shadows Hue value.
  29472. * 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).
  29473. */
  29474. /**
  29475. * Sets the shadows Hue value.
  29476. * 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).
  29477. */
  29478. shadowsHue: number;
  29479. /**
  29480. * Gets the shadows Density value.
  29481. * 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.
  29482. * Values less than zero provide a filter of opposite hue.
  29483. */
  29484. /**
  29485. * Sets the shadows Density value.
  29486. * 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.
  29487. * Values less than zero provide a filter of opposite hue.
  29488. */
  29489. shadowsDensity: number;
  29490. /**
  29491. * Gets the shadows Saturation value.
  29492. * 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.
  29493. */
  29494. /**
  29495. * Sets the shadows Saturation value.
  29496. * 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.
  29497. */
  29498. shadowsSaturation: number;
  29499. /**
  29500. * Gets the shadows Exposure value.
  29501. * 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.
  29502. */
  29503. /**
  29504. * Sets the shadows Exposure value.
  29505. * 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.
  29506. */
  29507. shadowsExposure: number;
  29508. /**
  29509. * Returns the class name
  29510. * @returns The class name
  29511. */
  29512. getClassName(): string;
  29513. /**
  29514. * Binds the color curves to the shader.
  29515. * @param colorCurves The color curve to bind
  29516. * @param effect The effect to bind to
  29517. * @param positiveUniform The positive uniform shader parameter
  29518. * @param neutralUniform The neutral uniform shader parameter
  29519. * @param negativeUniform The negative uniform shader parameter
  29520. */
  29521. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29522. /**
  29523. * Prepare the list of uniforms associated with the ColorCurves effects.
  29524. * @param uniformsList The list of uniforms used in the effect
  29525. */
  29526. static PrepareUniforms(uniformsList: string[]): void;
  29527. /**
  29528. * Returns color grading data based on a hue, density, saturation and exposure value.
  29529. * @param filterHue The hue of the color filter.
  29530. * @param filterDensity The density of the color filter.
  29531. * @param saturation The saturation.
  29532. * @param exposure The exposure.
  29533. * @param result The result data container.
  29534. */
  29535. private getColorGradingDataToRef;
  29536. /**
  29537. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29538. * @param value The input slider value in range [-100,100].
  29539. * @returns Adjusted value.
  29540. */
  29541. private static applyColorGradingSliderNonlinear;
  29542. /**
  29543. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29544. * @param hue The hue (H) input.
  29545. * @param saturation The saturation (S) input.
  29546. * @param brightness The brightness (B) input.
  29547. * @result An RGBA color represented as Vector4.
  29548. */
  29549. private static fromHSBToRef;
  29550. /**
  29551. * Returns a value clamped between min and max
  29552. * @param value The value to clamp
  29553. * @param min The minimum of value
  29554. * @param max The maximum of value
  29555. * @returns The clamped value.
  29556. */
  29557. private static clamp;
  29558. /**
  29559. * Clones the current color curve instance.
  29560. * @return The cloned curves
  29561. */
  29562. clone(): ColorCurves;
  29563. /**
  29564. * Serializes the current color curve instance to a json representation.
  29565. * @return a JSON representation
  29566. */
  29567. serialize(): any;
  29568. /**
  29569. * Parses the color curve from a json representation.
  29570. * @param source the JSON source to parse
  29571. * @return The parsed curves
  29572. */
  29573. static Parse(source: any): ColorCurves;
  29574. }
  29575. }
  29576. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  29577. import { Observable } from "babylonjs/Misc/observable";
  29578. import { Nullable } from "babylonjs/types";
  29579. import { Color4 } from "babylonjs/Maths/math";
  29580. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  29581. import { Effect } from "babylonjs/Materials/effect";
  29582. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29583. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  29584. /**
  29585. * Interface to follow in your material defines to integrate easily the
  29586. * Image proccessing functions.
  29587. * @hidden
  29588. */
  29589. export interface IImageProcessingConfigurationDefines {
  29590. IMAGEPROCESSING: boolean;
  29591. VIGNETTE: boolean;
  29592. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29593. VIGNETTEBLENDMODEOPAQUE: boolean;
  29594. TONEMAPPING: boolean;
  29595. TONEMAPPING_ACES: boolean;
  29596. CONTRAST: boolean;
  29597. EXPOSURE: boolean;
  29598. COLORCURVES: boolean;
  29599. COLORGRADING: boolean;
  29600. COLORGRADING3D: boolean;
  29601. SAMPLER3DGREENDEPTH: boolean;
  29602. SAMPLER3DBGRMAP: boolean;
  29603. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29604. }
  29605. /**
  29606. * @hidden
  29607. */
  29608. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29609. IMAGEPROCESSING: boolean;
  29610. VIGNETTE: boolean;
  29611. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29612. VIGNETTEBLENDMODEOPAQUE: boolean;
  29613. TONEMAPPING: boolean;
  29614. TONEMAPPING_ACES: boolean;
  29615. CONTRAST: boolean;
  29616. COLORCURVES: boolean;
  29617. COLORGRADING: boolean;
  29618. COLORGRADING3D: boolean;
  29619. SAMPLER3DGREENDEPTH: boolean;
  29620. SAMPLER3DBGRMAP: boolean;
  29621. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29622. EXPOSURE: boolean;
  29623. constructor();
  29624. }
  29625. /**
  29626. * This groups together the common properties used for image processing either in direct forward pass
  29627. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29628. * or not.
  29629. */
  29630. export class ImageProcessingConfiguration {
  29631. /**
  29632. * Default tone mapping applied in BabylonJS.
  29633. */
  29634. static readonly TONEMAPPING_STANDARD: number;
  29635. /**
  29636. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29637. * to other engines rendering to increase portability.
  29638. */
  29639. static readonly TONEMAPPING_ACES: number;
  29640. /**
  29641. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29642. */
  29643. colorCurves: Nullable<ColorCurves>;
  29644. private _colorCurvesEnabled;
  29645. /**
  29646. * Gets wether the color curves effect is enabled.
  29647. */
  29648. /**
  29649. * Sets wether the color curves effect is enabled.
  29650. */
  29651. colorCurvesEnabled: boolean;
  29652. private _colorGradingTexture;
  29653. /**
  29654. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29655. */
  29656. /**
  29657. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29658. */
  29659. colorGradingTexture: Nullable<BaseTexture>;
  29660. private _colorGradingEnabled;
  29661. /**
  29662. * Gets wether the color grading effect is enabled.
  29663. */
  29664. /**
  29665. * Sets wether the color grading effect is enabled.
  29666. */
  29667. colorGradingEnabled: boolean;
  29668. private _colorGradingWithGreenDepth;
  29669. /**
  29670. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29671. */
  29672. /**
  29673. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29674. */
  29675. colorGradingWithGreenDepth: boolean;
  29676. private _colorGradingBGR;
  29677. /**
  29678. * Gets wether the color grading texture contains BGR values.
  29679. */
  29680. /**
  29681. * Sets wether the color grading texture contains BGR values.
  29682. */
  29683. colorGradingBGR: boolean;
  29684. /** @hidden */
  29685. _exposure: number;
  29686. /**
  29687. * Gets the Exposure used in the effect.
  29688. */
  29689. /**
  29690. * Sets the Exposure used in the effect.
  29691. */
  29692. exposure: number;
  29693. private _toneMappingEnabled;
  29694. /**
  29695. * Gets wether the tone mapping effect is enabled.
  29696. */
  29697. /**
  29698. * Sets wether the tone mapping effect is enabled.
  29699. */
  29700. toneMappingEnabled: boolean;
  29701. private _toneMappingType;
  29702. /**
  29703. * Gets the type of tone mapping effect.
  29704. */
  29705. /**
  29706. * Sets the type of tone mapping effect used in BabylonJS.
  29707. */
  29708. toneMappingType: number;
  29709. protected _contrast: number;
  29710. /**
  29711. * Gets the contrast used in the effect.
  29712. */
  29713. /**
  29714. * Sets the contrast used in the effect.
  29715. */
  29716. contrast: number;
  29717. /**
  29718. * Vignette stretch size.
  29719. */
  29720. vignetteStretch: number;
  29721. /**
  29722. * Vignette centre X Offset.
  29723. */
  29724. vignetteCentreX: number;
  29725. /**
  29726. * Vignette centre Y Offset.
  29727. */
  29728. vignetteCentreY: number;
  29729. /**
  29730. * Vignette weight or intensity of the vignette effect.
  29731. */
  29732. vignetteWeight: number;
  29733. /**
  29734. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29735. * if vignetteEnabled is set to true.
  29736. */
  29737. vignetteColor: Color4;
  29738. /**
  29739. * Camera field of view used by the Vignette effect.
  29740. */
  29741. vignetteCameraFov: number;
  29742. private _vignetteBlendMode;
  29743. /**
  29744. * Gets the vignette blend mode allowing different kind of effect.
  29745. */
  29746. /**
  29747. * Sets the vignette blend mode allowing different kind of effect.
  29748. */
  29749. vignetteBlendMode: number;
  29750. private _vignetteEnabled;
  29751. /**
  29752. * Gets wether the vignette effect is enabled.
  29753. */
  29754. /**
  29755. * Sets wether the vignette effect is enabled.
  29756. */
  29757. vignetteEnabled: boolean;
  29758. private _applyByPostProcess;
  29759. /**
  29760. * Gets wether the image processing is applied through a post process or not.
  29761. */
  29762. /**
  29763. * Sets wether the image processing is applied through a post process or not.
  29764. */
  29765. applyByPostProcess: boolean;
  29766. private _isEnabled;
  29767. /**
  29768. * Gets wether the image processing is enabled or not.
  29769. */
  29770. /**
  29771. * Sets wether the image processing is enabled or not.
  29772. */
  29773. isEnabled: boolean;
  29774. /**
  29775. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29776. */
  29777. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29778. /**
  29779. * Method called each time the image processing information changes requires to recompile the effect.
  29780. */
  29781. protected _updateParameters(): void;
  29782. /**
  29783. * Gets the current class name.
  29784. * @return "ImageProcessingConfiguration"
  29785. */
  29786. getClassName(): string;
  29787. /**
  29788. * Prepare the list of uniforms associated with the Image Processing effects.
  29789. * @param uniforms The list of uniforms used in the effect
  29790. * @param defines the list of defines currently in use
  29791. */
  29792. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29793. /**
  29794. * Prepare the list of samplers associated with the Image Processing effects.
  29795. * @param samplersList The list of uniforms used in the effect
  29796. * @param defines the list of defines currently in use
  29797. */
  29798. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29799. /**
  29800. * Prepare the list of defines associated to the shader.
  29801. * @param defines the list of defines to complete
  29802. * @param forPostProcess Define if we are currently in post process mode or not
  29803. */
  29804. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29805. /**
  29806. * Returns true if all the image processing information are ready.
  29807. * @returns True if ready, otherwise, false
  29808. */
  29809. isReady(): boolean;
  29810. /**
  29811. * Binds the image processing to the shader.
  29812. * @param effect The effect to bind to
  29813. * @param aspectRatio Define the current aspect ratio of the effect
  29814. */
  29815. bind(effect: Effect, aspectRatio?: number): void;
  29816. /**
  29817. * Clones the current image processing instance.
  29818. * @return The cloned image processing
  29819. */
  29820. clone(): ImageProcessingConfiguration;
  29821. /**
  29822. * Serializes the current image processing instance to a json representation.
  29823. * @return a JSON representation
  29824. */
  29825. serialize(): any;
  29826. /**
  29827. * Parses the image processing from a json representation.
  29828. * @param source the JSON source to parse
  29829. * @return The parsed image processing
  29830. */
  29831. static Parse(source: any): ImageProcessingConfiguration;
  29832. private static _VIGNETTEMODE_MULTIPLY;
  29833. private static _VIGNETTEMODE_OPAQUE;
  29834. /**
  29835. * Used to apply the vignette as a mix with the pixel color.
  29836. */
  29837. static readonly VIGNETTEMODE_MULTIPLY: number;
  29838. /**
  29839. * Used to apply the vignette as a replacement of the pixel color.
  29840. */
  29841. static readonly VIGNETTEMODE_OPAQUE: number;
  29842. }
  29843. }
  29844. declare module "babylonjs/Materials/fresnelParameters" {
  29845. import { Color3 } from "babylonjs/Maths/math";
  29846. /**
  29847. * This represents all the required information to add a fresnel effect on a material:
  29848. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29849. */
  29850. export class FresnelParameters {
  29851. private _isEnabled;
  29852. /**
  29853. * Define if the fresnel effect is enable or not.
  29854. */
  29855. isEnabled: boolean;
  29856. /**
  29857. * Define the color used on edges (grazing angle)
  29858. */
  29859. leftColor: Color3;
  29860. /**
  29861. * Define the color used on center
  29862. */
  29863. rightColor: Color3;
  29864. /**
  29865. * Define bias applied to computed fresnel term
  29866. */
  29867. bias: number;
  29868. /**
  29869. * Defined the power exponent applied to fresnel term
  29870. */
  29871. power: number;
  29872. /**
  29873. * Clones the current fresnel and its valuues
  29874. * @returns a clone fresnel configuration
  29875. */
  29876. clone(): FresnelParameters;
  29877. /**
  29878. * Serializes the current fresnel parameters to a JSON representation.
  29879. * @return the JSON serialization
  29880. */
  29881. serialize(): any;
  29882. /**
  29883. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29884. * @param parsedFresnelParameters Define the JSON representation
  29885. * @returns the parsed parameters
  29886. */
  29887. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29888. }
  29889. }
  29890. declare module "babylonjs/Misc/decorators" {
  29891. import { Nullable } from "babylonjs/types";
  29892. import { Scene } from "babylonjs/scene";
  29893. import { IAnimatable } from "babylonjs/Misc/tools";
  29894. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29895. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29896. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29897. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29898. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29899. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29900. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29901. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29902. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29903. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29904. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29905. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29906. /**
  29907. * Decorator used to define property that can be serialized as reference to a camera
  29908. * @param sourceName defines the name of the property to decorate
  29909. */
  29910. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29911. /**
  29912. * Class used to help serialization objects
  29913. */
  29914. export class SerializationHelper {
  29915. /** hidden */
  29916. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  29917. /** hidden */
  29918. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  29919. /** hidden */
  29920. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  29921. /** hidden */
  29922. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  29923. /**
  29924. * Appends the serialized animations from the source animations
  29925. * @param source Source containing the animations
  29926. * @param destination Target to store the animations
  29927. */
  29928. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29929. /**
  29930. * Static function used to serialized a specific entity
  29931. * @param entity defines the entity to serialize
  29932. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29933. * @returns a JSON compatible object representing the serialization of the entity
  29934. */
  29935. static Serialize<T>(entity: T, serializationObject?: any): any;
  29936. /**
  29937. * Creates a new entity from a serialization data object
  29938. * @param creationFunction defines a function used to instanciated the new entity
  29939. * @param source defines the source serialization data
  29940. * @param scene defines the hosting scene
  29941. * @param rootUrl defines the root url for resources
  29942. * @returns a new entity
  29943. */
  29944. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29945. /**
  29946. * Clones an object
  29947. * @param creationFunction defines the function used to instanciate the new object
  29948. * @param source defines the source object
  29949. * @returns the cloned object
  29950. */
  29951. static Clone<T>(creationFunction: () => T, source: T): T;
  29952. /**
  29953. * Instanciates a new object based on a source one (some data will be shared between both object)
  29954. * @param creationFunction defines the function used to instanciate the new object
  29955. * @param source defines the source object
  29956. * @returns the new object
  29957. */
  29958. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29959. }
  29960. }
  29961. declare module "babylonjs/Cameras/camera" {
  29962. import { SmartArray } from "babylonjs/Misc/smartArray";
  29963. import { Observable } from "babylonjs/Misc/observable";
  29964. import { Nullable } from "babylonjs/types";
  29965. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29966. import { Scene } from "babylonjs/scene";
  29967. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  29968. import { Node } from "babylonjs/node";
  29969. import { Mesh } from "babylonjs/Meshes/mesh";
  29970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29971. import { Ray } from "babylonjs/Culling/ray";
  29972. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29974. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29975. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29976. /**
  29977. * This is the base class of all the camera used in the application.
  29978. * @see http://doc.babylonjs.com/features/cameras
  29979. */
  29980. export class Camera extends Node {
  29981. /** @hidden */
  29982. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29983. /**
  29984. * This is the default projection mode used by the cameras.
  29985. * It helps recreating a feeling of perspective and better appreciate depth.
  29986. * This is the best way to simulate real life cameras.
  29987. */
  29988. static readonly PERSPECTIVE_CAMERA: number;
  29989. /**
  29990. * This helps creating camera with an orthographic mode.
  29991. * 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.
  29992. */
  29993. static readonly ORTHOGRAPHIC_CAMERA: number;
  29994. /**
  29995. * This is the default FOV mode for perspective cameras.
  29996. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29997. */
  29998. static readonly FOVMODE_VERTICAL_FIXED: number;
  29999. /**
  30000. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30001. */
  30002. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30003. /**
  30004. * This specifies ther is no need for a camera rig.
  30005. * Basically only one eye is rendered corresponding to the camera.
  30006. */
  30007. static readonly RIG_MODE_NONE: number;
  30008. /**
  30009. * Simulates a camera Rig with one blue eye and one red eye.
  30010. * This can be use with 3d blue and red glasses.
  30011. */
  30012. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30013. /**
  30014. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30015. */
  30016. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30017. /**
  30018. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30019. */
  30020. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30021. /**
  30022. * Defines that both eyes of the camera will be rendered over under each other.
  30023. */
  30024. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30025. /**
  30026. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30027. */
  30028. static readonly RIG_MODE_VR: number;
  30029. /**
  30030. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30031. */
  30032. static readonly RIG_MODE_WEBVR: number;
  30033. /**
  30034. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30035. */
  30036. static readonly RIG_MODE_CUSTOM: number;
  30037. /**
  30038. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30039. */
  30040. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30041. /**
  30042. * @hidden
  30043. * Might be removed once multiview will be a thing
  30044. */
  30045. static UseAlternateWebVRRendering: boolean;
  30046. /**
  30047. * Define the input manager associated with the camera.
  30048. */
  30049. inputs: CameraInputsManager<Camera>;
  30050. /**
  30051. * Define the current local position of the camera in the scene
  30052. */
  30053. position: Vector3;
  30054. /**
  30055. * The vector the camera should consider as up.
  30056. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30057. */
  30058. upVector: Vector3;
  30059. /**
  30060. * Define the current limit on the left side for an orthographic camera
  30061. * In scene unit
  30062. */
  30063. orthoLeft: Nullable<number>;
  30064. /**
  30065. * Define the current limit on the right side for an orthographic camera
  30066. * In scene unit
  30067. */
  30068. orthoRight: Nullable<number>;
  30069. /**
  30070. * Define the current limit on the bottom side for an orthographic camera
  30071. * In scene unit
  30072. */
  30073. orthoBottom: Nullable<number>;
  30074. /**
  30075. * Define the current limit on the top side for an orthographic camera
  30076. * In scene unit
  30077. */
  30078. orthoTop: Nullable<number>;
  30079. /**
  30080. * Field Of View is set in Radians. (default is 0.8)
  30081. */
  30082. fov: number;
  30083. /**
  30084. * Define the minimum distance the camera can see from.
  30085. * This is important to note that the depth buffer are not infinite and the closer it starts
  30086. * the more your scene might encounter depth fighting issue.
  30087. */
  30088. minZ: number;
  30089. /**
  30090. * Define the maximum distance the camera can see to.
  30091. * This is important to note that the depth buffer are not infinite and the further it end
  30092. * the more your scene might encounter depth fighting issue.
  30093. */
  30094. maxZ: number;
  30095. /**
  30096. * Define the default inertia of the camera.
  30097. * This helps giving a smooth feeling to the camera movement.
  30098. */
  30099. inertia: number;
  30100. /**
  30101. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  30102. */
  30103. mode: number;
  30104. /**
  30105. * Define wether the camera is intermediate.
  30106. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30107. */
  30108. isIntermediate: boolean;
  30109. /**
  30110. * Define the viewport of the camera.
  30111. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30112. */
  30113. viewport: Viewport;
  30114. /**
  30115. * Restricts the camera to viewing objects with the same layerMask.
  30116. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30117. */
  30118. layerMask: number;
  30119. /**
  30120. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30121. */
  30122. fovMode: number;
  30123. /**
  30124. * Rig mode of the camera.
  30125. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30126. * This is normally controlled byt the camera themselves as internal use.
  30127. */
  30128. cameraRigMode: number;
  30129. /**
  30130. * Defines the distance between both "eyes" in case of a RIG
  30131. */
  30132. interaxialDistance: number;
  30133. /**
  30134. * Defines if stereoscopic rendering is done side by side or over under.
  30135. */
  30136. isStereoscopicSideBySide: boolean;
  30137. /**
  30138. * 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
  30139. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30140. * else in the scene.
  30141. */
  30142. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30143. /**
  30144. * When set, the camera will render to this render target instead of the default canvas
  30145. */
  30146. outputRenderTarget: Nullable<RenderTargetTexture>;
  30147. /**
  30148. * Observable triggered when the camera view matrix has changed.
  30149. */
  30150. onViewMatrixChangedObservable: Observable<Camera>;
  30151. /**
  30152. * Observable triggered when the camera Projection matrix has changed.
  30153. */
  30154. onProjectionMatrixChangedObservable: Observable<Camera>;
  30155. /**
  30156. * Observable triggered when the inputs have been processed.
  30157. */
  30158. onAfterCheckInputsObservable: Observable<Camera>;
  30159. /**
  30160. * Observable triggered when reset has been called and applied to the camera.
  30161. */
  30162. onRestoreStateObservable: Observable<Camera>;
  30163. /** @hidden */
  30164. _cameraRigParams: any;
  30165. /** @hidden */
  30166. _rigCameras: Camera[];
  30167. /** @hidden */
  30168. _rigPostProcess: Nullable<PostProcess>;
  30169. protected _webvrViewMatrix: Matrix;
  30170. /** @hidden */
  30171. _skipRendering: boolean;
  30172. /** @hidden */
  30173. _alternateCamera: Camera;
  30174. /** @hidden */
  30175. _projectionMatrix: Matrix;
  30176. /** @hidden */
  30177. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30178. /** @hidden */
  30179. _activeMeshes: SmartArray<AbstractMesh>;
  30180. protected _globalPosition: Vector3;
  30181. /** hidden */
  30182. _computedViewMatrix: Matrix;
  30183. private _doNotComputeProjectionMatrix;
  30184. private _transformMatrix;
  30185. private _frustumPlanes;
  30186. private _refreshFrustumPlanes;
  30187. private _storedFov;
  30188. private _stateStored;
  30189. /**
  30190. * Instantiates a new camera object.
  30191. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30192. * @see http://doc.babylonjs.com/features/cameras
  30193. * @param name Defines the name of the camera in the scene
  30194. * @param position Defines the position of the camera
  30195. * @param scene Defines the scene the camera belongs too
  30196. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30197. */
  30198. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30199. /**
  30200. * Store current camera state (fov, position, etc..)
  30201. * @returns the camera
  30202. */
  30203. storeState(): Camera;
  30204. /**
  30205. * Restores the camera state values if it has been stored. You must call storeState() first
  30206. */
  30207. protected _restoreStateValues(): boolean;
  30208. /**
  30209. * Restored camera state. You must call storeState() first.
  30210. * @returns true if restored and false otherwise
  30211. */
  30212. restoreState(): boolean;
  30213. /**
  30214. * Gets the class name of the camera.
  30215. * @returns the class name
  30216. */
  30217. getClassName(): string;
  30218. /** @hidden */
  30219. readonly _isCamera: boolean;
  30220. /**
  30221. * Gets a string representation of the camera useful for debug purpose.
  30222. * @param fullDetails Defines that a more verboe level of logging is required
  30223. * @returns the string representation
  30224. */
  30225. toString(fullDetails?: boolean): string;
  30226. /**
  30227. * Gets the current world space position of the camera.
  30228. */
  30229. readonly globalPosition: Vector3;
  30230. /**
  30231. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30232. * @returns the active meshe list
  30233. */
  30234. getActiveMeshes(): SmartArray<AbstractMesh>;
  30235. /**
  30236. * Check wether a mesh is part of the current active mesh list of the camera
  30237. * @param mesh Defines the mesh to check
  30238. * @returns true if active, false otherwise
  30239. */
  30240. isActiveMesh(mesh: Mesh): boolean;
  30241. /**
  30242. * Is this camera ready to be used/rendered
  30243. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30244. * @return true if the camera is ready
  30245. */
  30246. isReady(completeCheck?: boolean): boolean;
  30247. /** @hidden */
  30248. _initCache(): void;
  30249. /** @hidden */
  30250. _updateCache(ignoreParentClass?: boolean): void;
  30251. /** @hidden */
  30252. _isSynchronized(): boolean;
  30253. /** @hidden */
  30254. _isSynchronizedViewMatrix(): boolean;
  30255. /** @hidden */
  30256. _isSynchronizedProjectionMatrix(): boolean;
  30257. /**
  30258. * Attach the input controls to a specific dom element to get the input from.
  30259. * @param element Defines the element the controls should be listened from
  30260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30261. */
  30262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30263. /**
  30264. * Detach the current controls from the specified dom element.
  30265. * @param element Defines the element to stop listening the inputs from
  30266. */
  30267. detachControl(element: HTMLElement): void;
  30268. /**
  30269. * Update the camera state according to the different inputs gathered during the frame.
  30270. */
  30271. update(): void;
  30272. /** @hidden */
  30273. _checkInputs(): void;
  30274. /** @hidden */
  30275. readonly rigCameras: Camera[];
  30276. /**
  30277. * Gets the post process used by the rig cameras
  30278. */
  30279. readonly rigPostProcess: Nullable<PostProcess>;
  30280. /**
  30281. * Internal, gets the first post proces.
  30282. * @returns the first post process to be run on this camera.
  30283. */
  30284. _getFirstPostProcess(): Nullable<PostProcess>;
  30285. private _cascadePostProcessesToRigCams;
  30286. /**
  30287. * Attach a post process to the camera.
  30288. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30289. * @param postProcess The post process to attach to the camera
  30290. * @param insertAt The position of the post process in case several of them are in use in the scene
  30291. * @returns the position the post process has been inserted at
  30292. */
  30293. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30294. /**
  30295. * Detach a post process to the camera.
  30296. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30297. * @param postProcess The post process to detach from the camera
  30298. */
  30299. detachPostProcess(postProcess: PostProcess): void;
  30300. /**
  30301. * Gets the current world matrix of the camera
  30302. */
  30303. getWorldMatrix(): Matrix;
  30304. /** @hidden */
  30305. _getViewMatrix(): Matrix;
  30306. /**
  30307. * Gets the current view matrix of the camera.
  30308. * @param force forces the camera to recompute the matrix without looking at the cached state
  30309. * @returns the view matrix
  30310. */
  30311. getViewMatrix(force?: boolean): Matrix;
  30312. /**
  30313. * Freeze the projection matrix.
  30314. * It will prevent the cache check of the camera projection compute and can speed up perf
  30315. * if no parameter of the camera are meant to change
  30316. * @param projection Defines manually a projection if necessary
  30317. */
  30318. freezeProjectionMatrix(projection?: Matrix): void;
  30319. /**
  30320. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30321. */
  30322. unfreezeProjectionMatrix(): void;
  30323. /**
  30324. * Gets the current projection matrix of the camera.
  30325. * @param force forces the camera to recompute the matrix without looking at the cached state
  30326. * @returns the projection matrix
  30327. */
  30328. getProjectionMatrix(force?: boolean): Matrix;
  30329. /**
  30330. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30331. * @returns a Matrix
  30332. */
  30333. getTransformationMatrix(): Matrix;
  30334. private _updateFrustumPlanes;
  30335. /**
  30336. * Checks if a cullable object (mesh...) is in the camera frustum
  30337. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30338. * @param target The object to check
  30339. * @returns true if the object is in frustum otherwise false
  30340. */
  30341. isInFrustum(target: ICullable): boolean;
  30342. /**
  30343. * Checks if a cullable object (mesh...) is in the camera frustum
  30344. * Unlike isInFrustum this cheks the full bounding box
  30345. * @param target The object to check
  30346. * @returns true if the object is in frustum otherwise false
  30347. */
  30348. isCompletelyInFrustum(target: ICullable): boolean;
  30349. /**
  30350. * Gets a ray in the forward direction from the camera.
  30351. * @param length Defines the length of the ray to create
  30352. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30353. * @param origin Defines the start point of the ray which defaults to the camera position
  30354. * @returns the forward ray
  30355. */
  30356. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30357. /**
  30358. * Releases resources associated with this node.
  30359. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30360. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30361. */
  30362. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30363. /**
  30364. * Gets the left camera of a rig setup in case of Rigged Camera
  30365. */
  30366. readonly leftCamera: Nullable<FreeCamera>;
  30367. /**
  30368. * Gets the right camera of a rig setup in case of Rigged Camera
  30369. */
  30370. readonly rightCamera: Nullable<FreeCamera>;
  30371. /**
  30372. * Gets the left camera target of a rig setup in case of Rigged Camera
  30373. * @returns the target position
  30374. */
  30375. getLeftTarget(): Nullable<Vector3>;
  30376. /**
  30377. * Gets the right camera target of a rig setup in case of Rigged Camera
  30378. * @returns the target position
  30379. */
  30380. getRightTarget(): Nullable<Vector3>;
  30381. /**
  30382. * @hidden
  30383. */
  30384. setCameraRigMode(mode: number, rigParams: any): void;
  30385. /** @hidden */
  30386. static _setStereoscopicRigMode(camera: Camera): void;
  30387. /** @hidden */
  30388. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30389. /** @hidden */
  30390. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30391. /** @hidden */
  30392. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30393. /** @hidden */
  30394. _getVRProjectionMatrix(): Matrix;
  30395. protected _updateCameraRotationMatrix(): void;
  30396. protected _updateWebVRCameraRotationMatrix(): void;
  30397. /**
  30398. * This function MUST be overwritten by the different WebVR cameras available.
  30399. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30400. * @hidden
  30401. */
  30402. _getWebVRProjectionMatrix(): Matrix;
  30403. /**
  30404. * This function MUST be overwritten by the different WebVR cameras available.
  30405. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30406. * @hidden
  30407. */
  30408. _getWebVRViewMatrix(): Matrix;
  30409. /** @hidden */
  30410. setCameraRigParameter(name: string, value: any): void;
  30411. /**
  30412. * needs to be overridden by children so sub has required properties to be copied
  30413. * @hidden
  30414. */
  30415. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30416. /**
  30417. * May need to be overridden by children
  30418. * @hidden
  30419. */
  30420. _updateRigCameras(): void;
  30421. /** @hidden */
  30422. _setupInputs(): void;
  30423. /**
  30424. * Serialiaze the camera setup to a json represention
  30425. * @returns the JSON representation
  30426. */
  30427. serialize(): any;
  30428. /**
  30429. * Clones the current camera.
  30430. * @param name The cloned camera name
  30431. * @returns the cloned camera
  30432. */
  30433. clone(name: string): Camera;
  30434. /**
  30435. * Gets the direction of the camera relative to a given local axis.
  30436. * @param localAxis Defines the reference axis to provide a relative direction.
  30437. * @return the direction
  30438. */
  30439. getDirection(localAxis: Vector3): Vector3;
  30440. /**
  30441. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30442. * @param localAxis Defines the reference axis to provide a relative direction.
  30443. * @param result Defines the vector to store the result in
  30444. */
  30445. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30446. /**
  30447. * Gets a camera constructor for a given camera type
  30448. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30449. * @param name The name of the camera the result will be able to instantiate
  30450. * @param scene The scene the result will construct the camera in
  30451. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30452. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30453. * @returns a factory method to construc the camera
  30454. */
  30455. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30456. /**
  30457. * Compute the world matrix of the camera.
  30458. * @returns the camera workd matrix
  30459. */
  30460. computeWorldMatrix(): Matrix;
  30461. /**
  30462. * Parse a JSON and creates the camera from the parsed information
  30463. * @param parsedCamera The JSON to parse
  30464. * @param scene The scene to instantiate the camera in
  30465. * @returns the newly constructed camera
  30466. */
  30467. static Parse(parsedCamera: any, scene: Scene): Camera;
  30468. }
  30469. }
  30470. declare module "babylonjs/Misc/tools" {
  30471. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  30472. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  30473. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  30474. import { Observable } from "babylonjs/Misc/observable";
  30475. import { DomManagement } from "babylonjs/Misc/domManagement";
  30476. import { Camera } from "babylonjs/Cameras/camera";
  30477. import { Engine } from "babylonjs/Engines/engine";
  30478. import { Animation } from "babylonjs/Animations/animation";
  30479. /**
  30480. * Interface for any object that can request an animation frame
  30481. */
  30482. export interface ICustomAnimationFrameRequester {
  30483. /**
  30484. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30485. */
  30486. renderFunction?: Function;
  30487. /**
  30488. * Called to request the next frame to render to
  30489. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30490. */
  30491. requestAnimationFrame: Function;
  30492. /**
  30493. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30494. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30495. */
  30496. requestID?: number;
  30497. }
  30498. /**
  30499. * Interface containing an array of animations
  30500. */
  30501. export interface IAnimatable {
  30502. /**
  30503. * Array of animations
  30504. */
  30505. animations: Array<Animation>;
  30506. }
  30507. /** Interface used by value gradients (color, factor, ...) */
  30508. export interface IValueGradient {
  30509. /**
  30510. * Gets or sets the gradient value (between 0 and 1)
  30511. */
  30512. gradient: number;
  30513. }
  30514. /** Class used to store color4 gradient */
  30515. export class ColorGradient implements IValueGradient {
  30516. /**
  30517. * Gets or sets the gradient value (between 0 and 1)
  30518. */
  30519. gradient: number;
  30520. /**
  30521. * Gets or sets first associated color
  30522. */
  30523. color1: Color4;
  30524. /**
  30525. * Gets or sets second associated color
  30526. */
  30527. color2?: Color4;
  30528. /**
  30529. * Will get a color picked randomly between color1 and color2.
  30530. * If color2 is undefined then color1 will be used
  30531. * @param result defines the target Color4 to store the result in
  30532. */
  30533. getColorToRef(result: Color4): void;
  30534. }
  30535. /** Class used to store color 3 gradient */
  30536. export class Color3Gradient implements IValueGradient {
  30537. /**
  30538. * Gets or sets the gradient value (between 0 and 1)
  30539. */
  30540. gradient: number;
  30541. /**
  30542. * Gets or sets the associated color
  30543. */
  30544. color: Color3;
  30545. }
  30546. /** Class used to store factor gradient */
  30547. export class FactorGradient implements IValueGradient {
  30548. /**
  30549. * Gets or sets the gradient value (between 0 and 1)
  30550. */
  30551. gradient: number;
  30552. /**
  30553. * Gets or sets first associated factor
  30554. */
  30555. factor1: number;
  30556. /**
  30557. * Gets or sets second associated factor
  30558. */
  30559. factor2?: number;
  30560. /**
  30561. * Will get a number picked randomly between factor1 and factor2.
  30562. * If factor2 is undefined then factor1 will be used
  30563. * @returns the picked number
  30564. */
  30565. getFactor(): number;
  30566. }
  30567. /**
  30568. * @ignore
  30569. * Application error to support additional information when loading a file
  30570. */
  30571. export class LoadFileError extends Error {
  30572. /** defines the optional XHR request */
  30573. request?: XMLHttpRequest | undefined;
  30574. private static _setPrototypeOf;
  30575. /**
  30576. * Creates a new LoadFileError
  30577. * @param message defines the message of the error
  30578. * @param request defines the optional XHR request
  30579. */
  30580. constructor(message: string,
  30581. /** defines the optional XHR request */
  30582. request?: XMLHttpRequest | undefined);
  30583. }
  30584. /**
  30585. * Class used to define a retry strategy when error happens while loading assets
  30586. */
  30587. export class RetryStrategy {
  30588. /**
  30589. * Function used to defines an exponential back off strategy
  30590. * @param maxRetries defines the maximum number of retries (3 by default)
  30591. * @param baseInterval defines the interval between retries
  30592. * @returns the strategy function to use
  30593. */
  30594. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30595. }
  30596. /**
  30597. * File request interface
  30598. */
  30599. export interface IFileRequest {
  30600. /**
  30601. * Raised when the request is complete (success or error).
  30602. */
  30603. onCompleteObservable: Observable<IFileRequest>;
  30604. /**
  30605. * Aborts the request for a file.
  30606. */
  30607. abort: () => void;
  30608. }
  30609. /**
  30610. * Class containing a set of static utilities functions
  30611. */
  30612. export class Tools {
  30613. /**
  30614. * Gets or sets the base URL to use to load assets
  30615. */
  30616. static BaseUrl: string;
  30617. /**
  30618. * Enable/Disable Custom HTTP Request Headers globally.
  30619. * default = false
  30620. * @see CustomRequestHeaders
  30621. */
  30622. static UseCustomRequestHeaders: boolean;
  30623. /**
  30624. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30625. * i.e. when loading files, where the server/service expects an Authorization header.
  30626. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  30627. */
  30628. static CustomRequestHeaders: {
  30629. [key: string]: string;
  30630. };
  30631. /**
  30632. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30633. */
  30634. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  30635. /**
  30636. * Default behaviour for cors in the application.
  30637. * It can be a string if the expected behavior is identical in the entire app.
  30638. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30639. */
  30640. static CorsBehavior: string | ((url: string | string[]) => string);
  30641. /**
  30642. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30643. * @ignorenaming
  30644. */
  30645. static UseFallbackTexture: boolean;
  30646. /**
  30647. * Use this object to register external classes like custom textures or material
  30648. * to allow the laoders to instantiate them
  30649. */
  30650. static RegisteredExternalClasses: {
  30651. [key: string]: Object;
  30652. };
  30653. /**
  30654. * Texture content used if a texture cannot loaded
  30655. * @ignorenaming
  30656. */
  30657. static fallbackTexture: string;
  30658. /**
  30659. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30660. * @param u defines the coordinate on X axis
  30661. * @param v defines the coordinate on Y axis
  30662. * @param width defines the width of the source data
  30663. * @param height defines the height of the source data
  30664. * @param pixels defines the source byte array
  30665. * @param color defines the output color
  30666. */
  30667. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30668. /**
  30669. * Interpolates between a and b via alpha
  30670. * @param a The lower value (returned when alpha = 0)
  30671. * @param b The upper value (returned when alpha = 1)
  30672. * @param alpha The interpolation-factor
  30673. * @return The mixed value
  30674. */
  30675. static Mix(a: number, b: number, alpha: number): number;
  30676. /**
  30677. * Tries to instantiate a new object from a given class name
  30678. * @param className defines the class name to instantiate
  30679. * @returns the new object or null if the system was not able to do the instantiation
  30680. */
  30681. static Instantiate(className: string): any;
  30682. /**
  30683. * Provides a slice function that will work even on IE
  30684. * @param data defines the array to slice
  30685. * @param start defines the start of the data (optional)
  30686. * @param end defines the end of the data (optional)
  30687. * @returns the new sliced array
  30688. */
  30689. static Slice<T>(data: T, start?: number, end?: number): T;
  30690. /**
  30691. * Polyfill for setImmediate
  30692. * @param action defines the action to execute after the current execution block
  30693. */
  30694. static SetImmediate(action: () => void): void;
  30695. /**
  30696. * Function indicating if a number is an exponent of 2
  30697. * @param value defines the value to test
  30698. * @returns true if the value is an exponent of 2
  30699. */
  30700. static IsExponentOfTwo(value: number): boolean;
  30701. private static _tmpFloatArray;
  30702. /**
  30703. * Returns the nearest 32-bit single precision float representation of a Number
  30704. * @param value A Number. If the parameter is of a different type, it will get converted
  30705. * to a number or to NaN if it cannot be converted
  30706. * @returns number
  30707. */
  30708. static FloatRound(value: number): number;
  30709. /**
  30710. * Find the next highest power of two.
  30711. * @param x Number to start search from.
  30712. * @return Next highest power of two.
  30713. */
  30714. static CeilingPOT(x: number): number;
  30715. /**
  30716. * Find the next lowest power of two.
  30717. * @param x Number to start search from.
  30718. * @return Next lowest power of two.
  30719. */
  30720. static FloorPOT(x: number): number;
  30721. /**
  30722. * Find the nearest power of two.
  30723. * @param x Number to start search from.
  30724. * @return Next nearest power of two.
  30725. */
  30726. static NearestPOT(x: number): number;
  30727. /**
  30728. * Get the closest exponent of two
  30729. * @param value defines the value to approximate
  30730. * @param max defines the maximum value to return
  30731. * @param mode defines how to define the closest value
  30732. * @returns closest exponent of two of the given value
  30733. */
  30734. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30735. /**
  30736. * Extracts the filename from a path
  30737. * @param path defines the path to use
  30738. * @returns the filename
  30739. */
  30740. static GetFilename(path: string): string;
  30741. /**
  30742. * Extracts the "folder" part of a path (everything before the filename).
  30743. * @param uri The URI to extract the info from
  30744. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30745. * @returns The "folder" part of the path
  30746. */
  30747. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30748. /**
  30749. * Extracts text content from a DOM element hierarchy
  30750. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30751. */
  30752. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30753. /**
  30754. * Convert an angle in radians to degrees
  30755. * @param angle defines the angle to convert
  30756. * @returns the angle in degrees
  30757. */
  30758. static ToDegrees(angle: number): number;
  30759. /**
  30760. * Convert an angle in degrees to radians
  30761. * @param angle defines the angle to convert
  30762. * @returns the angle in radians
  30763. */
  30764. static ToRadians(angle: number): number;
  30765. /**
  30766. * Encode a buffer to a base64 string
  30767. * @param buffer defines the buffer to encode
  30768. * @returns the encoded string
  30769. */
  30770. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30771. /**
  30772. * Extracts minimum and maximum values from a list of indexed positions
  30773. * @param positions defines the positions to use
  30774. * @param indices defines the indices to the positions
  30775. * @param indexStart defines the start index
  30776. * @param indexCount defines the end index
  30777. * @param bias defines bias value to add to the result
  30778. * @return minimum and maximum values
  30779. */
  30780. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30781. minimum: Vector3;
  30782. maximum: Vector3;
  30783. };
  30784. /**
  30785. * Extracts minimum and maximum values from a list of positions
  30786. * @param positions defines the positions to use
  30787. * @param start defines the start index in the positions array
  30788. * @param count defines the number of positions to handle
  30789. * @param bias defines bias value to add to the result
  30790. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30791. * @return minimum and maximum values
  30792. */
  30793. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30794. minimum: Vector3;
  30795. maximum: Vector3;
  30796. };
  30797. /**
  30798. * Returns an array if obj is not an array
  30799. * @param obj defines the object to evaluate as an array
  30800. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30801. * @returns either obj directly if obj is an array or a new array containing obj
  30802. */
  30803. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30804. /**
  30805. * Gets the pointer prefix to use
  30806. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30807. */
  30808. static GetPointerPrefix(): string;
  30809. /**
  30810. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30811. * @param func - the function to be called
  30812. * @param requester - the object that will request the next frame. Falls back to window.
  30813. * @returns frame number
  30814. */
  30815. static QueueNewFrame(func: () => void, requester?: any): number;
  30816. /**
  30817. * Ask the browser to promote the current element to fullscreen rendering mode
  30818. * @param element defines the DOM element to promote
  30819. */
  30820. static RequestFullscreen(element: HTMLElement): void;
  30821. /**
  30822. * Asks the browser to exit fullscreen mode
  30823. */
  30824. static ExitFullscreen(): void;
  30825. /**
  30826. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30827. * @param url define the url we are trying
  30828. * @param element define the dom element where to configure the cors policy
  30829. */
  30830. static SetCorsBehavior(url: string | string[], element: {
  30831. crossOrigin: string | null;
  30832. }): void;
  30833. /**
  30834. * Removes unwanted characters from an url
  30835. * @param url defines the url to clean
  30836. * @returns the cleaned url
  30837. */
  30838. static CleanUrl(url: string): string;
  30839. /**
  30840. * Gets or sets a function used to pre-process url before using them to load assets
  30841. */
  30842. static PreprocessUrl: (url: string) => string;
  30843. /**
  30844. * Loads an image as an HTMLImageElement.
  30845. * @param input url string, ArrayBuffer, or Blob to load
  30846. * @param onLoad callback called when the image successfully loads
  30847. * @param onError callback called when the image fails to load
  30848. * @param offlineProvider offline provider for caching
  30849. * @returns the HTMLImageElement of the loaded image
  30850. */
  30851. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30852. /**
  30853. * Loads a file
  30854. * @param url url string, ArrayBuffer, or Blob to load
  30855. * @param onSuccess callback called when the file successfully loads
  30856. * @param onProgress callback called while file is loading (if the server supports this mode)
  30857. * @param offlineProvider defines the offline provider for caching
  30858. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30859. * @param onError callback called when the file fails to load
  30860. * @returns a file request object
  30861. */
  30862. 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;
  30863. /**
  30864. * Load a script (identified by an url). When the url returns, the
  30865. * content of this file is added into a new script element, attached to the DOM (body element)
  30866. * @param scriptUrl defines the url of the script to laod
  30867. * @param onSuccess defines the callback called when the script is loaded
  30868. * @param onError defines the callback to call if an error occurs
  30869. */
  30870. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  30871. /**
  30872. * Loads a file from a blob
  30873. * @param fileToLoad defines the blob to use
  30874. * @param callback defines the callback to call when data is loaded
  30875. * @param progressCallback defines the callback to call during loading process
  30876. * @returns a file request object
  30877. */
  30878. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30879. /**
  30880. * Loads a file
  30881. * @param fileToLoad defines the file to load
  30882. * @param callback defines the callback to call when data is loaded
  30883. * @param progressCallBack defines the callback to call during loading process
  30884. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30885. * @returns a file request object
  30886. */
  30887. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30888. /**
  30889. * Creates a data url from a given string content
  30890. * @param content defines the content to convert
  30891. * @returns the new data url link
  30892. */
  30893. static FileAsURL(content: string): string;
  30894. /**
  30895. * Format the given number to a specific decimal format
  30896. * @param value defines the number to format
  30897. * @param decimals defines the number of decimals to use
  30898. * @returns the formatted string
  30899. */
  30900. static Format(value: number, decimals?: number): string;
  30901. /**
  30902. * Checks if a given vector is inside a specific range
  30903. * @param v defines the vector to test
  30904. * @param min defines the minimum range
  30905. * @param max defines the maximum range
  30906. */
  30907. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30908. /**
  30909. * Tries to copy an object by duplicating every property
  30910. * @param source defines the source object
  30911. * @param destination defines the target object
  30912. * @param doNotCopyList defines a list of properties to avoid
  30913. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30914. */
  30915. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30916. /**
  30917. * Gets a boolean indicating if the given object has no own property
  30918. * @param obj defines the object to test
  30919. * @returns true if object has no own property
  30920. */
  30921. static IsEmpty(obj: any): boolean;
  30922. /**
  30923. * Function used to register events at window level
  30924. * @param events defines the events to register
  30925. */
  30926. static RegisterTopRootEvents(events: {
  30927. name: string;
  30928. handler: Nullable<(e: FocusEvent) => any>;
  30929. }[]): void;
  30930. /**
  30931. * Function used to unregister events from window level
  30932. * @param events defines the events to unregister
  30933. */
  30934. static UnregisterTopRootEvents(events: {
  30935. name: string;
  30936. handler: Nullable<(e: FocusEvent) => any>;
  30937. }[]): void;
  30938. /**
  30939. * Dumps the current bound framebuffer
  30940. * @param width defines the rendering width
  30941. * @param height defines the rendering height
  30942. * @param engine defines the hosting engine
  30943. * @param successCallback defines the callback triggered once the data are available
  30944. * @param mimeType defines the mime type of the result
  30945. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30946. */
  30947. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30948. /**
  30949. * Converts the canvas data to blob.
  30950. * This acts as a polyfill for browsers not supporting the to blob function.
  30951. * @param canvas Defines the canvas to extract the data from
  30952. * @param successCallback Defines the callback triggered once the data are available
  30953. * @param mimeType Defines the mime type of the result
  30954. */
  30955. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30956. /**
  30957. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30958. * @param successCallback defines the callback triggered once the data are available
  30959. * @param mimeType defines the mime type of the result
  30960. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30961. */
  30962. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30963. /**
  30964. * Downloads a blob in the browser
  30965. * @param blob defines the blob to download
  30966. * @param fileName defines the name of the downloaded file
  30967. */
  30968. static Download(blob: Blob, fileName: string): void;
  30969. /**
  30970. * Captures a screenshot of the current rendering
  30971. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30972. * @param engine defines the rendering engine
  30973. * @param camera defines the source camera
  30974. * @param size This parameter can be set to a single number or to an object with the
  30975. * following (optional) properties: precision, width, height. If a single number is passed,
  30976. * it will be used for both width and height. If an object is passed, the screenshot size
  30977. * will be derived from the parameters. The precision property is a multiplier allowing
  30978. * rendering at a higher or lower resolution
  30979. * @param successCallback defines the callback receives a single parameter which contains the
  30980. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30981. * src parameter of an <img> to display it
  30982. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30983. * Check your browser for supported MIME types
  30984. */
  30985. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30986. /**
  30987. * Generates an image screenshot from the specified camera.
  30988. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30989. * @param engine The engine to use for rendering
  30990. * @param camera The camera to use for rendering
  30991. * @param size This parameter can be set to a single number or to an object with the
  30992. * following (optional) properties: precision, width, height. If a single number is passed,
  30993. * it will be used for both width and height. If an object is passed, the screenshot size
  30994. * will be derived from the parameters. The precision property is a multiplier allowing
  30995. * rendering at a higher or lower resolution
  30996. * @param successCallback The callback receives a single parameter which contains the
  30997. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30998. * src parameter of an <img> to display it
  30999. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31000. * Check your browser for supported MIME types
  31001. * @param samples Texture samples (default: 1)
  31002. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31003. * @param fileName A name for for the downloaded file.
  31004. */
  31005. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31006. /**
  31007. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31008. * Be aware Math.random() could cause collisions, but:
  31009. * "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"
  31010. * @returns a pseudo random id
  31011. */
  31012. static RandomId(): string;
  31013. /**
  31014. * Test if the given uri is a base64 string
  31015. * @param uri The uri to test
  31016. * @return True if the uri is a base64 string or false otherwise
  31017. */
  31018. static IsBase64(uri: string): boolean;
  31019. /**
  31020. * Decode the given base64 uri.
  31021. * @param uri The uri to decode
  31022. * @return The decoded base64 data.
  31023. */
  31024. static DecodeBase64(uri: string): ArrayBuffer;
  31025. /**
  31026. * No log
  31027. */
  31028. static readonly NoneLogLevel: number;
  31029. /**
  31030. * Only message logs
  31031. */
  31032. static readonly MessageLogLevel: number;
  31033. /**
  31034. * Only warning logs
  31035. */
  31036. static readonly WarningLogLevel: number;
  31037. /**
  31038. * Only error logs
  31039. */
  31040. static readonly ErrorLogLevel: number;
  31041. /**
  31042. * All logs
  31043. */
  31044. static readonly AllLogLevel: number;
  31045. /**
  31046. * Gets a value indicating the number of loading errors
  31047. * @ignorenaming
  31048. */
  31049. static readonly errorsCount: number;
  31050. /**
  31051. * Callback called when a new log is added
  31052. */
  31053. static OnNewCacheEntry: (entry: string) => void;
  31054. /**
  31055. * Log a message to the console
  31056. * @param message defines the message to log
  31057. */
  31058. static Log(message: string): void;
  31059. /**
  31060. * Write a warning message to the console
  31061. * @param message defines the message to log
  31062. */
  31063. static Warn(message: string): void;
  31064. /**
  31065. * Write an error message to the console
  31066. * @param message defines the message to log
  31067. */
  31068. static Error(message: string): void;
  31069. /**
  31070. * Gets current log cache (list of logs)
  31071. */
  31072. static readonly LogCache: string;
  31073. /**
  31074. * Clears the log cache
  31075. */
  31076. static ClearLogCache(): void;
  31077. /**
  31078. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31079. */
  31080. static LogLevels: number;
  31081. /**
  31082. * Checks if the loaded document was accessed via `file:`-Protocol.
  31083. * @returns boolean
  31084. */
  31085. static IsFileURL(): boolean;
  31086. /**
  31087. * Checks if the window object exists
  31088. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31089. */
  31090. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31091. /**
  31092. * No performance log
  31093. */
  31094. static readonly PerformanceNoneLogLevel: number;
  31095. /**
  31096. * Use user marks to log performance
  31097. */
  31098. static readonly PerformanceUserMarkLogLevel: number;
  31099. /**
  31100. * Log performance to the console
  31101. */
  31102. static readonly PerformanceConsoleLogLevel: number;
  31103. private static _performance;
  31104. /**
  31105. * Sets the current performance log level
  31106. */
  31107. static PerformanceLogLevel: number;
  31108. private static _StartPerformanceCounterDisabled;
  31109. private static _EndPerformanceCounterDisabled;
  31110. private static _StartUserMark;
  31111. private static _EndUserMark;
  31112. private static _StartPerformanceConsole;
  31113. private static _EndPerformanceConsole;
  31114. /**
  31115. * Injects the @see CustomRequestHeaders into the given request
  31116. * @param request the request that should be used for injection
  31117. */
  31118. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  31119. /**
  31120. * Starts a performance counter
  31121. */
  31122. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31123. /**
  31124. * Ends a specific performance coutner
  31125. */
  31126. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31127. /**
  31128. * Gets either window.performance.now() if supported or Date.now() else
  31129. */
  31130. static readonly Now: number;
  31131. /**
  31132. * This method will return the name of the class used to create the instance of the given object.
  31133. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31134. * @param object the object to get the class name from
  31135. * @param isType defines if the object is actually a type
  31136. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31137. */
  31138. static GetClassName(object: any, isType?: boolean): string;
  31139. /**
  31140. * Gets the first element of an array satisfying a given predicate
  31141. * @param array defines the array to browse
  31142. * @param predicate defines the predicate to use
  31143. * @returns null if not found or the element
  31144. */
  31145. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31146. /**
  31147. * This method will return the name of the full name of the class, including its owning module (if any).
  31148. * 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).
  31149. * @param object the object to get the class name from
  31150. * @param isType defines if the object is actually a type
  31151. * @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.
  31152. * @ignorenaming
  31153. */
  31154. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31155. /**
  31156. * Returns a promise that resolves after the given amount of time.
  31157. * @param delay Number of milliseconds to delay
  31158. * @returns Promise that resolves after the given amount of time
  31159. */
  31160. static DelayAsync(delay: number): Promise<void>;
  31161. /**
  31162. * Gets the current gradient from an array of IValueGradient
  31163. * @param ratio defines the current ratio to get
  31164. * @param gradients defines the array of IValueGradient
  31165. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  31166. */
  31167. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  31168. }
  31169. /**
  31170. * This class is used to track a performance counter which is number based.
  31171. * The user has access to many properties which give statistics of different nature.
  31172. *
  31173. * The implementer can track two kinds of Performance Counter: time and count.
  31174. * 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.
  31175. * 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.
  31176. */
  31177. export class PerfCounter {
  31178. /**
  31179. * Gets or sets a global boolean to turn on and off all the counters
  31180. */
  31181. static Enabled: boolean;
  31182. /**
  31183. * Returns the smallest value ever
  31184. */
  31185. readonly min: number;
  31186. /**
  31187. * Returns the biggest value ever
  31188. */
  31189. readonly max: number;
  31190. /**
  31191. * Returns the average value since the performance counter is running
  31192. */
  31193. readonly average: number;
  31194. /**
  31195. * Returns the average value of the last second the counter was monitored
  31196. */
  31197. readonly lastSecAverage: number;
  31198. /**
  31199. * Returns the current value
  31200. */
  31201. readonly current: number;
  31202. /**
  31203. * Gets the accumulated total
  31204. */
  31205. readonly total: number;
  31206. /**
  31207. * Gets the total value count
  31208. */
  31209. readonly count: number;
  31210. /**
  31211. * Creates a new counter
  31212. */
  31213. constructor();
  31214. /**
  31215. * Call this method to start monitoring a new frame.
  31216. * 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.
  31217. */
  31218. fetchNewFrame(): void;
  31219. /**
  31220. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31221. * @param newCount the count value to add to the monitored count
  31222. * @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.
  31223. */
  31224. addCount(newCount: number, fetchResult: boolean): void;
  31225. /**
  31226. * Start monitoring this performance counter
  31227. */
  31228. beginMonitoring(): void;
  31229. /**
  31230. * Compute the time lapsed since the previous beginMonitoring() call.
  31231. * @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
  31232. */
  31233. endMonitoring(newFrame?: boolean): void;
  31234. private _fetchResult;
  31235. private _startMonitoringTime;
  31236. private _min;
  31237. private _max;
  31238. private _average;
  31239. private _current;
  31240. private _totalValueCount;
  31241. private _totalAccumulated;
  31242. private _lastSecAverage;
  31243. private _lastSecAccumulated;
  31244. private _lastSecTime;
  31245. private _lastSecValueCount;
  31246. }
  31247. /**
  31248. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31249. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31250. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31251. * @param name The name of the class, case should be preserved
  31252. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31253. */
  31254. export function className(name: string, module?: string): (target: Object) => void;
  31255. /**
  31256. * An implementation of a loop for asynchronous functions.
  31257. */
  31258. export class AsyncLoop {
  31259. /**
  31260. * Defines the number of iterations for the loop
  31261. */
  31262. iterations: number;
  31263. /**
  31264. * Defines the current index of the loop.
  31265. */
  31266. index: number;
  31267. private _done;
  31268. private _fn;
  31269. private _successCallback;
  31270. /**
  31271. * Constructor.
  31272. * @param iterations the number of iterations.
  31273. * @param func the function to run each iteration
  31274. * @param successCallback the callback that will be called upon succesful execution
  31275. * @param offset starting offset.
  31276. */
  31277. constructor(
  31278. /**
  31279. * Defines the number of iterations for the loop
  31280. */
  31281. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31282. /**
  31283. * Execute the next iteration. Must be called after the last iteration was finished.
  31284. */
  31285. executeNext(): void;
  31286. /**
  31287. * Break the loop and run the success callback.
  31288. */
  31289. breakLoop(): void;
  31290. /**
  31291. * Create and run an async loop.
  31292. * @param iterations the number of iterations.
  31293. * @param fn the function to run each iteration
  31294. * @param successCallback the callback that will be called upon succesful execution
  31295. * @param offset starting offset.
  31296. * @returns the created async loop object
  31297. */
  31298. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31299. /**
  31300. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31301. * @param iterations total number of iterations
  31302. * @param syncedIterations number of synchronous iterations in each async iteration.
  31303. * @param fn the function to call each iteration.
  31304. * @param callback a success call back that will be called when iterating stops.
  31305. * @param breakFunction a break condition (optional)
  31306. * @param timeout timeout settings for the setTimeout function. default - 0.
  31307. * @returns the created async loop object
  31308. */
  31309. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31310. }
  31311. }
  31312. declare module "babylonjs/Collisions/collisionCoordinator" {
  31313. import { Nullable } from "babylonjs/types";
  31314. import { Scene } from "babylonjs/scene";
  31315. import { Vector3 } from "babylonjs/Maths/math";
  31316. import { Collider } from "babylonjs/Collisions/collider";
  31317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31318. /** @hidden */
  31319. export interface ICollisionCoordinator {
  31320. createCollider(): Collider;
  31321. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31322. init(scene: Scene): void;
  31323. }
  31324. /** @hidden */
  31325. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31326. private _scene;
  31327. private _scaledPosition;
  31328. private _scaledVelocity;
  31329. private _finalPosition;
  31330. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31331. createCollider(): Collider;
  31332. init(scene: Scene): void;
  31333. private _collideWithWorld;
  31334. }
  31335. }
  31336. declare module "babylonjs/Animations/animationGroup" {
  31337. import { Animatable } from "babylonjs/Animations/animatable";
  31338. import { Animation } from "babylonjs/Animations/animation";
  31339. import { Scene, IDisposable } from "babylonjs/scene";
  31340. import { Observable } from "babylonjs/Misc/observable";
  31341. import { Nullable } from "babylonjs/types";
  31342. /**
  31343. * This class defines the direct association between an animation and a target
  31344. */
  31345. export class TargetedAnimation {
  31346. /**
  31347. * Animation to perform
  31348. */
  31349. animation: Animation;
  31350. /**
  31351. * Target to animate
  31352. */
  31353. target: any;
  31354. }
  31355. /**
  31356. * Use this class to create coordinated animations on multiple targets
  31357. */
  31358. export class AnimationGroup implements IDisposable {
  31359. /** The name of the animation group */
  31360. name: string;
  31361. private _scene;
  31362. private _targetedAnimations;
  31363. private _animatables;
  31364. private _from;
  31365. private _to;
  31366. private _isStarted;
  31367. private _isPaused;
  31368. private _speedRatio;
  31369. /**
  31370. * Gets or sets the unique id of the node
  31371. */
  31372. uniqueId: number;
  31373. /**
  31374. * This observable will notify when one animation have ended
  31375. */
  31376. onAnimationEndObservable: Observable<TargetedAnimation>;
  31377. /**
  31378. * Observer raised when one animation loops
  31379. */
  31380. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31381. /**
  31382. * This observable will notify when all animations have ended.
  31383. */
  31384. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31385. /**
  31386. * This observable will notify when all animations have paused.
  31387. */
  31388. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31389. /**
  31390. * This observable will notify when all animations are playing.
  31391. */
  31392. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31393. /**
  31394. * Gets the first frame
  31395. */
  31396. readonly from: number;
  31397. /**
  31398. * Gets the last frame
  31399. */
  31400. readonly to: number;
  31401. /**
  31402. * Define if the animations are started
  31403. */
  31404. readonly isStarted: boolean;
  31405. /**
  31406. * Gets a value indicating that the current group is playing
  31407. */
  31408. readonly isPlaying: boolean;
  31409. /**
  31410. * Gets or sets the speed ratio to use for all animations
  31411. */
  31412. /**
  31413. * Gets or sets the speed ratio to use for all animations
  31414. */
  31415. speedRatio: number;
  31416. /**
  31417. * Gets the targeted animations for this animation group
  31418. */
  31419. readonly targetedAnimations: Array<TargetedAnimation>;
  31420. /**
  31421. * returning the list of animatables controlled by this animation group.
  31422. */
  31423. readonly animatables: Array<Animatable>;
  31424. /**
  31425. * Instantiates a new Animation Group.
  31426. * This helps managing several animations at once.
  31427. * @see http://doc.babylonjs.com/how_to/group
  31428. * @param name Defines the name of the group
  31429. * @param scene Defines the scene the group belongs to
  31430. */
  31431. constructor(
  31432. /** The name of the animation group */
  31433. name: string, scene?: Nullable<Scene>);
  31434. /**
  31435. * Add an animation (with its target) in the group
  31436. * @param animation defines the animation we want to add
  31437. * @param target defines the target of the animation
  31438. * @returns the TargetedAnimation object
  31439. */
  31440. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31441. /**
  31442. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31443. * It can add constant keys at begin or end
  31444. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31445. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31446. * @returns the animation group
  31447. */
  31448. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31449. /**
  31450. * Start all animations on given targets
  31451. * @param loop defines if animations must loop
  31452. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31453. * @param from defines the from key (optional)
  31454. * @param to defines the to key (optional)
  31455. * @returns the current animation group
  31456. */
  31457. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31458. /**
  31459. * Pause all animations
  31460. * @returns the animation group
  31461. */
  31462. pause(): AnimationGroup;
  31463. /**
  31464. * Play all animations to initial state
  31465. * This function will start() the animations if they were not started or will restart() them if they were paused
  31466. * @param loop defines if animations must loop
  31467. * @returns the animation group
  31468. */
  31469. play(loop?: boolean): AnimationGroup;
  31470. /**
  31471. * Reset all animations to initial state
  31472. * @returns the animation group
  31473. */
  31474. reset(): AnimationGroup;
  31475. /**
  31476. * Restart animations from key 0
  31477. * @returns the animation group
  31478. */
  31479. restart(): AnimationGroup;
  31480. /**
  31481. * Stop all animations
  31482. * @returns the animation group
  31483. */
  31484. stop(): AnimationGroup;
  31485. /**
  31486. * Set animation weight for all animatables
  31487. * @param weight defines the weight to use
  31488. * @return the animationGroup
  31489. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31490. */
  31491. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31492. /**
  31493. * Synchronize and normalize all animatables with a source animatable
  31494. * @param root defines the root animatable to synchronize with
  31495. * @return the animationGroup
  31496. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31497. */
  31498. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31499. /**
  31500. * Goes to a specific frame in this animation group
  31501. * @param frame the frame number to go to
  31502. * @return the animationGroup
  31503. */
  31504. goToFrame(frame: number): AnimationGroup;
  31505. /**
  31506. * Dispose all associated resources
  31507. */
  31508. dispose(): void;
  31509. private _checkAnimationGroupEnded;
  31510. /**
  31511. * Returns a new AnimationGroup object parsed from the source provided.
  31512. * @param parsedAnimationGroup defines the source
  31513. * @param scene defines the scene that will receive the animationGroup
  31514. * @returns a new AnimationGroup
  31515. */
  31516. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31517. /**
  31518. * Returns the string "AnimationGroup"
  31519. * @returns "AnimationGroup"
  31520. */
  31521. getClassName(): string;
  31522. /**
  31523. * Creates a detailled string about the object
  31524. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31525. * @returns a string representing the object
  31526. */
  31527. toString(fullDetails?: boolean): string;
  31528. }
  31529. }
  31530. declare module "babylonjs/scene" {
  31531. import { Nullable } from "babylonjs/types";
  31532. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  31533. import { Observable } from "babylonjs/Misc/observable";
  31534. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  31535. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  31536. import { Geometry } from "babylonjs/Meshes/geometry";
  31537. import { TransformNode } from "babylonjs/Meshes/transformNode";
  31538. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31540. import { Mesh } from "babylonjs/Meshes/mesh";
  31541. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  31542. import { Bone } from "babylonjs/Bones/bone";
  31543. import { Skeleton } from "babylonjs/Bones/skeleton";
  31544. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  31545. import { Camera } from "babylonjs/Cameras/camera";
  31546. import { AbstractScene } from "babylonjs/abstractScene";
  31547. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31548. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31549. import { Material } from "babylonjs/Materials/material";
  31550. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  31551. import { Effect } from "babylonjs/Materials/effect";
  31552. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31553. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31554. import { Light } from "babylonjs/Lights/light";
  31555. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31556. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  31557. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  31558. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  31559. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31560. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  31561. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31562. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  31563. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction } from "babylonjs/sceneComponent";
  31564. import { Engine } from "babylonjs/Engines/engine";
  31565. import { Ray } from "babylonjs/Culling/ray";
  31566. import { Node } from "babylonjs/node";
  31567. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  31568. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  31569. import { Animation } from "babylonjs/Animations/animation";
  31570. import { Animatable } from "babylonjs/Animations/animatable";
  31571. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  31572. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  31573. import { Collider } from "babylonjs/Collisions/collider";
  31574. /**
  31575. * Define an interface for all classes that will hold resources
  31576. */
  31577. export interface IDisposable {
  31578. /**
  31579. * Releases all held resources
  31580. */
  31581. dispose(): void;
  31582. }
  31583. /** Interface defining initialization parameters for Scene class */
  31584. export interface SceneOptions {
  31585. /**
  31586. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31587. * It will improve performance when the number of geometries becomes important.
  31588. */
  31589. useGeometryUniqueIdsMap?: boolean;
  31590. /**
  31591. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31592. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31593. */
  31594. useMaterialMeshMap?: boolean;
  31595. /**
  31596. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31597. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31598. */
  31599. useClonedMeshhMap?: boolean;
  31600. }
  31601. /**
  31602. * Represents a scene to be rendered by the engine.
  31603. * @see http://doc.babylonjs.com/features/scene
  31604. */
  31605. export class Scene extends AbstractScene implements IAnimatable {
  31606. private static _uniqueIdCounter;
  31607. /** The fog is deactivated */
  31608. static readonly FOGMODE_NONE: number;
  31609. /** The fog density is following an exponential function */
  31610. static readonly FOGMODE_EXP: number;
  31611. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31612. static readonly FOGMODE_EXP2: number;
  31613. /** The fog density is following a linear function. */
  31614. static readonly FOGMODE_LINEAR: number;
  31615. /**
  31616. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31617. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31618. */
  31619. static MinDeltaTime: number;
  31620. /**
  31621. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31623. */
  31624. static MaxDeltaTime: number;
  31625. /**
  31626. * Factory used to create the default material.
  31627. * @param name The name of the material to create
  31628. * @param scene The scene to create the material for
  31629. * @returns The default material
  31630. */
  31631. static DefaultMaterialFactory(scene: Scene): Material;
  31632. /**
  31633. * Factory used to create the a collision coordinator.
  31634. * @returns The collision coordinator
  31635. */
  31636. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31637. /** @hidden */
  31638. readonly _isScene: boolean;
  31639. /**
  31640. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31641. */
  31642. autoClear: boolean;
  31643. /**
  31644. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31645. */
  31646. autoClearDepthAndStencil: boolean;
  31647. /**
  31648. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31649. */
  31650. clearColor: Color4;
  31651. /**
  31652. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31653. */
  31654. ambientColor: Color3;
  31655. /** @hidden */
  31656. _environmentBRDFTexture: BaseTexture;
  31657. /** @hidden */
  31658. protected _environmentTexture: Nullable<BaseTexture>;
  31659. /**
  31660. * Texture used in all pbr material as the reflection texture.
  31661. * As in the majority of the scene they are the same (exception for multi room and so on),
  31662. * this is easier to reference from here than from all the materials.
  31663. */
  31664. /**
  31665. * Texture used in all pbr material as the reflection texture.
  31666. * As in the majority of the scene they are the same (exception for multi room and so on),
  31667. * this is easier to set here than in all the materials.
  31668. */
  31669. environmentTexture: Nullable<BaseTexture>;
  31670. /** @hidden */
  31671. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31672. /**
  31673. * Default image processing configuration used either in the rendering
  31674. * Forward main pass or through the imageProcessingPostProcess if present.
  31675. * As in the majority of the scene they are the same (exception for multi camera),
  31676. * this is easier to reference from here than from all the materials and post process.
  31677. *
  31678. * No setter as we it is a shared configuration, you can set the values instead.
  31679. */
  31680. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31681. private _forceWireframe;
  31682. /**
  31683. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31684. */
  31685. forceWireframe: boolean;
  31686. private _forcePointsCloud;
  31687. /**
  31688. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31689. */
  31690. forcePointsCloud: boolean;
  31691. /**
  31692. * Gets or sets the active clipplane 1
  31693. */
  31694. clipPlane: Nullable<Plane>;
  31695. /**
  31696. * Gets or sets the active clipplane 2
  31697. */
  31698. clipPlane2: Nullable<Plane>;
  31699. /**
  31700. * Gets or sets the active clipplane 3
  31701. */
  31702. clipPlane3: Nullable<Plane>;
  31703. /**
  31704. * Gets or sets the active clipplane 4
  31705. */
  31706. clipPlane4: Nullable<Plane>;
  31707. /**
  31708. * Gets or sets a boolean indicating if animations are enabled
  31709. */
  31710. animationsEnabled: boolean;
  31711. private _animationPropertiesOverride;
  31712. /**
  31713. * Gets or sets the animation properties override
  31714. */
  31715. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31716. /**
  31717. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31718. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31719. */
  31720. useConstantAnimationDeltaTime: boolean;
  31721. /**
  31722. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31723. * Please note that it requires to run a ray cast through the scene on every frame
  31724. */
  31725. constantlyUpdateMeshUnderPointer: boolean;
  31726. /**
  31727. * Defines the HTML cursor to use when hovering over interactive elements
  31728. */
  31729. hoverCursor: string;
  31730. /**
  31731. * Defines the HTML default cursor to use (empty by default)
  31732. */
  31733. defaultCursor: string;
  31734. /**
  31735. * This is used to call preventDefault() on pointer down
  31736. * in order to block unwanted artifacts like system double clicks
  31737. */
  31738. preventDefaultOnPointerDown: boolean;
  31739. /**
  31740. * This is used to call preventDefault() on pointer up
  31741. * in order to block unwanted artifacts like system double clicks
  31742. */
  31743. preventDefaultOnPointerUp: boolean;
  31744. /**
  31745. * Gets or sets user defined metadata
  31746. */
  31747. metadata: any;
  31748. /**
  31749. * For internal use only. Please do not use.
  31750. */
  31751. reservedDataStore: any;
  31752. /**
  31753. * Gets the name of the plugin used to load this scene (null by default)
  31754. */
  31755. loadingPluginName: string;
  31756. /**
  31757. * Use this array to add regular expressions used to disable offline support for specific urls
  31758. */
  31759. disableOfflineSupportExceptionRules: RegExp[];
  31760. /**
  31761. * An event triggered when the scene is disposed.
  31762. */
  31763. onDisposeObservable: Observable<Scene>;
  31764. private _onDisposeObserver;
  31765. /** Sets a function to be executed when this scene is disposed. */
  31766. onDispose: () => void;
  31767. /**
  31768. * An event triggered before rendering the scene (right after animations and physics)
  31769. */
  31770. onBeforeRenderObservable: Observable<Scene>;
  31771. private _onBeforeRenderObserver;
  31772. /** Sets a function to be executed before rendering this scene */
  31773. beforeRender: Nullable<() => void>;
  31774. /**
  31775. * An event triggered after rendering the scene
  31776. */
  31777. onAfterRenderObservable: Observable<Scene>;
  31778. private _onAfterRenderObserver;
  31779. /** Sets a function to be executed after rendering this scene */
  31780. afterRender: Nullable<() => void>;
  31781. /**
  31782. * An event triggered before animating the scene
  31783. */
  31784. onBeforeAnimationsObservable: Observable<Scene>;
  31785. /**
  31786. * An event triggered after animations processing
  31787. */
  31788. onAfterAnimationsObservable: Observable<Scene>;
  31789. /**
  31790. * An event triggered before draw calls are ready to be sent
  31791. */
  31792. onBeforeDrawPhaseObservable: Observable<Scene>;
  31793. /**
  31794. * An event triggered after draw calls have been sent
  31795. */
  31796. onAfterDrawPhaseObservable: Observable<Scene>;
  31797. /**
  31798. * An event triggered when the scene is ready
  31799. */
  31800. onReadyObservable: Observable<Scene>;
  31801. /**
  31802. * An event triggered before rendering a camera
  31803. */
  31804. onBeforeCameraRenderObservable: Observable<Camera>;
  31805. private _onBeforeCameraRenderObserver;
  31806. /** Sets a function to be executed before rendering a camera*/
  31807. beforeCameraRender: () => void;
  31808. /**
  31809. * An event triggered after rendering a camera
  31810. */
  31811. onAfterCameraRenderObservable: Observable<Camera>;
  31812. private _onAfterCameraRenderObserver;
  31813. /** Sets a function to be executed after rendering a camera*/
  31814. afterCameraRender: () => void;
  31815. /**
  31816. * An event triggered when active meshes evaluation is about to start
  31817. */
  31818. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31819. /**
  31820. * An event triggered when active meshes evaluation is done
  31821. */
  31822. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31823. /**
  31824. * An event triggered when particles rendering is about to start
  31825. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31826. */
  31827. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31828. /**
  31829. * An event triggered when particles rendering is done
  31830. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31831. */
  31832. onAfterParticlesRenderingObservable: Observable<Scene>;
  31833. /**
  31834. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31835. */
  31836. onDataLoadedObservable: Observable<Scene>;
  31837. /**
  31838. * An event triggered when a camera is created
  31839. */
  31840. onNewCameraAddedObservable: Observable<Camera>;
  31841. /**
  31842. * An event triggered when a camera is removed
  31843. */
  31844. onCameraRemovedObservable: Observable<Camera>;
  31845. /**
  31846. * An event triggered when a light is created
  31847. */
  31848. onNewLightAddedObservable: Observable<Light>;
  31849. /**
  31850. * An event triggered when a light is removed
  31851. */
  31852. onLightRemovedObservable: Observable<Light>;
  31853. /**
  31854. * An event triggered when a geometry is created
  31855. */
  31856. onNewGeometryAddedObservable: Observable<Geometry>;
  31857. /**
  31858. * An event triggered when a geometry is removed
  31859. */
  31860. onGeometryRemovedObservable: Observable<Geometry>;
  31861. /**
  31862. * An event triggered when a transform node is created
  31863. */
  31864. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31865. /**
  31866. * An event triggered when a transform node is removed
  31867. */
  31868. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31869. /**
  31870. * An event triggered when a mesh is created
  31871. */
  31872. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31873. /**
  31874. * An event triggered when a mesh is removed
  31875. */
  31876. onMeshRemovedObservable: Observable<AbstractMesh>;
  31877. /**
  31878. * An event triggered when a material is created
  31879. */
  31880. onNewMaterialAddedObservable: Observable<Material>;
  31881. /**
  31882. * An event triggered when a material is removed
  31883. */
  31884. onMaterialRemovedObservable: Observable<Material>;
  31885. /**
  31886. * An event triggered when a texture is created
  31887. */
  31888. onNewTextureAddedObservable: Observable<BaseTexture>;
  31889. /**
  31890. * An event triggered when a texture is removed
  31891. */
  31892. onTextureRemovedObservable: Observable<BaseTexture>;
  31893. /**
  31894. * An event triggered when render targets are about to be rendered
  31895. * Can happen multiple times per frame.
  31896. */
  31897. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31898. /**
  31899. * An event triggered when render targets were rendered.
  31900. * Can happen multiple times per frame.
  31901. */
  31902. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31903. /**
  31904. * An event triggered before calculating deterministic simulation step
  31905. */
  31906. onBeforeStepObservable: Observable<Scene>;
  31907. /**
  31908. * An event triggered after calculating deterministic simulation step
  31909. */
  31910. onAfterStepObservable: Observable<Scene>;
  31911. /**
  31912. * An event triggered when the activeCamera property is updated
  31913. */
  31914. onActiveCameraChanged: Observable<Scene>;
  31915. /**
  31916. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31917. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31918. * 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)
  31919. */
  31920. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31921. /**
  31922. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31923. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31924. * 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)
  31925. */
  31926. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31927. /**
  31928. * This Observable will when a mesh has been imported into the scene.
  31929. */
  31930. onMeshImportedObservable: Observable<AbstractMesh>;
  31931. /** @hidden */
  31932. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31933. /**
  31934. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31935. */
  31936. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31937. /**
  31938. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31939. */
  31940. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31941. /**
  31942. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31943. */
  31944. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31945. private _onPointerMove;
  31946. private _onPointerDown;
  31947. private _onPointerUp;
  31948. /** Callback called when a pointer move is detected */
  31949. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31950. /** Callback called when a pointer down is detected */
  31951. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31952. /** Callback called when a pointer up is detected */
  31953. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31954. /** Callback called when a pointer pick is detected */
  31955. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31956. /**
  31957. * 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).
  31958. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31959. */
  31960. onPrePointerObservable: Observable<PointerInfoPre>;
  31961. /**
  31962. * Observable event triggered each time an input event is received from the rendering canvas
  31963. */
  31964. onPointerObservable: Observable<PointerInfo>;
  31965. /**
  31966. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31967. */
  31968. readonly unTranslatedPointer: Vector2;
  31969. /** The distance in pixel that you have to move to prevent some events */
  31970. static DragMovementThreshold: number;
  31971. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31972. static LongPressDelay: number;
  31973. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31974. static DoubleClickDelay: number;
  31975. /** If you need to check double click without raising a single click at first click, enable this flag */
  31976. static ExclusiveDoubleClickMode: boolean;
  31977. private _initClickEvent;
  31978. private _initActionManager;
  31979. private _delayedSimpleClick;
  31980. private _delayedSimpleClickTimeout;
  31981. private _previousDelayedSimpleClickTimeout;
  31982. private _meshPickProceed;
  31983. private _previousButtonPressed;
  31984. private _currentPickResult;
  31985. private _previousPickResult;
  31986. private _totalPointersPressed;
  31987. private _doubleClickOccured;
  31988. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31989. cameraToUseForPointers: Nullable<Camera>;
  31990. private _pointerX;
  31991. private _pointerY;
  31992. private _unTranslatedPointerX;
  31993. private _unTranslatedPointerY;
  31994. private _startingPointerPosition;
  31995. private _previousStartingPointerPosition;
  31996. private _startingPointerTime;
  31997. private _previousStartingPointerTime;
  31998. private _pointerCaptures;
  31999. private _timeAccumulator;
  32000. private _currentStepId;
  32001. private _currentInternalStep;
  32002. /** @hidden */
  32003. _mirroredCameraPosition: Nullable<Vector3>;
  32004. /**
  32005. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32006. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32007. */
  32008. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32009. /**
  32010. * Observable event triggered each time an keyboard event is received from the hosting window
  32011. */
  32012. onKeyboardObservable: Observable<KeyboardInfo>;
  32013. private _onKeyDown;
  32014. private _onKeyUp;
  32015. private _onCanvasFocusObserver;
  32016. private _onCanvasBlurObserver;
  32017. private _useRightHandedSystem;
  32018. /**
  32019. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32020. */
  32021. useRightHandedSystem: boolean;
  32022. /**
  32023. * Sets the step Id used by deterministic lock step
  32024. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32025. * @param newStepId defines the step Id
  32026. */
  32027. setStepId(newStepId: number): void;
  32028. /**
  32029. * Gets the step Id used by deterministic lock step
  32030. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32031. * @returns the step Id
  32032. */
  32033. getStepId(): number;
  32034. /**
  32035. * Gets the internal step used by deterministic lock step
  32036. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32037. * @returns the internal step
  32038. */
  32039. getInternalStep(): number;
  32040. private _fogEnabled;
  32041. /**
  32042. * Gets or sets a boolean indicating if fog is enabled on this scene
  32043. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32044. * (Default is true)
  32045. */
  32046. fogEnabled: boolean;
  32047. private _fogMode;
  32048. /**
  32049. * Gets or sets the fog mode to use
  32050. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32051. * | mode | value |
  32052. * | --- | --- |
  32053. * | FOGMODE_NONE | 0 |
  32054. * | FOGMODE_EXP | 1 |
  32055. * | FOGMODE_EXP2 | 2 |
  32056. * | FOGMODE_LINEAR | 3 |
  32057. */
  32058. fogMode: number;
  32059. /**
  32060. * Gets or sets the fog color to use
  32061. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32062. * (Default is Color3(0.2, 0.2, 0.3))
  32063. */
  32064. fogColor: Color3;
  32065. /**
  32066. * Gets or sets the fog density to use
  32067. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32068. * (Default is 0.1)
  32069. */
  32070. fogDensity: number;
  32071. /**
  32072. * Gets or sets the fog start distance to use
  32073. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32074. * (Default is 0)
  32075. */
  32076. fogStart: number;
  32077. /**
  32078. * Gets or sets the fog end distance to use
  32079. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32080. * (Default is 1000)
  32081. */
  32082. fogEnd: number;
  32083. private _shadowsEnabled;
  32084. /**
  32085. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32086. */
  32087. shadowsEnabled: boolean;
  32088. private _lightsEnabled;
  32089. /**
  32090. * Gets or sets a boolean indicating if lights are enabled on this scene
  32091. */
  32092. lightsEnabled: boolean;
  32093. /** All of the active cameras added to this scene. */
  32094. activeCameras: Camera[];
  32095. private _activeCamera;
  32096. /** Gets or sets the current active camera */
  32097. activeCamera: Nullable<Camera>;
  32098. private _defaultMaterial;
  32099. /** The default material used on meshes when no material is affected */
  32100. /** The default material used on meshes when no material is affected */
  32101. defaultMaterial: Material;
  32102. private _texturesEnabled;
  32103. /**
  32104. * Gets or sets a boolean indicating if textures are enabled on this scene
  32105. */
  32106. texturesEnabled: boolean;
  32107. /**
  32108. * Gets or sets a boolean indicating if particles are enabled on this scene
  32109. */
  32110. particlesEnabled: boolean;
  32111. /**
  32112. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32113. */
  32114. spritesEnabled: boolean;
  32115. private _skeletonsEnabled;
  32116. /**
  32117. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32118. */
  32119. skeletonsEnabled: boolean;
  32120. /**
  32121. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32122. */
  32123. lensFlaresEnabled: boolean;
  32124. /**
  32125. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32126. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32127. */
  32128. collisionsEnabled: boolean;
  32129. private _collisionCoordinator;
  32130. /** @hidden */
  32131. readonly collisionCoordinator: ICollisionCoordinator;
  32132. /**
  32133. * Defines the gravity applied to this scene (used only for collisions)
  32134. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32135. */
  32136. gravity: Vector3;
  32137. /**
  32138. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32139. */
  32140. postProcessesEnabled: boolean;
  32141. /**
  32142. * The list of postprocesses added to the scene
  32143. */
  32144. postProcesses: PostProcess[];
  32145. /**
  32146. * Gets the current postprocess manager
  32147. */
  32148. postProcessManager: PostProcessManager;
  32149. /**
  32150. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32151. */
  32152. renderTargetsEnabled: boolean;
  32153. /**
  32154. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32155. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32156. */
  32157. dumpNextRenderTargets: boolean;
  32158. /**
  32159. * The list of user defined render targets added to the scene
  32160. */
  32161. customRenderTargets: RenderTargetTexture[];
  32162. /**
  32163. * Defines if texture loading must be delayed
  32164. * If true, textures will only be loaded when they need to be rendered
  32165. */
  32166. useDelayedTextureLoading: boolean;
  32167. /**
  32168. * Gets the list of meshes imported to the scene through SceneLoader
  32169. */
  32170. importedMeshesFiles: String[];
  32171. /**
  32172. * Gets or sets a boolean indicating if probes are enabled on this scene
  32173. */
  32174. probesEnabled: boolean;
  32175. /**
  32176. * Gets or sets the current offline provider to use to store scene data
  32177. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32178. */
  32179. offlineProvider: IOfflineProvider;
  32180. /**
  32181. * Gets or sets the action manager associated with the scene
  32182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32183. */
  32184. actionManager: AbstractActionManager;
  32185. private _meshesForIntersections;
  32186. /**
  32187. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32188. */
  32189. proceduralTexturesEnabled: boolean;
  32190. private _engine;
  32191. private _totalVertices;
  32192. /** @hidden */
  32193. _activeIndices: PerfCounter;
  32194. /** @hidden */
  32195. _activeParticles: PerfCounter;
  32196. /** @hidden */
  32197. _activeBones: PerfCounter;
  32198. private _animationRatio;
  32199. /** @hidden */
  32200. _animationTimeLast: number;
  32201. /** @hidden */
  32202. _animationTime: number;
  32203. /**
  32204. * Gets or sets a general scale for animation speed
  32205. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32206. */
  32207. animationTimeScale: number;
  32208. /** @hidden */
  32209. _cachedMaterial: Nullable<Material>;
  32210. /** @hidden */
  32211. _cachedEffect: Nullable<Effect>;
  32212. /** @hidden */
  32213. _cachedVisibility: Nullable<number>;
  32214. private _renderId;
  32215. private _frameId;
  32216. private _executeWhenReadyTimeoutId;
  32217. private _intermediateRendering;
  32218. private _viewUpdateFlag;
  32219. private _projectionUpdateFlag;
  32220. private _alternateViewUpdateFlag;
  32221. private _alternateProjectionUpdateFlag;
  32222. /** @hidden */
  32223. _toBeDisposed: Nullable<IDisposable>[];
  32224. private _activeRequests;
  32225. /** @hidden */
  32226. _pendingData: any[];
  32227. private _isDisposed;
  32228. /**
  32229. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32230. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32231. */
  32232. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32233. private _activeMeshes;
  32234. private _processedMaterials;
  32235. private _renderTargets;
  32236. /** @hidden */
  32237. _activeParticleSystems: SmartArray<IParticleSystem>;
  32238. private _activeSkeletons;
  32239. private _softwareSkinnedMeshes;
  32240. private _renderingManager;
  32241. /** @hidden */
  32242. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  32243. private _transformMatrix;
  32244. private _sceneUbo;
  32245. private _alternateSceneUbo;
  32246. private _pickWithRayInverseMatrix;
  32247. private _viewMatrix;
  32248. private _projectionMatrix;
  32249. private _alternateViewMatrix;
  32250. private _alternateProjectionMatrix;
  32251. private _alternateTransformMatrix;
  32252. private _useAlternateCameraConfiguration;
  32253. private _alternateRendering;
  32254. private _wheelEventName;
  32255. /** @hidden */
  32256. _forcedViewPosition: Nullable<Vector3>;
  32257. /** @hidden */
  32258. readonly _isAlternateRenderingEnabled: boolean;
  32259. private _frustumPlanes;
  32260. /**
  32261. * Gets the list of frustum planes (built from the active camera)
  32262. */
  32263. readonly frustumPlanes: Plane[];
  32264. /**
  32265. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32266. * This is useful if there are more lights that the maximum simulteanous authorized
  32267. */
  32268. requireLightSorting: boolean;
  32269. /** @hidden */
  32270. readonly useMaterialMeshMap: boolean;
  32271. /** @hidden */
  32272. readonly useClonedMeshhMap: boolean;
  32273. private _pointerOverMesh;
  32274. private _pickedDownMesh;
  32275. private _pickedUpMesh;
  32276. private _externalData;
  32277. private _uid;
  32278. /**
  32279. * @hidden
  32280. * Backing store of defined scene components.
  32281. */
  32282. _components: ISceneComponent[];
  32283. /**
  32284. * @hidden
  32285. * Backing store of defined scene components.
  32286. */
  32287. _serializableComponents: ISceneSerializableComponent[];
  32288. /**
  32289. * List of components to register on the next registration step.
  32290. */
  32291. private _transientComponents;
  32292. /**
  32293. * Registers the transient components if needed.
  32294. */
  32295. private _registerTransientComponents;
  32296. /**
  32297. * @hidden
  32298. * Add a component to the scene.
  32299. * Note that the ccomponent could be registered on th next frame if this is called after
  32300. * the register component stage.
  32301. * @param component Defines the component to add to the scene
  32302. */
  32303. _addComponent(component: ISceneComponent): void;
  32304. /**
  32305. * @hidden
  32306. * Gets a component from the scene.
  32307. * @param name defines the name of the component to retrieve
  32308. * @returns the component or null if not present
  32309. */
  32310. _getComponent(name: string): Nullable<ISceneComponent>;
  32311. /**
  32312. * @hidden
  32313. * Defines the actions happening before camera updates.
  32314. */
  32315. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32316. /**
  32317. * @hidden
  32318. * Defines the actions happening before clear the canvas.
  32319. */
  32320. _beforeClearStage: Stage<SimpleStageAction>;
  32321. /**
  32322. * @hidden
  32323. * Defines the actions when collecting render targets for the frame.
  32324. */
  32325. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32326. /**
  32327. * @hidden
  32328. * Defines the actions happening for one camera in the frame.
  32329. */
  32330. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32331. /**
  32332. * @hidden
  32333. * Defines the actions happening during the per mesh ready checks.
  32334. */
  32335. _isReadyForMeshStage: Stage<MeshStageAction>;
  32336. /**
  32337. * @hidden
  32338. * Defines the actions happening before evaluate active mesh checks.
  32339. */
  32340. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32341. /**
  32342. * @hidden
  32343. * Defines the actions happening during the evaluate sub mesh checks.
  32344. */
  32345. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32346. /**
  32347. * @hidden
  32348. * Defines the actions happening during the active mesh stage.
  32349. */
  32350. _activeMeshStage: Stage<ActiveMeshStageAction>;
  32351. /**
  32352. * @hidden
  32353. * Defines the actions happening during the per camera render target step.
  32354. */
  32355. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  32356. /**
  32357. * @hidden
  32358. * Defines the actions happening just before the active camera is drawing.
  32359. */
  32360. _beforeCameraDrawStage: Stage<CameraStageAction>;
  32361. /**
  32362. * @hidden
  32363. * Defines the actions happening just before a render target is drawing.
  32364. */
  32365. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32366. /**
  32367. * @hidden
  32368. * Defines the actions happening just before a rendering group is drawing.
  32369. */
  32370. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32371. /**
  32372. * @hidden
  32373. * Defines the actions happening just before a mesh is drawing.
  32374. */
  32375. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32376. /**
  32377. * @hidden
  32378. * Defines the actions happening just after a mesh has been drawn.
  32379. */
  32380. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32381. /**
  32382. * @hidden
  32383. * Defines the actions happening just after a rendering group has been drawn.
  32384. */
  32385. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32386. /**
  32387. * @hidden
  32388. * Defines the actions happening just after the active camera has been drawn.
  32389. */
  32390. _afterCameraDrawStage: Stage<CameraStageAction>;
  32391. /**
  32392. * @hidden
  32393. * Defines the actions happening just after a render target has been drawn.
  32394. */
  32395. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32396. /**
  32397. * @hidden
  32398. * Defines the actions happening just after rendering all cameras and computing intersections.
  32399. */
  32400. _afterRenderStage: Stage<SimpleStageAction>;
  32401. /**
  32402. * @hidden
  32403. * Defines the actions happening when a pointer move event happens.
  32404. */
  32405. _pointerMoveStage: Stage<PointerMoveStageAction>;
  32406. /**
  32407. * @hidden
  32408. * Defines the actions happening when a pointer down event happens.
  32409. */
  32410. _pointerDownStage: Stage<PointerUpDownStageAction>;
  32411. /**
  32412. * @hidden
  32413. * Defines the actions happening when a pointer up event happens.
  32414. */
  32415. _pointerUpStage: Stage<PointerUpDownStageAction>;
  32416. /**
  32417. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32418. */
  32419. private geometriesByUniqueId;
  32420. /**
  32421. * Creates a new Scene
  32422. * @param engine defines the engine to use to render this scene
  32423. * @param options defines the scene options
  32424. */
  32425. constructor(engine: Engine, options?: SceneOptions);
  32426. private _defaultMeshCandidates;
  32427. /**
  32428. * @hidden
  32429. */
  32430. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32431. private _defaultSubMeshCandidates;
  32432. /**
  32433. * @hidden
  32434. */
  32435. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32436. /**
  32437. * Sets the default candidate providers for the scene.
  32438. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32439. * and getCollidingSubMeshCandidates to their default function
  32440. */
  32441. setDefaultCandidateProviders(): void;
  32442. /**
  32443. * Gets the mesh that is currently under the pointer
  32444. */
  32445. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32446. /**
  32447. * Gets or sets the current on-screen X position of the pointer
  32448. */
  32449. pointerX: number;
  32450. /**
  32451. * Gets or sets the current on-screen Y position of the pointer
  32452. */
  32453. pointerY: number;
  32454. /**
  32455. * Gets the cached material (ie. the latest rendered one)
  32456. * @returns the cached material
  32457. */
  32458. getCachedMaterial(): Nullable<Material>;
  32459. /**
  32460. * Gets the cached effect (ie. the latest rendered one)
  32461. * @returns the cached effect
  32462. */
  32463. getCachedEffect(): Nullable<Effect>;
  32464. /**
  32465. * Gets the cached visibility state (ie. the latest rendered one)
  32466. * @returns the cached visibility state
  32467. */
  32468. getCachedVisibility(): Nullable<number>;
  32469. /**
  32470. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32471. * @param material defines the current material
  32472. * @param effect defines the current effect
  32473. * @param visibility defines the current visibility state
  32474. * @returns true if one parameter is not cached
  32475. */
  32476. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32477. /**
  32478. * Gets the engine associated with the scene
  32479. * @returns an Engine
  32480. */
  32481. getEngine(): Engine;
  32482. /**
  32483. * Gets the total number of vertices rendered per frame
  32484. * @returns the total number of vertices rendered per frame
  32485. */
  32486. getTotalVertices(): number;
  32487. /**
  32488. * Gets the performance counter for total vertices
  32489. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32490. */
  32491. readonly totalVerticesPerfCounter: PerfCounter;
  32492. /**
  32493. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32494. * @returns the total number of active indices rendered per frame
  32495. */
  32496. getActiveIndices(): number;
  32497. /**
  32498. * Gets the performance counter for active indices
  32499. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32500. */
  32501. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32502. /**
  32503. * Gets the total number of active particles rendered per frame
  32504. * @returns the total number of active particles rendered per frame
  32505. */
  32506. getActiveParticles(): number;
  32507. /**
  32508. * Gets the performance counter for active particles
  32509. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32510. */
  32511. readonly activeParticlesPerfCounter: PerfCounter;
  32512. /**
  32513. * Gets the total number of active bones rendered per frame
  32514. * @returns the total number of active bones rendered per frame
  32515. */
  32516. getActiveBones(): number;
  32517. /**
  32518. * Gets the performance counter for active bones
  32519. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32520. */
  32521. readonly activeBonesPerfCounter: PerfCounter;
  32522. /**
  32523. * Gets the array of active meshes
  32524. * @returns an array of AbstractMesh
  32525. */
  32526. getActiveMeshes(): SmartArray<AbstractMesh>;
  32527. /**
  32528. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32529. * @returns a number
  32530. */
  32531. getAnimationRatio(): number;
  32532. /**
  32533. * Gets an unique Id for the current render phase
  32534. * @returns a number
  32535. */
  32536. getRenderId(): number;
  32537. /**
  32538. * Gets an unique Id for the current frame
  32539. * @returns a number
  32540. */
  32541. getFrameId(): number;
  32542. /** Call this function if you want to manually increment the render Id*/
  32543. incrementRenderId(): void;
  32544. private _updatePointerPosition;
  32545. private _createUbo;
  32546. private _createAlternateUbo;
  32547. private _setRayOnPointerInfo;
  32548. /**
  32549. * Use this method to simulate a pointer move on a mesh
  32550. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32551. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32552. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32553. * @returns the current scene
  32554. */
  32555. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32556. private _processPointerMove;
  32557. private _checkPrePointerObservable;
  32558. /**
  32559. * Use this method to simulate a pointer down on a mesh
  32560. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32561. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32562. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32563. * @returns the current scene
  32564. */
  32565. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32566. private _processPointerDown;
  32567. /**
  32568. * Use this method to simulate a pointer up on a mesh
  32569. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32570. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32571. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32572. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32573. * @returns the current scene
  32574. */
  32575. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32576. private _processPointerUp;
  32577. /**
  32578. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32579. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32580. * @returns true if the pointer was captured
  32581. */
  32582. isPointerCaptured(pointerId?: number): boolean;
  32583. /** @hidden */
  32584. _isPointerSwiping(): boolean;
  32585. /**
  32586. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32587. * @param attachUp defines if you want to attach events to pointerup
  32588. * @param attachDown defines if you want to attach events to pointerdown
  32589. * @param attachMove defines if you want to attach events to pointermove
  32590. */
  32591. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32592. /** Detaches all event handlers*/
  32593. detachControl(): void;
  32594. /**
  32595. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32596. * Delay loaded resources are not taking in account
  32597. * @return true if all required resources are ready
  32598. */
  32599. isReady(): boolean;
  32600. /** Resets all cached information relative to material (including effect and visibility) */
  32601. resetCachedMaterial(): void;
  32602. /**
  32603. * Registers a function to be called before every frame render
  32604. * @param func defines the function to register
  32605. */
  32606. registerBeforeRender(func: () => void): void;
  32607. /**
  32608. * Unregisters a function called before every frame render
  32609. * @param func defines the function to unregister
  32610. */
  32611. unregisterBeforeRender(func: () => void): void;
  32612. /**
  32613. * Registers a function to be called after every frame render
  32614. * @param func defines the function to register
  32615. */
  32616. registerAfterRender(func: () => void): void;
  32617. /**
  32618. * Unregisters a function called after every frame render
  32619. * @param func defines the function to unregister
  32620. */
  32621. unregisterAfterRender(func: () => void): void;
  32622. private _executeOnceBeforeRender;
  32623. /**
  32624. * The provided function will run before render once and will be disposed afterwards.
  32625. * A timeout delay can be provided so that the function will be executed in N ms.
  32626. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32627. * @param func The function to be executed.
  32628. * @param timeout optional delay in ms
  32629. */
  32630. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32631. /** @hidden */
  32632. _addPendingData(data: any): void;
  32633. /** @hidden */
  32634. _removePendingData(data: any): void;
  32635. /**
  32636. * Returns the number of items waiting to be loaded
  32637. * @returns the number of items waiting to be loaded
  32638. */
  32639. getWaitingItemsCount(): number;
  32640. /**
  32641. * Returns a boolean indicating if the scene is still loading data
  32642. */
  32643. readonly isLoading: boolean;
  32644. /**
  32645. * Registers a function to be executed when the scene is ready
  32646. * @param {Function} func - the function to be executed
  32647. */
  32648. executeWhenReady(func: () => void): void;
  32649. /**
  32650. * Returns a promise that resolves when the scene is ready
  32651. * @returns A promise that resolves when the scene is ready
  32652. */
  32653. whenReadyAsync(): Promise<void>;
  32654. /** @hidden */
  32655. _checkIsReady(): void;
  32656. /**
  32657. * Gets all animatable attached to the scene
  32658. */
  32659. readonly animatables: Animatable[];
  32660. /**
  32661. * Resets the last animation time frame.
  32662. * Useful to override when animations start running when loading a scene for the first time.
  32663. */
  32664. resetLastAnimationTimeFrame(): void;
  32665. /** @hidden */
  32666. _switchToAlternateCameraConfiguration(active: boolean): void;
  32667. /**
  32668. * Gets the current view matrix
  32669. * @returns a Matrix
  32670. */
  32671. getViewMatrix(): Matrix;
  32672. /**
  32673. * Gets the current projection matrix
  32674. * @returns a Matrix
  32675. */
  32676. getProjectionMatrix(): Matrix;
  32677. /**
  32678. * Gets the current transform matrix
  32679. * @returns a Matrix made of View * Projection
  32680. */
  32681. getTransformMatrix(): Matrix;
  32682. /**
  32683. * Sets the current transform matrix
  32684. * @param view defines the View matrix to use
  32685. * @param projection defines the Projection matrix to use
  32686. */
  32687. setTransformMatrix(view: Matrix, projection: Matrix): void;
  32688. /** @hidden */
  32689. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  32690. /**
  32691. * Gets the uniform buffer used to store scene data
  32692. * @returns a UniformBuffer
  32693. */
  32694. getSceneUniformBuffer(): UniformBuffer;
  32695. /**
  32696. * Gets an unique (relatively to the current scene) Id
  32697. * @returns an unique number for the scene
  32698. */
  32699. getUniqueId(): number;
  32700. /**
  32701. * Add a mesh to the list of scene's meshes
  32702. * @param newMesh defines the mesh to add
  32703. * @param recursive if all child meshes should also be added to the scene
  32704. */
  32705. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32706. /**
  32707. * Remove a mesh for the list of scene's meshes
  32708. * @param toRemove defines the mesh to remove
  32709. * @param recursive if all child meshes should also be removed from the scene
  32710. * @returns the index where the mesh was in the mesh list
  32711. */
  32712. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32713. /**
  32714. * Add a transform node to the list of scene's transform nodes
  32715. * @param newTransformNode defines the transform node to add
  32716. */
  32717. addTransformNode(newTransformNode: TransformNode): void;
  32718. /**
  32719. * Remove a transform node for the list of scene's transform nodes
  32720. * @param toRemove defines the transform node to remove
  32721. * @returns the index where the transform node was in the transform node list
  32722. */
  32723. removeTransformNode(toRemove: TransformNode): number;
  32724. /**
  32725. * Remove a skeleton for the list of scene's skeletons
  32726. * @param toRemove defines the skeleton to remove
  32727. * @returns the index where the skeleton was in the skeleton list
  32728. */
  32729. removeSkeleton(toRemove: Skeleton): number;
  32730. /**
  32731. * Remove a morph target for the list of scene's morph targets
  32732. * @param toRemove defines the morph target to remove
  32733. * @returns the index where the morph target was in the morph target list
  32734. */
  32735. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32736. /**
  32737. * Remove a light for the list of scene's lights
  32738. * @param toRemove defines the light to remove
  32739. * @returns the index where the light was in the light list
  32740. */
  32741. removeLight(toRemove: Light): number;
  32742. /**
  32743. * Remove a camera for the list of scene's cameras
  32744. * @param toRemove defines the camera to remove
  32745. * @returns the index where the camera was in the camera list
  32746. */
  32747. removeCamera(toRemove: Camera): number;
  32748. /**
  32749. * Remove a particle system for the list of scene's particle systems
  32750. * @param toRemove defines the particle system to remove
  32751. * @returns the index where the particle system was in the particle system list
  32752. */
  32753. removeParticleSystem(toRemove: IParticleSystem): number;
  32754. /**
  32755. * Remove a animation for the list of scene's animations
  32756. * @param toRemove defines the animation to remove
  32757. * @returns the index where the animation was in the animation list
  32758. */
  32759. removeAnimation(toRemove: Animation): number;
  32760. /**
  32761. * Removes the given animation group from this scene.
  32762. * @param toRemove The animation group to remove
  32763. * @returns The index of the removed animation group
  32764. */
  32765. removeAnimationGroup(toRemove: AnimationGroup): number;
  32766. /**
  32767. * Removes the given multi-material from this scene.
  32768. * @param toRemove The multi-material to remove
  32769. * @returns The index of the removed multi-material
  32770. */
  32771. removeMultiMaterial(toRemove: MultiMaterial): number;
  32772. /**
  32773. * Removes the given material from this scene.
  32774. * @param toRemove The material to remove
  32775. * @returns The index of the removed material
  32776. */
  32777. removeMaterial(toRemove: Material): number;
  32778. /**
  32779. * Removes the given action manager from this scene.
  32780. * @param toRemove The action manager to remove
  32781. * @returns The index of the removed action manager
  32782. */
  32783. removeActionManager(toRemove: AbstractActionManager): number;
  32784. /**
  32785. * Removes the given texture from this scene.
  32786. * @param toRemove The texture to remove
  32787. * @returns The index of the removed texture
  32788. */
  32789. removeTexture(toRemove: BaseTexture): number;
  32790. /**
  32791. * Adds the given light to this scene
  32792. * @param newLight The light to add
  32793. */
  32794. addLight(newLight: Light): void;
  32795. /**
  32796. * Sorts the list list based on light priorities
  32797. */
  32798. sortLightsByPriority(): void;
  32799. /**
  32800. * Adds the given camera to this scene
  32801. * @param newCamera The camera to add
  32802. */
  32803. addCamera(newCamera: Camera): void;
  32804. /**
  32805. * Adds the given skeleton to this scene
  32806. * @param newSkeleton The skeleton to add
  32807. */
  32808. addSkeleton(newSkeleton: Skeleton): void;
  32809. /**
  32810. * Adds the given particle system to this scene
  32811. * @param newParticleSystem The particle system to add
  32812. */
  32813. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32814. /**
  32815. * Adds the given animation to this scene
  32816. * @param newAnimation The animation to add
  32817. */
  32818. addAnimation(newAnimation: Animation): void;
  32819. /**
  32820. * Adds the given animation group to this scene.
  32821. * @param newAnimationGroup The animation group to add
  32822. */
  32823. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32824. /**
  32825. * Adds the given multi-material to this scene
  32826. * @param newMultiMaterial The multi-material to add
  32827. */
  32828. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32829. /**
  32830. * Adds the given material to this scene
  32831. * @param newMaterial The material to add
  32832. */
  32833. addMaterial(newMaterial: Material): void;
  32834. /**
  32835. * Adds the given morph target to this scene
  32836. * @param newMorphTargetManager The morph target to add
  32837. */
  32838. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32839. /**
  32840. * Adds the given geometry to this scene
  32841. * @param newGeometry The geometry to add
  32842. */
  32843. addGeometry(newGeometry: Geometry): void;
  32844. /**
  32845. * Adds the given action manager to this scene
  32846. * @param newActionManager The action manager to add
  32847. */
  32848. addActionManager(newActionManager: AbstractActionManager): void;
  32849. /**
  32850. * Adds the given texture to this scene.
  32851. * @param newTexture The texture to add
  32852. */
  32853. addTexture(newTexture: BaseTexture): void;
  32854. /**
  32855. * Switch active camera
  32856. * @param newCamera defines the new active camera
  32857. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32858. */
  32859. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32860. /**
  32861. * sets the active camera of the scene using its ID
  32862. * @param id defines the camera's ID
  32863. * @return the new active camera or null if none found.
  32864. */
  32865. setActiveCameraByID(id: string): Nullable<Camera>;
  32866. /**
  32867. * sets the active camera of the scene using its name
  32868. * @param name defines the camera's name
  32869. * @returns the new active camera or null if none found.
  32870. */
  32871. setActiveCameraByName(name: string): Nullable<Camera>;
  32872. /**
  32873. * get an animation group using its name
  32874. * @param name defines the material's name
  32875. * @return the animation group or null if none found.
  32876. */
  32877. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32878. /**
  32879. * get a material using its id
  32880. * @param id defines the material's ID
  32881. * @return the material or null if none found.
  32882. */
  32883. getMaterialByID(id: string): Nullable<Material>;
  32884. /**
  32885. * Gets a material using its name
  32886. * @param name defines the material's name
  32887. * @return the material or null if none found.
  32888. */
  32889. getMaterialByName(name: string): Nullable<Material>;
  32890. /**
  32891. * Gets a camera using its id
  32892. * @param id defines the id to look for
  32893. * @returns the camera or null if not found
  32894. */
  32895. getCameraByID(id: string): Nullable<Camera>;
  32896. /**
  32897. * Gets a camera using its unique id
  32898. * @param uniqueId defines the unique id to look for
  32899. * @returns the camera or null if not found
  32900. */
  32901. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32902. /**
  32903. * Gets a camera using its name
  32904. * @param name defines the camera's name
  32905. * @return the camera or null if none found.
  32906. */
  32907. getCameraByName(name: string): Nullable<Camera>;
  32908. /**
  32909. * Gets a bone using its id
  32910. * @param id defines the bone's id
  32911. * @return the bone or null if not found
  32912. */
  32913. getBoneByID(id: string): Nullable<Bone>;
  32914. /**
  32915. * Gets a bone using its id
  32916. * @param name defines the bone's name
  32917. * @return the bone or null if not found
  32918. */
  32919. getBoneByName(name: string): Nullable<Bone>;
  32920. /**
  32921. * Gets a light node using its name
  32922. * @param name defines the the light's name
  32923. * @return the light or null if none found.
  32924. */
  32925. getLightByName(name: string): Nullable<Light>;
  32926. /**
  32927. * Gets a light node using its id
  32928. * @param id defines the light's id
  32929. * @return the light or null if none found.
  32930. */
  32931. getLightByID(id: string): Nullable<Light>;
  32932. /**
  32933. * Gets a light node using its scene-generated unique ID
  32934. * @param uniqueId defines the light's unique id
  32935. * @return the light or null if none found.
  32936. */
  32937. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32938. /**
  32939. * Gets a particle system by id
  32940. * @param id defines the particle system id
  32941. * @return the corresponding system or null if none found
  32942. */
  32943. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32944. /**
  32945. * Gets a geometry using its ID
  32946. * @param id defines the geometry's id
  32947. * @return the geometry or null if none found.
  32948. */
  32949. getGeometryByID(id: string): Nullable<Geometry>;
  32950. private _getGeometryByUniqueID;
  32951. /**
  32952. * Add a new geometry to this scene
  32953. * @param geometry defines the geometry to be added to the scene.
  32954. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32955. * @return a boolean defining if the geometry was added or not
  32956. */
  32957. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32958. /**
  32959. * Removes an existing geometry
  32960. * @param geometry defines the geometry to be removed from the scene
  32961. * @return a boolean defining if the geometry was removed or not
  32962. */
  32963. removeGeometry(geometry: Geometry): boolean;
  32964. /**
  32965. * Gets the list of geometries attached to the scene
  32966. * @returns an array of Geometry
  32967. */
  32968. getGeometries(): Geometry[];
  32969. /**
  32970. * Gets the first added mesh found of a given ID
  32971. * @param id defines the id to search for
  32972. * @return the mesh found or null if not found at all
  32973. */
  32974. getMeshByID(id: string): Nullable<AbstractMesh>;
  32975. /**
  32976. * Gets a list of meshes using their id
  32977. * @param id defines the id to search for
  32978. * @returns a list of meshes
  32979. */
  32980. getMeshesByID(id: string): Array<AbstractMesh>;
  32981. /**
  32982. * Gets the first added transform node found of a given ID
  32983. * @param id defines the id to search for
  32984. * @return the found transform node or null if not found at all.
  32985. */
  32986. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32987. /**
  32988. * Gets a list of transform nodes using their id
  32989. * @param id defines the id to search for
  32990. * @returns a list of transform nodes
  32991. */
  32992. getTransformNodesByID(id: string): Array<TransformNode>;
  32993. /**
  32994. * Gets a mesh with its auto-generated unique id
  32995. * @param uniqueId defines the unique id to search for
  32996. * @return the found mesh or null if not found at all.
  32997. */
  32998. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32999. /**
  33000. * Gets a the last added mesh using a given id
  33001. * @param id defines the id to search for
  33002. * @return the found mesh or null if not found at all.
  33003. */
  33004. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33005. /**
  33006. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33007. * @param id defines the id to search for
  33008. * @return the found node or null if not found at all
  33009. */
  33010. getLastEntryByID(id: string): Nullable<Node>;
  33011. /**
  33012. * Gets a node (Mesh, Camera, Light) using a given id
  33013. * @param id defines the id to search for
  33014. * @return the found node or null if not found at all
  33015. */
  33016. getNodeByID(id: string): Nullable<Node>;
  33017. /**
  33018. * Gets a node (Mesh, Camera, Light) using a given name
  33019. * @param name defines the name to search for
  33020. * @return the found node or null if not found at all.
  33021. */
  33022. getNodeByName(name: string): Nullable<Node>;
  33023. /**
  33024. * Gets a mesh using a given name
  33025. * @param name defines the name to search for
  33026. * @return the found mesh or null if not found at all.
  33027. */
  33028. getMeshByName(name: string): Nullable<AbstractMesh>;
  33029. /**
  33030. * Gets a transform node using a given name
  33031. * @param name defines the name to search for
  33032. * @return the found transform node or null if not found at all.
  33033. */
  33034. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33035. /**
  33036. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33037. * @param id defines the id to search for
  33038. * @return the found skeleton or null if not found at all.
  33039. */
  33040. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33041. /**
  33042. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33043. * @param id defines the id to search for
  33044. * @return the found skeleton or null if not found at all.
  33045. */
  33046. getSkeletonById(id: string): Nullable<Skeleton>;
  33047. /**
  33048. * Gets a skeleton using a given name
  33049. * @param name defines the name to search for
  33050. * @return the found skeleton or null if not found at all.
  33051. */
  33052. getSkeletonByName(name: string): Nullable<Skeleton>;
  33053. /**
  33054. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33055. * @param id defines the id to search for
  33056. * @return the found morph target manager or null if not found at all.
  33057. */
  33058. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33059. /**
  33060. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33061. * @param id defines the id to search for
  33062. * @return the found morph target or null if not found at all.
  33063. */
  33064. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33065. /**
  33066. * Gets a boolean indicating if the given mesh is active
  33067. * @param mesh defines the mesh to look for
  33068. * @returns true if the mesh is in the active list
  33069. */
  33070. isActiveMesh(mesh: AbstractMesh): boolean;
  33071. /**
  33072. * Return a unique id as a string which can serve as an identifier for the scene
  33073. */
  33074. readonly uid: string;
  33075. /**
  33076. * Add an externaly attached data from its key.
  33077. * This method call will fail and return false, if such key already exists.
  33078. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33079. * @param key the unique key that identifies the data
  33080. * @param data the data object to associate to the key for this Engine instance
  33081. * @return true if no such key were already present and the data was added successfully, false otherwise
  33082. */
  33083. addExternalData<T>(key: string, data: T): boolean;
  33084. /**
  33085. * Get an externaly attached data from its key
  33086. * @param key the unique key that identifies the data
  33087. * @return the associated data, if present (can be null), or undefined if not present
  33088. */
  33089. getExternalData<T>(key: string): Nullable<T>;
  33090. /**
  33091. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33092. * @param key the unique key that identifies the data
  33093. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33094. * @return the associated data, can be null if the factory returned null.
  33095. */
  33096. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33097. /**
  33098. * Remove an externaly attached data from the Engine instance
  33099. * @param key the unique key that identifies the data
  33100. * @return true if the data was successfully removed, false if it doesn't exist
  33101. */
  33102. removeExternalData(key: string): boolean;
  33103. private _evaluateSubMesh;
  33104. /**
  33105. * Clear the processed materials smart array preventing retention point in material dispose.
  33106. */
  33107. freeProcessedMaterials(): void;
  33108. private _preventFreeActiveMeshesAndRenderingGroups;
  33109. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33110. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33111. * when disposing several meshes in a row or a hierarchy of meshes.
  33112. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33113. */
  33114. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33115. /**
  33116. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33117. */
  33118. freeActiveMeshes(): void;
  33119. /**
  33120. * Clear the info related to rendering groups preventing retention points during dispose.
  33121. */
  33122. freeRenderingGroups(): void;
  33123. /** @hidden */
  33124. _isInIntermediateRendering(): boolean;
  33125. /**
  33126. * Lambda returning the list of potentially active meshes.
  33127. */
  33128. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33129. /**
  33130. * Lambda returning the list of potentially active sub meshes.
  33131. */
  33132. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33133. /**
  33134. * Lambda returning the list of potentially intersecting sub meshes.
  33135. */
  33136. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33137. /**
  33138. * Lambda returning the list of potentially colliding sub meshes.
  33139. */
  33140. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33141. private _activeMeshesFrozen;
  33142. /**
  33143. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33144. * @returns the current scene
  33145. */
  33146. freezeActiveMeshes(): Scene;
  33147. /**
  33148. * Use this function to restart evaluating active meshes on every frame
  33149. * @returns the current scene
  33150. */
  33151. unfreezeActiveMeshes(): Scene;
  33152. private _evaluateActiveMeshes;
  33153. private _activeMesh;
  33154. /**
  33155. * Update the transform matrix to update from the current active camera
  33156. * @param force defines a boolean used to force the update even if cache is up to date
  33157. */
  33158. updateTransformMatrix(force?: boolean): void;
  33159. /**
  33160. * 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)
  33161. * @param alternateCamera defines the camera to use
  33162. */
  33163. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  33164. /** @hidden */
  33165. _allowPostProcessClearColor: boolean;
  33166. private _renderForCamera;
  33167. private _processSubCameras;
  33168. private _checkIntersections;
  33169. /** @hidden */
  33170. _advancePhysicsEngineStep(step: number): void;
  33171. /**
  33172. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33173. */
  33174. getDeterministicFrameTime: () => number;
  33175. /**
  33176. * Render the scene
  33177. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33178. */
  33179. render(updateCameras?: boolean): void;
  33180. /**
  33181. * Freeze all materials
  33182. * A frozen material will not be updatable but should be faster to render
  33183. */
  33184. freezeMaterials(): void;
  33185. /**
  33186. * Unfreeze all materials
  33187. * A frozen material will not be updatable but should be faster to render
  33188. */
  33189. unfreezeMaterials(): void;
  33190. /**
  33191. * Releases all held ressources
  33192. */
  33193. dispose(): void;
  33194. /**
  33195. * Gets if the scene is already disposed
  33196. */
  33197. readonly isDisposed: boolean;
  33198. /**
  33199. * Call this function to reduce memory footprint of the scene.
  33200. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33201. */
  33202. clearCachedVertexData(): void;
  33203. /**
  33204. * This function will remove the local cached buffer data from texture.
  33205. * It will save memory but will prevent the texture from being rebuilt
  33206. */
  33207. cleanCachedTextureBuffer(): void;
  33208. /**
  33209. * Get the world extend vectors with an optional filter
  33210. *
  33211. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33212. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33213. */
  33214. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33215. min: Vector3;
  33216. max: Vector3;
  33217. };
  33218. /**
  33219. * Creates a ray that can be used to pick in the scene
  33220. * @param x defines the x coordinate of the origin (on-screen)
  33221. * @param y defines the y coordinate of the origin (on-screen)
  33222. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33223. * @param camera defines the camera to use for the picking
  33224. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33225. * @returns a Ray
  33226. */
  33227. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33228. /**
  33229. * Creates a ray that can be used to pick in the scene
  33230. * @param x defines the x coordinate of the origin (on-screen)
  33231. * @param y defines the y coordinate of the origin (on-screen)
  33232. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33233. * @param result defines the ray where to store the picking ray
  33234. * @param camera defines the camera to use for the picking
  33235. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33236. * @returns the current scene
  33237. */
  33238. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33239. /**
  33240. * Creates a ray that can be used to pick in the scene
  33241. * @param x defines the x coordinate of the origin (on-screen)
  33242. * @param y defines the y coordinate of the origin (on-screen)
  33243. * @param camera defines the camera to use for the picking
  33244. * @returns a Ray
  33245. */
  33246. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33247. /**
  33248. * Creates a ray that can be used to pick in the scene
  33249. * @param x defines the x coordinate of the origin (on-screen)
  33250. * @param y defines the y coordinate of the origin (on-screen)
  33251. * @param result defines the ray where to store the picking ray
  33252. * @param camera defines the camera to use for the picking
  33253. * @returns the current scene
  33254. */
  33255. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33256. private _internalPick;
  33257. private _internalMultiPick;
  33258. private _tempPickingRay;
  33259. /** Launch a ray to try to pick a mesh in the scene
  33260. * @param x position on screen
  33261. * @param y position on screen
  33262. * @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
  33263. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33264. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33265. * @returns a PickingInfo
  33266. */
  33267. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  33268. private _cachedRayForTransform;
  33269. /** Use the given ray to pick a mesh in the scene
  33270. * @param ray The ray to use to pick meshes
  33271. * @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
  33272. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33273. * @returns a PickingInfo
  33274. */
  33275. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  33276. /**
  33277. * Launch a ray to try to pick a mesh in the scene
  33278. * @param x X position on screen
  33279. * @param y Y position on screen
  33280. * @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
  33281. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33282. * @returns an array of PickingInfo
  33283. */
  33284. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  33285. /**
  33286. * Launch a ray to try to pick a mesh in the scene
  33287. * @param ray Ray to use
  33288. * @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
  33289. * @returns an array of PickingInfo
  33290. */
  33291. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  33292. /**
  33293. * Force the value of meshUnderPointer
  33294. * @param mesh defines the mesh to use
  33295. */
  33296. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33297. /**
  33298. * Gets the mesh under the pointer
  33299. * @returns a Mesh or null if no mesh is under the pointer
  33300. */
  33301. getPointerOverMesh(): Nullable<AbstractMesh>;
  33302. /** @hidden */
  33303. _rebuildGeometries(): void;
  33304. /** @hidden */
  33305. _rebuildTextures(): void;
  33306. private _getByTags;
  33307. /**
  33308. * Get a list of meshes by tags
  33309. * @param tagsQuery defines the tags query to use
  33310. * @param forEach defines a predicate used to filter results
  33311. * @returns an array of Mesh
  33312. */
  33313. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33314. /**
  33315. * Get a list of cameras by tags
  33316. * @param tagsQuery defines the tags query to use
  33317. * @param forEach defines a predicate used to filter results
  33318. * @returns an array of Camera
  33319. */
  33320. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33321. /**
  33322. * Get a list of lights by tags
  33323. * @param tagsQuery defines the tags query to use
  33324. * @param forEach defines a predicate used to filter results
  33325. * @returns an array of Light
  33326. */
  33327. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33328. /**
  33329. * Get a list of materials by tags
  33330. * @param tagsQuery defines the tags query to use
  33331. * @param forEach defines a predicate used to filter results
  33332. * @returns an array of Material
  33333. */
  33334. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33335. /**
  33336. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33337. * This allowed control for front to back rendering or reversly depending of the special needs.
  33338. *
  33339. * @param renderingGroupId The rendering group id corresponding to its index
  33340. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33341. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33342. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33343. */
  33344. 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;
  33345. /**
  33346. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33347. *
  33348. * @param renderingGroupId The rendering group id corresponding to its index
  33349. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33350. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33351. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33352. */
  33353. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33354. /**
  33355. * Gets the current auto clear configuration for one rendering group of the rendering
  33356. * manager.
  33357. * @param index the rendering group index to get the information for
  33358. * @returns The auto clear setup for the requested rendering group
  33359. */
  33360. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33361. private _blockMaterialDirtyMechanism;
  33362. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33363. blockMaterialDirtyMechanism: boolean;
  33364. /**
  33365. * Will flag all materials as dirty to trigger new shader compilation
  33366. * @param flag defines the flag used to specify which material part must be marked as dirty
  33367. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33368. */
  33369. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33370. /** @hidden */
  33371. _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;
  33372. /** @hidden */
  33373. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33374. }
  33375. }
  33376. declare module "babylonjs/assetContainer" {
  33377. import { AbstractScene } from "babylonjs/abstractScene";
  33378. import { Scene } from "babylonjs/scene";
  33379. import { Mesh } from "babylonjs/Meshes/mesh";
  33380. /**
  33381. * Set of assets to keep when moving a scene into an asset container.
  33382. */
  33383. export class KeepAssets extends AbstractScene {
  33384. }
  33385. /**
  33386. * Container with a set of assets that can be added or removed from a scene.
  33387. */
  33388. export class AssetContainer extends AbstractScene {
  33389. /**
  33390. * The scene the AssetContainer belongs to.
  33391. */
  33392. scene: Scene;
  33393. /**
  33394. * Instantiates an AssetContainer.
  33395. * @param scene The scene the AssetContainer belongs to.
  33396. */
  33397. constructor(scene: Scene);
  33398. /**
  33399. * Adds all the assets from the container to the scene.
  33400. */
  33401. addAllToScene(): void;
  33402. /**
  33403. * Removes all the assets in the container from the scene
  33404. */
  33405. removeAllFromScene(): void;
  33406. /**
  33407. * Disposes all the assets in the container
  33408. */
  33409. dispose(): void;
  33410. private _moveAssets;
  33411. /**
  33412. * Removes all the assets contained in the scene and adds them to the container.
  33413. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33414. */
  33415. moveAllFromScene(keepAssets?: KeepAssets): void;
  33416. /**
  33417. * 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.
  33418. * @returns the root mesh
  33419. */
  33420. createRootMesh(): Mesh;
  33421. }
  33422. }
  33423. declare module "babylonjs/abstractScene" {
  33424. import { Scene } from "babylonjs/scene";
  33425. import { Nullable } from "babylonjs/types";
  33426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33428. import { Geometry } from "babylonjs/Meshes/geometry";
  33429. import { Skeleton } from "babylonjs/Bones/skeleton";
  33430. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33431. import { AssetContainer } from "babylonjs/assetContainer";
  33432. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33433. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33434. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33435. import { Material } from "babylonjs/Materials/material";
  33436. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33437. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33438. import { Camera } from "babylonjs/Cameras/camera";
  33439. import { Light } from "babylonjs/Lights/light";
  33440. import { Node } from "babylonjs/node";
  33441. import { Animation } from "babylonjs/Animations/animation";
  33442. /**
  33443. * Defines how the parser contract is defined.
  33444. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33445. */
  33446. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33447. /**
  33448. * Defines how the individual parser contract is defined.
  33449. * These parser can parse an individual asset
  33450. */
  33451. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33452. /**
  33453. * Base class of the scene acting as a container for the different elements composing a scene.
  33454. * This class is dynamically extended by the different components of the scene increasing
  33455. * flexibility and reducing coupling
  33456. */
  33457. export abstract class AbstractScene {
  33458. /**
  33459. * Stores the list of available parsers in the application.
  33460. */
  33461. private static _BabylonFileParsers;
  33462. /**
  33463. * Stores the list of available individual parsers in the application.
  33464. */
  33465. private static _IndividualBabylonFileParsers;
  33466. /**
  33467. * Adds a parser in the list of available ones
  33468. * @param name Defines the name of the parser
  33469. * @param parser Defines the parser to add
  33470. */
  33471. static AddParser(name: string, parser: BabylonFileParser): void;
  33472. /**
  33473. * Gets a general parser from the list of avaialble ones
  33474. * @param name Defines the name of the parser
  33475. * @returns the requested parser or null
  33476. */
  33477. static GetParser(name: string): Nullable<BabylonFileParser>;
  33478. /**
  33479. * Adds n individual parser in the list of available ones
  33480. * @param name Defines the name of the parser
  33481. * @param parser Defines the parser to add
  33482. */
  33483. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33484. /**
  33485. * Gets an individual parser from the list of avaialble ones
  33486. * @param name Defines the name of the parser
  33487. * @returns the requested parser or null
  33488. */
  33489. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33490. /**
  33491. * Parser json data and populate both a scene and its associated container object
  33492. * @param jsonData Defines the data to parse
  33493. * @param scene Defines the scene to parse the data for
  33494. * @param container Defines the container attached to the parsing sequence
  33495. * @param rootUrl Defines the root url of the data
  33496. */
  33497. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33498. /**
  33499. * Gets the list of root nodes (ie. nodes with no parent)
  33500. */
  33501. rootNodes: Node[];
  33502. /** All of the cameras added to this scene
  33503. * @see http://doc.babylonjs.com/babylon101/cameras
  33504. */
  33505. cameras: Camera[];
  33506. /**
  33507. * All of the lights added to this scene
  33508. * @see http://doc.babylonjs.com/babylon101/lights
  33509. */
  33510. lights: Light[];
  33511. /**
  33512. * All of the (abstract) meshes added to this scene
  33513. */
  33514. meshes: AbstractMesh[];
  33515. /**
  33516. * The list of skeletons added to the scene
  33517. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33518. */
  33519. skeletons: Skeleton[];
  33520. /**
  33521. * All of the particle systems added to this scene
  33522. * @see http://doc.babylonjs.com/babylon101/particles
  33523. */
  33524. particleSystems: IParticleSystem[];
  33525. /**
  33526. * Gets a list of Animations associated with the scene
  33527. */
  33528. animations: Animation[];
  33529. /**
  33530. * All of the animation groups added to this scene
  33531. * @see http://doc.babylonjs.com/how_to/group
  33532. */
  33533. animationGroups: AnimationGroup[];
  33534. /**
  33535. * All of the multi-materials added to this scene
  33536. * @see http://doc.babylonjs.com/how_to/multi_materials
  33537. */
  33538. multiMaterials: MultiMaterial[];
  33539. /**
  33540. * All of the materials added to this scene
  33541. * In the context of a Scene, it is not supposed to be modified manually.
  33542. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33543. * Note also that the order of the Material wihin the array is not significant and might change.
  33544. * @see http://doc.babylonjs.com/babylon101/materials
  33545. */
  33546. materials: Material[];
  33547. /**
  33548. * The list of morph target managers added to the scene
  33549. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33550. */
  33551. morphTargetManagers: MorphTargetManager[];
  33552. /**
  33553. * The list of geometries used in the scene.
  33554. */
  33555. geometries: Geometry[];
  33556. /**
  33557. * All of the tranform nodes added to this scene
  33558. * In the context of a Scene, it is not supposed to be modified manually.
  33559. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33560. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33561. * @see http://doc.babylonjs.com/how_to/transformnode
  33562. */
  33563. transformNodes: TransformNode[];
  33564. /**
  33565. * ActionManagers available on the scene.
  33566. */
  33567. actionManagers: AbstractActionManager[];
  33568. /**
  33569. * Textures to keep.
  33570. */
  33571. textures: BaseTexture[];
  33572. }
  33573. }
  33574. declare module "babylonjs/Audio/sound" {
  33575. import { Observable } from "babylonjs/Misc/observable";
  33576. import { Vector3 } from "babylonjs/Maths/math";
  33577. import { Nullable } from "babylonjs/types";
  33578. import { Scene } from "babylonjs/scene";
  33579. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33580. /**
  33581. * Defines a sound that can be played in the application.
  33582. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33584. */
  33585. export class Sound {
  33586. /**
  33587. * The name of the sound in the scene.
  33588. */
  33589. name: string;
  33590. /**
  33591. * Does the sound autoplay once loaded.
  33592. */
  33593. autoplay: boolean;
  33594. /**
  33595. * Does the sound loop after it finishes playing once.
  33596. */
  33597. loop: boolean;
  33598. /**
  33599. * Does the sound use a custom attenuation curve to simulate the falloff
  33600. * happening when the source gets further away from the camera.
  33601. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33602. */
  33603. useCustomAttenuation: boolean;
  33604. /**
  33605. * The sound track id this sound belongs to.
  33606. */
  33607. soundTrackId: number;
  33608. /**
  33609. * Is this sound currently played.
  33610. */
  33611. isPlaying: boolean;
  33612. /**
  33613. * Is this sound currently paused.
  33614. */
  33615. isPaused: boolean;
  33616. /**
  33617. * Does this sound enables spatial sound.
  33618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33619. */
  33620. spatialSound: boolean;
  33621. /**
  33622. * Define the reference distance the sound should be heard perfectly.
  33623. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33624. */
  33625. refDistance: number;
  33626. /**
  33627. * Define the roll off factor of spatial sounds.
  33628. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33629. */
  33630. rolloffFactor: number;
  33631. /**
  33632. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33633. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33634. */
  33635. maxDistance: number;
  33636. /**
  33637. * Define the distance attenuation model the sound will follow.
  33638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33639. */
  33640. distanceModel: string;
  33641. /**
  33642. * @hidden
  33643. * Back Compat
  33644. **/
  33645. onended: () => any;
  33646. /**
  33647. * Observable event when the current playing sound finishes.
  33648. */
  33649. onEndedObservable: Observable<Sound>;
  33650. private _panningModel;
  33651. private _playbackRate;
  33652. private _streaming;
  33653. private _startTime;
  33654. private _startOffset;
  33655. private _position;
  33656. /** @hidden */
  33657. _positionInEmitterSpace: boolean;
  33658. private _localDirection;
  33659. private _volume;
  33660. private _isReadyToPlay;
  33661. private _isDirectional;
  33662. private _readyToPlayCallback;
  33663. private _audioBuffer;
  33664. private _soundSource;
  33665. private _streamingSource;
  33666. private _soundPanner;
  33667. private _soundGain;
  33668. private _inputAudioNode;
  33669. private _outputAudioNode;
  33670. private _coneInnerAngle;
  33671. private _coneOuterAngle;
  33672. private _coneOuterGain;
  33673. private _scene;
  33674. private _connectedTransformNode;
  33675. private _customAttenuationFunction;
  33676. private _registerFunc;
  33677. private _isOutputConnected;
  33678. private _htmlAudioElement;
  33679. private _urlType;
  33680. /** @hidden */
  33681. static _SceneComponentInitialization: (scene: Scene) => void;
  33682. /**
  33683. * Create a sound and attach it to a scene
  33684. * @param name Name of your sound
  33685. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33686. * @param scene defines the scene the sound belongs to
  33687. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33688. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33689. */
  33690. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33691. /**
  33692. * Release the sound and its associated resources
  33693. */
  33694. dispose(): void;
  33695. /**
  33696. * Gets if the sounds is ready to be played or not.
  33697. * @returns true if ready, otherwise false
  33698. */
  33699. isReady(): boolean;
  33700. private _soundLoaded;
  33701. /**
  33702. * Sets the data of the sound from an audiobuffer
  33703. * @param audioBuffer The audioBuffer containing the data
  33704. */
  33705. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33706. /**
  33707. * Updates the current sounds options such as maxdistance, loop...
  33708. * @param options A JSON object containing values named as the object properties
  33709. */
  33710. updateOptions(options: any): void;
  33711. private _createSpatialParameters;
  33712. private _updateSpatialParameters;
  33713. /**
  33714. * Switch the panning model to HRTF:
  33715. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33716. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33717. */
  33718. switchPanningModelToHRTF(): void;
  33719. /**
  33720. * Switch the panning model to Equal Power:
  33721. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33722. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33723. */
  33724. switchPanningModelToEqualPower(): void;
  33725. private _switchPanningModel;
  33726. /**
  33727. * Connect this sound to a sound track audio node like gain...
  33728. * @param soundTrackAudioNode the sound track audio node to connect to
  33729. */
  33730. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33731. /**
  33732. * Transform this sound into a directional source
  33733. * @param coneInnerAngle Size of the inner cone in degree
  33734. * @param coneOuterAngle Size of the outer cone in degree
  33735. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33736. */
  33737. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33738. /**
  33739. * Gets or sets the inner angle for the directional cone.
  33740. */
  33741. /**
  33742. * Gets or sets the inner angle for the directional cone.
  33743. */
  33744. directionalConeInnerAngle: number;
  33745. /**
  33746. * Gets or sets the outer angle for the directional cone.
  33747. */
  33748. /**
  33749. * Gets or sets the outer angle for the directional cone.
  33750. */
  33751. directionalConeOuterAngle: number;
  33752. /**
  33753. * Sets the position of the emitter if spatial sound is enabled
  33754. * @param newPosition Defines the new posisiton
  33755. */
  33756. setPosition(newPosition: Vector3): void;
  33757. /**
  33758. * Sets the local direction of the emitter if spatial sound is enabled
  33759. * @param newLocalDirection Defines the new local direction
  33760. */
  33761. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33762. private _updateDirection;
  33763. /** @hidden */
  33764. updateDistanceFromListener(): void;
  33765. /**
  33766. * Sets a new custom attenuation function for the sound.
  33767. * @param callback Defines the function used for the attenuation
  33768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33769. */
  33770. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33771. /**
  33772. * Play the sound
  33773. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33774. * @param offset (optional) Start the sound setting it at a specific time
  33775. */
  33776. play(time?: number, offset?: number): void;
  33777. private _onended;
  33778. /**
  33779. * Stop the sound
  33780. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33781. */
  33782. stop(time?: number): void;
  33783. /**
  33784. * Put the sound in pause
  33785. */
  33786. pause(): void;
  33787. /**
  33788. * Sets a dedicated volume for this sounds
  33789. * @param newVolume Define the new volume of the sound
  33790. * @param time Define in how long the sound should be at this value
  33791. */
  33792. setVolume(newVolume: number, time?: number): void;
  33793. /**
  33794. * Set the sound play back rate
  33795. * @param newPlaybackRate Define the playback rate the sound should be played at
  33796. */
  33797. setPlaybackRate(newPlaybackRate: number): void;
  33798. /**
  33799. * Gets the volume of the sound.
  33800. * @returns the volume of the sound
  33801. */
  33802. getVolume(): number;
  33803. /**
  33804. * Attach the sound to a dedicated mesh
  33805. * @param transformNode The transform node to connect the sound with
  33806. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33807. */
  33808. attachToMesh(transformNode: TransformNode): void;
  33809. /**
  33810. * Detach the sound from the previously attached mesh
  33811. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33812. */
  33813. detachFromMesh(): void;
  33814. private _onRegisterAfterWorldMatrixUpdate;
  33815. /**
  33816. * Clone the current sound in the scene.
  33817. * @returns the new sound clone
  33818. */
  33819. clone(): Nullable<Sound>;
  33820. /**
  33821. * Gets the current underlying audio buffer containing the data
  33822. * @returns the audio buffer
  33823. */
  33824. getAudioBuffer(): Nullable<AudioBuffer>;
  33825. /**
  33826. * Serializes the Sound in a JSON representation
  33827. * @returns the JSON representation of the sound
  33828. */
  33829. serialize(): any;
  33830. /**
  33831. * Parse a JSON representation of a sound to innstantiate in a given scene
  33832. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33833. * @param scene Define the scene the new parsed sound should be created in
  33834. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33835. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33836. * @returns the newly parsed sound
  33837. */
  33838. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33839. }
  33840. }
  33841. declare module "babylonjs/Actions/directAudioActions" {
  33842. import { Action } from "babylonjs/Actions/action";
  33843. import { Condition } from "babylonjs/Actions/condition";
  33844. import { Sound } from "babylonjs/Audio/sound";
  33845. /**
  33846. * This defines an action helpful to play a defined sound on a triggered action.
  33847. */
  33848. export class PlaySoundAction extends Action {
  33849. private _sound;
  33850. /**
  33851. * Instantiate the action
  33852. * @param triggerOptions defines the trigger options
  33853. * @param sound defines the sound to play
  33854. * @param condition defines the trigger related conditions
  33855. */
  33856. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33857. /** @hidden */
  33858. _prepare(): void;
  33859. /**
  33860. * Execute the action and play the sound.
  33861. */
  33862. execute(): void;
  33863. /**
  33864. * Serializes the actions and its related information.
  33865. * @param parent defines the object to serialize in
  33866. * @returns the serialized object
  33867. */
  33868. serialize(parent: any): any;
  33869. }
  33870. /**
  33871. * This defines an action helpful to stop a defined sound on a triggered action.
  33872. */
  33873. export class StopSoundAction extends Action {
  33874. private _sound;
  33875. /**
  33876. * Instantiate the action
  33877. * @param triggerOptions defines the trigger options
  33878. * @param sound defines the sound to stop
  33879. * @param condition defines the trigger related conditions
  33880. */
  33881. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33882. /** @hidden */
  33883. _prepare(): void;
  33884. /**
  33885. * Execute the action and stop the sound.
  33886. */
  33887. execute(): void;
  33888. /**
  33889. * Serializes the actions and its related information.
  33890. * @param parent defines the object to serialize in
  33891. * @returns the serialized object
  33892. */
  33893. serialize(parent: any): any;
  33894. }
  33895. }
  33896. declare module "babylonjs/Actions/interpolateValueAction" {
  33897. import { Action } from "babylonjs/Actions/action";
  33898. import { Condition } from "babylonjs/Actions/condition";
  33899. import { Observable } from "babylonjs/Misc/observable";
  33900. /**
  33901. * This defines an action responsible to change the value of a property
  33902. * by interpolating between its current value and the newly set one once triggered.
  33903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33904. */
  33905. export class InterpolateValueAction extends Action {
  33906. /**
  33907. * Defines the path of the property where the value should be interpolated
  33908. */
  33909. propertyPath: string;
  33910. /**
  33911. * Defines the target value at the end of the interpolation.
  33912. */
  33913. value: any;
  33914. /**
  33915. * Defines the time it will take for the property to interpolate to the value.
  33916. */
  33917. duration: number;
  33918. /**
  33919. * Defines if the other scene animations should be stopped when the action has been triggered
  33920. */
  33921. stopOtherAnimations?: boolean;
  33922. /**
  33923. * Defines a callback raised once the interpolation animation has been done.
  33924. */
  33925. onInterpolationDone?: () => void;
  33926. /**
  33927. * Observable triggered once the interpolation animation has been done.
  33928. */
  33929. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33930. private _target;
  33931. private _effectiveTarget;
  33932. private _property;
  33933. /**
  33934. * Instantiate the action
  33935. * @param triggerOptions defines the trigger options
  33936. * @param target defines the object containing the value to interpolate
  33937. * @param propertyPath defines the path to the property in the target object
  33938. * @param value defines the target value at the end of the interpolation
  33939. * @param duration deines the time it will take for the property to interpolate to the value.
  33940. * @param condition defines the trigger related conditions
  33941. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33942. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33943. */
  33944. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33945. /** @hidden */
  33946. _prepare(): void;
  33947. /**
  33948. * Execute the action starts the value interpolation.
  33949. */
  33950. execute(): void;
  33951. /**
  33952. * Serializes the actions and its related information.
  33953. * @param parent defines the object to serialize in
  33954. * @returns the serialized object
  33955. */
  33956. serialize(parent: any): any;
  33957. }
  33958. }
  33959. declare module "babylonjs/Actions/index" {
  33960. export * from "babylonjs/Actions/action";
  33961. export * from "babylonjs/Actions/actionEvent";
  33962. export * from "babylonjs/Actions/actionManager";
  33963. export * from "babylonjs/Actions/condition";
  33964. export * from "babylonjs/Actions/directActions";
  33965. export * from "babylonjs/Actions/directAudioActions";
  33966. export * from "babylonjs/Actions/interpolateValueAction";
  33967. }
  33968. declare module "babylonjs/Animations/index" {
  33969. export * from "babylonjs/Animations/animatable";
  33970. export * from "babylonjs/Animations/animation";
  33971. export * from "babylonjs/Animations/animationGroup";
  33972. export * from "babylonjs/Animations/animationPropertiesOverride";
  33973. export * from "babylonjs/Animations/easing";
  33974. export * from "babylonjs/Animations/runtimeAnimation";
  33975. export * from "babylonjs/Animations/animationEvent";
  33976. export * from "babylonjs/Animations/animationGroup";
  33977. export * from "babylonjs/Animations/animationKey";
  33978. export * from "babylonjs/Animations/animationRange";
  33979. }
  33980. declare module "babylonjs/Audio/soundTrack" {
  33981. import { Sound } from "babylonjs/Audio/sound";
  33982. import { Analyser } from "babylonjs/Audio/analyser";
  33983. import { Scene } from "babylonjs/scene";
  33984. /**
  33985. * Options allowed during the creation of a sound track.
  33986. */
  33987. export interface ISoundTrackOptions {
  33988. /**
  33989. * The volume the sound track should take during creation
  33990. */
  33991. volume?: number;
  33992. /**
  33993. * Define if the sound track is the main sound track of the scene
  33994. */
  33995. mainTrack?: boolean;
  33996. }
  33997. /**
  33998. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33999. * It will be also used in a future release to apply effects on a specific track.
  34000. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34001. */
  34002. export class SoundTrack {
  34003. /**
  34004. * The unique identifier of the sound track in the scene.
  34005. */
  34006. id: number;
  34007. /**
  34008. * The list of sounds included in the sound track.
  34009. */
  34010. soundCollection: Array<Sound>;
  34011. private _outputAudioNode;
  34012. private _scene;
  34013. private _isMainTrack;
  34014. private _connectedAnalyser;
  34015. private _options;
  34016. private _isInitialized;
  34017. /**
  34018. * Creates a new sound track.
  34019. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34020. * @param scene Define the scene the sound track belongs to
  34021. * @param options
  34022. */
  34023. constructor(scene: Scene, options?: ISoundTrackOptions);
  34024. private _initializeSoundTrackAudioGraph;
  34025. /**
  34026. * Release the sound track and its associated resources
  34027. */
  34028. dispose(): void;
  34029. /**
  34030. * Adds a sound to this sound track
  34031. * @param sound define the cound to add
  34032. * @ignoreNaming
  34033. */
  34034. AddSound(sound: Sound): void;
  34035. /**
  34036. * Removes a sound to this sound track
  34037. * @param sound define the cound to remove
  34038. * @ignoreNaming
  34039. */
  34040. RemoveSound(sound: Sound): void;
  34041. /**
  34042. * Set a global volume for the full sound track.
  34043. * @param newVolume Define the new volume of the sound track
  34044. */
  34045. setVolume(newVolume: number): void;
  34046. /**
  34047. * Switch the panning model to HRTF:
  34048. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34049. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34050. */
  34051. switchPanningModelToHRTF(): void;
  34052. /**
  34053. * Switch the panning model to Equal Power:
  34054. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34056. */
  34057. switchPanningModelToEqualPower(): void;
  34058. /**
  34059. * Connect the sound track to an audio analyser allowing some amazing
  34060. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34062. * @param analyser The analyser to connect to the engine
  34063. */
  34064. connectToAnalyser(analyser: Analyser): void;
  34065. }
  34066. }
  34067. declare module "babylonjs/Audio/audioSceneComponent" {
  34068. import { Sound } from "babylonjs/Audio/sound";
  34069. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  34070. import { Nullable } from "babylonjs/types";
  34071. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  34072. import { Scene } from "babylonjs/scene";
  34073. import { AbstractScene } from "babylonjs/abstractScene";
  34074. module "babylonjs/abstractScene" {
  34075. interface AbstractScene {
  34076. /**
  34077. * The list of sounds used in the scene.
  34078. */
  34079. sounds: Nullable<Array<Sound>>;
  34080. }
  34081. }
  34082. module "babylonjs/scene" {
  34083. interface Scene {
  34084. /**
  34085. * @hidden
  34086. * Backing field
  34087. */
  34088. _mainSoundTrack: SoundTrack;
  34089. /**
  34090. * The main sound track played by the scene.
  34091. * It cotains your primary collection of sounds.
  34092. */
  34093. mainSoundTrack: SoundTrack;
  34094. /**
  34095. * The list of sound tracks added to the scene
  34096. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34097. */
  34098. soundTracks: Nullable<Array<SoundTrack>>;
  34099. /**
  34100. * Gets a sound using a given name
  34101. * @param name defines the name to search for
  34102. * @return the found sound or null if not found at all.
  34103. */
  34104. getSoundByName(name: string): Nullable<Sound>;
  34105. /**
  34106. * Gets or sets if audio support is enabled
  34107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34108. */
  34109. audioEnabled: boolean;
  34110. /**
  34111. * Gets or sets if audio will be output to headphones
  34112. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34113. */
  34114. headphone: boolean;
  34115. }
  34116. }
  34117. /**
  34118. * Defines the sound scene component responsible to manage any sounds
  34119. * in a given scene.
  34120. */
  34121. export class AudioSceneComponent implements ISceneSerializableComponent {
  34122. /**
  34123. * The component name helpfull to identify the component in the list of scene components.
  34124. */
  34125. readonly name: string;
  34126. /**
  34127. * The scene the component belongs to.
  34128. */
  34129. scene: Scene;
  34130. private _audioEnabled;
  34131. /**
  34132. * Gets whether audio is enabled or not.
  34133. * Please use related enable/disable method to switch state.
  34134. */
  34135. readonly audioEnabled: boolean;
  34136. private _headphone;
  34137. /**
  34138. * Gets whether audio is outputing to headphone or not.
  34139. * Please use the according Switch methods to change output.
  34140. */
  34141. readonly headphone: boolean;
  34142. /**
  34143. * Creates a new instance of the component for the given scene
  34144. * @param scene Defines the scene to register the component in
  34145. */
  34146. constructor(scene: Scene);
  34147. /**
  34148. * Registers the component in a given scene
  34149. */
  34150. register(): void;
  34151. /**
  34152. * Rebuilds the elements related to this component in case of
  34153. * context lost for instance.
  34154. */
  34155. rebuild(): void;
  34156. /**
  34157. * Serializes the component data to the specified json object
  34158. * @param serializationObject The object to serialize to
  34159. */
  34160. serialize(serializationObject: any): void;
  34161. /**
  34162. * Adds all the element from the container to the scene
  34163. * @param container the container holding the elements
  34164. */
  34165. addFromContainer(container: AbstractScene): void;
  34166. /**
  34167. * Removes all the elements in the container from the scene
  34168. * @param container contains the elements to remove
  34169. */
  34170. removeFromContainer(container: AbstractScene): void;
  34171. /**
  34172. * Disposes the component and the associated ressources.
  34173. */
  34174. dispose(): void;
  34175. /**
  34176. * Disables audio in the associated scene.
  34177. */
  34178. disableAudio(): void;
  34179. /**
  34180. * Enables audio in the associated scene.
  34181. */
  34182. enableAudio(): void;
  34183. /**
  34184. * Switch audio to headphone output.
  34185. */
  34186. switchAudioModeForHeadphones(): void;
  34187. /**
  34188. * Switch audio to normal speakers.
  34189. */
  34190. switchAudioModeForNormalSpeakers(): void;
  34191. private _afterRender;
  34192. }
  34193. }
  34194. declare module "babylonjs/Audio/weightedsound" {
  34195. import { Sound } from "babylonjs/Audio/sound";
  34196. /**
  34197. * Wraps one or more Sound objects and selects one with random weight for playback.
  34198. */
  34199. export class WeightedSound {
  34200. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34201. loop: boolean;
  34202. private _coneInnerAngle;
  34203. private _coneOuterAngle;
  34204. private _volume;
  34205. /** A Sound is currently playing. */
  34206. isPlaying: boolean;
  34207. /** A Sound is currently paused. */
  34208. isPaused: boolean;
  34209. private _sounds;
  34210. private _weights;
  34211. private _currentIndex?;
  34212. /**
  34213. * Creates a new WeightedSound from the list of sounds given.
  34214. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34215. * @param sounds Array of Sounds that will be selected from.
  34216. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34217. */
  34218. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34219. /**
  34220. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34221. */
  34222. /**
  34223. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34224. */
  34225. directionalConeInnerAngle: number;
  34226. /**
  34227. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34228. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34229. */
  34230. /**
  34231. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34232. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34233. */
  34234. directionalConeOuterAngle: number;
  34235. /**
  34236. * Playback volume.
  34237. */
  34238. /**
  34239. * Playback volume.
  34240. */
  34241. volume: number;
  34242. private _onended;
  34243. /**
  34244. * Suspend playback
  34245. */
  34246. pause(): void;
  34247. /**
  34248. * Stop playback
  34249. */
  34250. stop(): void;
  34251. /**
  34252. * Start playback.
  34253. * @param startOffset Position the clip head at a specific time in seconds.
  34254. */
  34255. play(startOffset?: number): void;
  34256. }
  34257. }
  34258. declare module "babylonjs/Audio/index" {
  34259. export * from "babylonjs/Audio/analyser";
  34260. export * from "babylonjs/Audio/audioEngine";
  34261. export * from "babylonjs/Audio/audioSceneComponent";
  34262. export * from "babylonjs/Audio/sound";
  34263. export * from "babylonjs/Audio/soundTrack";
  34264. export * from "babylonjs/Audio/weightedsound";
  34265. }
  34266. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  34267. import { Behavior } from "babylonjs/Behaviors/behavior";
  34268. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34269. import { BackEase } from "babylonjs/Animations/easing";
  34270. /**
  34271. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34272. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34273. */
  34274. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34275. /**
  34276. * Gets the name of the behavior.
  34277. */
  34278. readonly name: string;
  34279. /**
  34280. * The easing function used by animations
  34281. */
  34282. static EasingFunction: BackEase;
  34283. /**
  34284. * The easing mode used by animations
  34285. */
  34286. static EasingMode: number;
  34287. /**
  34288. * The duration of the animation, in milliseconds
  34289. */
  34290. transitionDuration: number;
  34291. /**
  34292. * Length of the distance animated by the transition when lower radius is reached
  34293. */
  34294. lowerRadiusTransitionRange: number;
  34295. /**
  34296. * Length of the distance animated by the transition when upper radius is reached
  34297. */
  34298. upperRadiusTransitionRange: number;
  34299. private _autoTransitionRange;
  34300. /**
  34301. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34302. */
  34303. /**
  34304. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34305. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34306. */
  34307. autoTransitionRange: boolean;
  34308. private _attachedCamera;
  34309. private _onAfterCheckInputsObserver;
  34310. private _onMeshTargetChangedObserver;
  34311. /**
  34312. * Initializes the behavior.
  34313. */
  34314. init(): void;
  34315. /**
  34316. * Attaches the behavior to its arc rotate camera.
  34317. * @param camera Defines the camera to attach the behavior to
  34318. */
  34319. attach(camera: ArcRotateCamera): void;
  34320. /**
  34321. * Detaches the behavior from its current arc rotate camera.
  34322. */
  34323. detach(): void;
  34324. private _radiusIsAnimating;
  34325. private _radiusBounceTransition;
  34326. private _animatables;
  34327. private _cachedWheelPrecision;
  34328. /**
  34329. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34330. * @param radiusLimit The limit to check against.
  34331. * @return Bool to indicate if at limit.
  34332. */
  34333. private _isRadiusAtLimit;
  34334. /**
  34335. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34336. * @param radiusDelta The delta by which to animate to. Can be negative.
  34337. */
  34338. private _applyBoundRadiusAnimation;
  34339. /**
  34340. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34341. */
  34342. protected _clearAnimationLocks(): void;
  34343. /**
  34344. * Stops and removes all animations that have been applied to the camera
  34345. */
  34346. stopAllAnimations(): void;
  34347. }
  34348. }
  34349. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  34350. import { Behavior } from "babylonjs/Behaviors/behavior";
  34351. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34352. import { ExponentialEase } from "babylonjs/Animations/easing";
  34353. import { Nullable } from "babylonjs/types";
  34354. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34355. import { Vector3 } from "babylonjs/Maths/math";
  34356. /**
  34357. * 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.
  34358. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34359. */
  34360. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34361. /**
  34362. * Gets the name of the behavior.
  34363. */
  34364. readonly name: string;
  34365. private _mode;
  34366. private _radiusScale;
  34367. private _positionScale;
  34368. private _defaultElevation;
  34369. private _elevationReturnTime;
  34370. private _elevationReturnWaitTime;
  34371. private _zoomStopsAnimation;
  34372. private _framingTime;
  34373. /**
  34374. * The easing function used by animations
  34375. */
  34376. static EasingFunction: ExponentialEase;
  34377. /**
  34378. * The easing mode used by animations
  34379. */
  34380. static EasingMode: number;
  34381. /**
  34382. * Sets the current mode used by the behavior
  34383. */
  34384. /**
  34385. * Gets current mode used by the behavior.
  34386. */
  34387. mode: number;
  34388. /**
  34389. * Sets the scale applied to the radius (1 by default)
  34390. */
  34391. /**
  34392. * Gets the scale applied to the radius
  34393. */
  34394. radiusScale: number;
  34395. /**
  34396. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34397. */
  34398. /**
  34399. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34400. */
  34401. positionScale: number;
  34402. /**
  34403. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34404. * behaviour is triggered, in radians.
  34405. */
  34406. /**
  34407. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34408. * behaviour is triggered, in radians.
  34409. */
  34410. defaultElevation: number;
  34411. /**
  34412. * Sets the time (in milliseconds) taken to return to the default beta position.
  34413. * Negative value indicates camera should not return to default.
  34414. */
  34415. /**
  34416. * Gets the time (in milliseconds) taken to return to the default beta position.
  34417. * Negative value indicates camera should not return to default.
  34418. */
  34419. elevationReturnTime: number;
  34420. /**
  34421. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34422. */
  34423. /**
  34424. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34425. */
  34426. elevationReturnWaitTime: number;
  34427. /**
  34428. * Sets the flag that indicates if user zooming should stop animation.
  34429. */
  34430. /**
  34431. * Gets the flag that indicates if user zooming should stop animation.
  34432. */
  34433. zoomStopsAnimation: boolean;
  34434. /**
  34435. * Sets the transition time when framing the mesh, in milliseconds
  34436. */
  34437. /**
  34438. * Gets the transition time when framing the mesh, in milliseconds
  34439. */
  34440. framingTime: number;
  34441. /**
  34442. * Define if the behavior should automatically change the configured
  34443. * camera limits and sensibilities.
  34444. */
  34445. autoCorrectCameraLimitsAndSensibility: boolean;
  34446. private _onPrePointerObservableObserver;
  34447. private _onAfterCheckInputsObserver;
  34448. private _onMeshTargetChangedObserver;
  34449. private _attachedCamera;
  34450. private _isPointerDown;
  34451. private _lastInteractionTime;
  34452. /**
  34453. * Initializes the behavior.
  34454. */
  34455. init(): void;
  34456. /**
  34457. * Attaches the behavior to its arc rotate camera.
  34458. * @param camera Defines the camera to attach the behavior to
  34459. */
  34460. attach(camera: ArcRotateCamera): void;
  34461. /**
  34462. * Detaches the behavior from its current arc rotate camera.
  34463. */
  34464. detach(): void;
  34465. private _animatables;
  34466. private _betaIsAnimating;
  34467. private _betaTransition;
  34468. private _radiusTransition;
  34469. private _vectorTransition;
  34470. /**
  34471. * Targets the given mesh and updates zoom level accordingly.
  34472. * @param mesh The mesh to target.
  34473. * @param radius Optional. If a cached radius position already exists, overrides default.
  34474. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34475. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34476. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34477. */
  34478. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34479. /**
  34480. * Targets the given mesh with its children and updates zoom level accordingly.
  34481. * @param mesh The mesh to target.
  34482. * @param radius Optional. If a cached radius position already exists, overrides default.
  34483. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34484. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34485. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34486. */
  34487. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34488. /**
  34489. * Targets the given meshes with their children and updates zoom level accordingly.
  34490. * @param meshes The mesh to target.
  34491. * @param radius Optional. If a cached radius position already exists, overrides default.
  34492. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34493. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34494. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34495. */
  34496. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34497. /**
  34498. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34499. * @param minimumWorld Determines the smaller position of the bounding box extend
  34500. * @param maximumWorld Determines the bigger position of the bounding box extend
  34501. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34502. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34503. */
  34504. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34505. /**
  34506. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34507. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34508. * frustum width.
  34509. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34510. * to fully enclose the mesh in the viewing frustum.
  34511. */
  34512. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34513. /**
  34514. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34515. * is automatically returned to its default position (expected to be above ground plane).
  34516. */
  34517. private _maintainCameraAboveGround;
  34518. /**
  34519. * Returns the frustum slope based on the canvas ratio and camera FOV
  34520. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34521. */
  34522. private _getFrustumSlope;
  34523. /**
  34524. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34525. */
  34526. private _clearAnimationLocks;
  34527. /**
  34528. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34529. */
  34530. private _applyUserInteraction;
  34531. /**
  34532. * Stops and removes all animations that have been applied to the camera
  34533. */
  34534. stopAllAnimations(): void;
  34535. /**
  34536. * Gets a value indicating if the user is moving the camera
  34537. */
  34538. readonly isUserIsMoving: boolean;
  34539. /**
  34540. * The camera can move all the way towards the mesh.
  34541. */
  34542. static IgnoreBoundsSizeMode: number;
  34543. /**
  34544. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34545. */
  34546. static FitFrustumSidesMode: number;
  34547. }
  34548. }
  34549. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  34550. import { Nullable } from "babylonjs/types";
  34551. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34552. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34553. /**
  34554. * Manage the pointers inputs to control an arc rotate camera.
  34555. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34556. */
  34557. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  34558. /**
  34559. * Defines the camera the input is attached to.
  34560. */
  34561. camera: ArcRotateCamera;
  34562. /**
  34563. * Defines the buttons associated with the input to handle camera move.
  34564. */
  34565. buttons: number[];
  34566. /**
  34567. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34568. */
  34569. angularSensibilityX: number;
  34570. /**
  34571. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34572. */
  34573. angularSensibilityY: number;
  34574. /**
  34575. * Defines the pointer pinch precision or how fast is the camera zooming.
  34576. */
  34577. pinchPrecision: number;
  34578. /**
  34579. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  34580. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34581. */
  34582. pinchDeltaPercentage: number;
  34583. /**
  34584. * Defines the pointer panning sensibility or how fast is the camera moving.
  34585. */
  34586. panningSensibility: number;
  34587. /**
  34588. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34589. */
  34590. multiTouchPanning: boolean;
  34591. /**
  34592. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  34593. */
  34594. multiTouchPanAndZoom: boolean;
  34595. /**
  34596. * Revers pinch action direction.
  34597. */
  34598. pinchInwards: boolean;
  34599. private _isPanClick;
  34600. private _pointerInput;
  34601. private _observer;
  34602. private _onMouseMove;
  34603. private _onGestureStart;
  34604. private _onGesture;
  34605. private _MSGestureHandler;
  34606. private _onLostFocus;
  34607. private _onContextMenu;
  34608. /**
  34609. * Attach the input controls to a specific dom element to get the input from.
  34610. * @param element Defines the element the controls should be listened from
  34611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34612. */
  34613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34614. /**
  34615. * Detach the current controls from the specified dom element.
  34616. * @param element Defines the element to stop listening the inputs from
  34617. */
  34618. detachControl(element: Nullable<HTMLElement>): void;
  34619. /**
  34620. * Gets the class name of the current intput.
  34621. * @returns the class name
  34622. */
  34623. getClassName(): string;
  34624. /**
  34625. * Get the friendly name associated with the input class.
  34626. * @returns the input friendly name
  34627. */
  34628. getSimpleName(): string;
  34629. }
  34630. }
  34631. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  34632. import { Nullable } from "babylonjs/types";
  34633. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34634. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34635. /**
  34636. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34638. */
  34639. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34640. /**
  34641. * Defines the camera the input is attached to.
  34642. */
  34643. camera: ArcRotateCamera;
  34644. /**
  34645. * Defines the list of key codes associated with the up action (increase alpha)
  34646. */
  34647. keysUp: number[];
  34648. /**
  34649. * Defines the list of key codes associated with the down action (decrease alpha)
  34650. */
  34651. keysDown: number[];
  34652. /**
  34653. * Defines the list of key codes associated with the left action (increase beta)
  34654. */
  34655. keysLeft: number[];
  34656. /**
  34657. * Defines the list of key codes associated with the right action (decrease beta)
  34658. */
  34659. keysRight: number[];
  34660. /**
  34661. * Defines the list of key codes associated with the reset action.
  34662. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34663. */
  34664. keysReset: number[];
  34665. /**
  34666. * Defines the panning sensibility of the inputs.
  34667. * (How fast is the camera paning)
  34668. */
  34669. panningSensibility: number;
  34670. /**
  34671. * Defines the zooming sensibility of the inputs.
  34672. * (How fast is the camera zooming)
  34673. */
  34674. zoomingSensibility: number;
  34675. /**
  34676. * Defines wether maintaining the alt key down switch the movement mode from
  34677. * orientation to zoom.
  34678. */
  34679. useAltToZoom: boolean;
  34680. /**
  34681. * Rotation speed of the camera
  34682. */
  34683. angularSpeed: number;
  34684. private _keys;
  34685. private _ctrlPressed;
  34686. private _altPressed;
  34687. private _onCanvasBlurObserver;
  34688. private _onKeyboardObserver;
  34689. private _engine;
  34690. private _scene;
  34691. /**
  34692. * Attach the input controls to a specific dom element to get the input from.
  34693. * @param element Defines the element the controls should be listened from
  34694. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34695. */
  34696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34697. /**
  34698. * Detach the current controls from the specified dom element.
  34699. * @param element Defines the element to stop listening the inputs from
  34700. */
  34701. detachControl(element: Nullable<HTMLElement>): void;
  34702. /**
  34703. * Update the current camera state depending on the inputs that have been used this frame.
  34704. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34705. */
  34706. checkInputs(): void;
  34707. /**
  34708. * Gets the class name of the current intput.
  34709. * @returns the class name
  34710. */
  34711. getClassName(): string;
  34712. /**
  34713. * Get the friendly name associated with the input class.
  34714. * @returns the input friendly name
  34715. */
  34716. getSimpleName(): string;
  34717. }
  34718. }
  34719. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  34720. import { Nullable } from "babylonjs/types";
  34721. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34722. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  34723. /**
  34724. * Manage the mouse wheel inputs to control an arc rotate camera.
  34725. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34726. */
  34727. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34728. /**
  34729. * Defines the camera the input is attached to.
  34730. */
  34731. camera: ArcRotateCamera;
  34732. /**
  34733. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34734. */
  34735. wheelPrecision: number;
  34736. /**
  34737. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34738. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34739. */
  34740. wheelDeltaPercentage: number;
  34741. private _wheel;
  34742. private _observer;
  34743. /**
  34744. * Attach the input controls to a specific dom element to get the input from.
  34745. * @param element Defines the element the controls should be listened from
  34746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34747. */
  34748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34749. /**
  34750. * Detach the current controls from the specified dom element.
  34751. * @param element Defines the element to stop listening the inputs from
  34752. */
  34753. detachControl(element: Nullable<HTMLElement>): void;
  34754. /**
  34755. * Gets the class name of the current intput.
  34756. * @returns the class name
  34757. */
  34758. getClassName(): string;
  34759. /**
  34760. * Get the friendly name associated with the input class.
  34761. * @returns the input friendly name
  34762. */
  34763. getSimpleName(): string;
  34764. }
  34765. }
  34766. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  34767. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  34768. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  34769. /**
  34770. * Default Inputs manager for the ArcRotateCamera.
  34771. * It groups all the default supported inputs for ease of use.
  34772. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34773. */
  34774. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34775. /**
  34776. * Instantiates a new ArcRotateCameraInputsManager.
  34777. * @param camera Defines the camera the inputs belong to
  34778. */
  34779. constructor(camera: ArcRotateCamera);
  34780. /**
  34781. * Add mouse wheel input support to the input manager.
  34782. * @returns the current input manager
  34783. */
  34784. addMouseWheel(): ArcRotateCameraInputsManager;
  34785. /**
  34786. * Add pointers input support to the input manager.
  34787. * @returns the current input manager
  34788. */
  34789. addPointers(): ArcRotateCameraInputsManager;
  34790. /**
  34791. * Add keyboard input support to the input manager.
  34792. * @returns the current input manager
  34793. */
  34794. addKeyboard(): ArcRotateCameraInputsManager;
  34795. }
  34796. }
  34797. declare module "babylonjs/Cameras/arcRotateCamera" {
  34798. import { Observable } from "babylonjs/Misc/observable";
  34799. import { Nullable } from "babylonjs/types";
  34800. import { Scene } from "babylonjs/scene";
  34801. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  34802. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34803. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  34804. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  34805. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  34806. import { Camera } from "babylonjs/Cameras/camera";
  34807. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  34808. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  34809. import { Collider } from "babylonjs/Collisions/collider";
  34810. /**
  34811. * This represents an orbital type of camera.
  34812. *
  34813. * 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.
  34814. * 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.
  34815. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34816. */
  34817. export class ArcRotateCamera extends TargetCamera {
  34818. /**
  34819. * Defines the rotation angle of the camera along the longitudinal axis.
  34820. */
  34821. alpha: number;
  34822. /**
  34823. * Defines the rotation angle of the camera along the latitudinal axis.
  34824. */
  34825. beta: number;
  34826. /**
  34827. * Defines the radius of the camera from it s target point.
  34828. */
  34829. radius: number;
  34830. protected _target: Vector3;
  34831. protected _targetHost: Nullable<AbstractMesh>;
  34832. /**
  34833. * Defines the target point of the camera.
  34834. * The camera looks towards it form the radius distance.
  34835. */
  34836. target: Vector3;
  34837. /**
  34838. * Current inertia value on the longitudinal axis.
  34839. * The bigger this number the longer it will take for the camera to stop.
  34840. */
  34841. inertialAlphaOffset: number;
  34842. /**
  34843. * Current inertia value on the latitudinal axis.
  34844. * The bigger this number the longer it will take for the camera to stop.
  34845. */
  34846. inertialBetaOffset: number;
  34847. /**
  34848. * Current inertia value on the radius axis.
  34849. * The bigger this number the longer it will take for the camera to stop.
  34850. */
  34851. inertialRadiusOffset: number;
  34852. /**
  34853. * Minimum allowed angle on the longitudinal axis.
  34854. * This can help limiting how the Camera is able to move in the scene.
  34855. */
  34856. lowerAlphaLimit: Nullable<number>;
  34857. /**
  34858. * Maximum allowed angle on the longitudinal axis.
  34859. * This can help limiting how the Camera is able to move in the scene.
  34860. */
  34861. upperAlphaLimit: Nullable<number>;
  34862. /**
  34863. * Minimum allowed angle on the latitudinal axis.
  34864. * This can help limiting how the Camera is able to move in the scene.
  34865. */
  34866. lowerBetaLimit: number;
  34867. /**
  34868. * Maximum allowed angle on the latitudinal axis.
  34869. * This can help limiting how the Camera is able to move in the scene.
  34870. */
  34871. upperBetaLimit: number;
  34872. /**
  34873. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34874. * This can help limiting how the Camera is able to move in the scene.
  34875. */
  34876. lowerRadiusLimit: Nullable<number>;
  34877. /**
  34878. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34879. * This can help limiting how the Camera is able to move in the scene.
  34880. */
  34881. upperRadiusLimit: Nullable<number>;
  34882. /**
  34883. * Defines the current inertia value used during panning of the camera along the X axis.
  34884. */
  34885. inertialPanningX: number;
  34886. /**
  34887. * Defines the current inertia value used during panning of the camera along the Y axis.
  34888. */
  34889. inertialPanningY: number;
  34890. /**
  34891. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34892. * Basically if your fingers moves away from more than this distance you will be considered
  34893. * in pinch mode.
  34894. */
  34895. pinchToPanMaxDistance: number;
  34896. /**
  34897. * Defines the maximum distance the camera can pan.
  34898. * This could help keeping the cammera always in your scene.
  34899. */
  34900. panningDistanceLimit: Nullable<number>;
  34901. /**
  34902. * Defines the target of the camera before paning.
  34903. */
  34904. panningOriginTarget: Vector3;
  34905. /**
  34906. * Defines the value of the inertia used during panning.
  34907. * 0 would mean stop inertia and one would mean no decelleration at all.
  34908. */
  34909. panningInertia: number;
  34910. /**
  34911. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34912. */
  34913. angularSensibilityX: number;
  34914. /**
  34915. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34916. */
  34917. angularSensibilityY: number;
  34918. /**
  34919. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34920. */
  34921. pinchPrecision: number;
  34922. /**
  34923. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34924. * It will be used instead of pinchDeltaPrecision if different from 0.
  34925. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34926. */
  34927. pinchDeltaPercentage: number;
  34928. /**
  34929. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34930. */
  34931. panningSensibility: number;
  34932. /**
  34933. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34934. */
  34935. keysUp: number[];
  34936. /**
  34937. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34938. */
  34939. keysDown: number[];
  34940. /**
  34941. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34942. */
  34943. keysLeft: number[];
  34944. /**
  34945. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34946. */
  34947. keysRight: number[];
  34948. /**
  34949. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34950. */
  34951. wheelPrecision: number;
  34952. /**
  34953. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34954. * It will be used instead of pinchDeltaPrecision if different from 0.
  34955. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34956. */
  34957. wheelDeltaPercentage: number;
  34958. /**
  34959. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34960. */
  34961. zoomOnFactor: number;
  34962. /**
  34963. * Defines a screen offset for the camera position.
  34964. */
  34965. targetScreenOffset: Vector2;
  34966. /**
  34967. * Allows the camera to be completely reversed.
  34968. * If false the camera can not arrive upside down.
  34969. */
  34970. allowUpsideDown: boolean;
  34971. /**
  34972. * Define if double tap/click is used to restore the previously saved state of the camera.
  34973. */
  34974. useInputToRestoreState: boolean;
  34975. /** @hidden */
  34976. _viewMatrix: Matrix;
  34977. /** @hidden */
  34978. _useCtrlForPanning: boolean;
  34979. /** @hidden */
  34980. _panningMouseButton: number;
  34981. /**
  34982. * Defines the input associated to the camera.
  34983. */
  34984. inputs: ArcRotateCameraInputsManager;
  34985. /** @hidden */
  34986. _reset: () => void;
  34987. /**
  34988. * Defines the allowed panning axis.
  34989. */
  34990. panningAxis: Vector3;
  34991. protected _localDirection: Vector3;
  34992. protected _transformedDirection: Vector3;
  34993. private _bouncingBehavior;
  34994. /**
  34995. * Gets the bouncing behavior of the camera if it has been enabled.
  34996. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34997. */
  34998. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34999. /**
  35000. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35001. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35002. */
  35003. useBouncingBehavior: boolean;
  35004. private _framingBehavior;
  35005. /**
  35006. * Gets the framing behavior of the camera if it has been enabled.
  35007. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35008. */
  35009. readonly framingBehavior: Nullable<FramingBehavior>;
  35010. /**
  35011. * Defines if the framing behavior of the camera is enabled on the camera.
  35012. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35013. */
  35014. useFramingBehavior: boolean;
  35015. private _autoRotationBehavior;
  35016. /**
  35017. * Gets the auto rotation behavior of the camera if it has been enabled.
  35018. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35019. */
  35020. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35021. /**
  35022. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35023. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35024. */
  35025. useAutoRotationBehavior: boolean;
  35026. /**
  35027. * Observable triggered when the mesh target has been changed on the camera.
  35028. */
  35029. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35030. /**
  35031. * Event raised when the camera is colliding with a mesh.
  35032. */
  35033. onCollide: (collidedMesh: AbstractMesh) => void;
  35034. /**
  35035. * Defines whether the camera should check collision with the objects oh the scene.
  35036. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35037. */
  35038. checkCollisions: boolean;
  35039. /**
  35040. * Defines the collision radius of the camera.
  35041. * This simulates a sphere around the camera.
  35042. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35043. */
  35044. collisionRadius: Vector3;
  35045. protected _collider: Collider;
  35046. protected _previousPosition: Vector3;
  35047. protected _collisionVelocity: Vector3;
  35048. protected _newPosition: Vector3;
  35049. protected _previousAlpha: number;
  35050. protected _previousBeta: number;
  35051. protected _previousRadius: number;
  35052. protected _collisionTriggered: boolean;
  35053. protected _targetBoundingCenter: Nullable<Vector3>;
  35054. private _computationVector;
  35055. private _tempAxisVector;
  35056. private _tempAxisRotationMatrix;
  35057. /**
  35058. * Instantiates a new ArcRotateCamera in a given scene
  35059. * @param name Defines the name of the camera
  35060. * @param alpha Defines the camera rotation along the logitudinal axis
  35061. * @param beta Defines the camera rotation along the latitudinal axis
  35062. * @param radius Defines the camera distance from its target
  35063. * @param target Defines the camera target
  35064. * @param scene Defines the scene the camera belongs to
  35065. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35066. */
  35067. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35068. /** @hidden */
  35069. _initCache(): void;
  35070. /** @hidden */
  35071. _updateCache(ignoreParentClass?: boolean): void;
  35072. protected _getTargetPosition(): Vector3;
  35073. private _storedAlpha;
  35074. private _storedBeta;
  35075. private _storedRadius;
  35076. private _storedTarget;
  35077. /**
  35078. * Stores the current state of the camera (alpha, beta, radius and target)
  35079. * @returns the camera itself
  35080. */
  35081. storeState(): Camera;
  35082. /**
  35083. * @hidden
  35084. * Restored camera state. You must call storeState() first
  35085. */
  35086. _restoreStateValues(): boolean;
  35087. /** @hidden */
  35088. _isSynchronizedViewMatrix(): boolean;
  35089. /**
  35090. * Attached controls to the current camera.
  35091. * @param element Defines the element the controls should be listened from
  35092. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35093. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35094. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35095. */
  35096. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35097. /**
  35098. * Detach the current controls from the camera.
  35099. * The camera will stop reacting to inputs.
  35100. * @param element Defines the element to stop listening the inputs from
  35101. */
  35102. detachControl(element: HTMLElement): void;
  35103. /** @hidden */
  35104. _checkInputs(): void;
  35105. protected _checkLimits(): void;
  35106. /**
  35107. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  35108. */
  35109. rebuildAnglesAndRadius(): void;
  35110. /**
  35111. * Use a position to define the current camera related information like aplha, beta and radius
  35112. * @param position Defines the position to set the camera at
  35113. */
  35114. setPosition(position: Vector3): void;
  35115. /**
  35116. * Defines the target the camera should look at.
  35117. * This will automatically adapt alpha beta and radius to fit within the new target.
  35118. * @param target Defines the new target as a Vector or a mesh
  35119. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35120. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35121. */
  35122. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35123. /** @hidden */
  35124. _getViewMatrix(): Matrix;
  35125. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35126. /**
  35127. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35128. * @param meshes Defines the mesh to zoom on
  35129. * @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)
  35130. */
  35131. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35132. /**
  35133. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35134. * The target will be changed but the radius
  35135. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35136. * @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)
  35137. */
  35138. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35139. min: Vector3;
  35140. max: Vector3;
  35141. distance: number;
  35142. }, doNotUpdateMaxZ?: boolean): void;
  35143. /**
  35144. * @override
  35145. * Override Camera.createRigCamera
  35146. */
  35147. createRigCamera(name: string, cameraIndex: number): Camera;
  35148. /**
  35149. * @hidden
  35150. * @override
  35151. * Override Camera._updateRigCameras
  35152. */
  35153. _updateRigCameras(): void;
  35154. /**
  35155. * Destroy the camera and release the current resources hold by it.
  35156. */
  35157. dispose(): void;
  35158. /**
  35159. * Gets the current object class name.
  35160. * @return the class name
  35161. */
  35162. getClassName(): string;
  35163. }
  35164. }
  35165. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  35166. import { Behavior } from "babylonjs/Behaviors/behavior";
  35167. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35168. /**
  35169. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35170. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35171. */
  35172. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35173. /**
  35174. * Gets the name of the behavior.
  35175. */
  35176. readonly name: string;
  35177. private _zoomStopsAnimation;
  35178. private _idleRotationSpeed;
  35179. private _idleRotationWaitTime;
  35180. private _idleRotationSpinupTime;
  35181. /**
  35182. * Sets the flag that indicates if user zooming should stop animation.
  35183. */
  35184. /**
  35185. * Gets the flag that indicates if user zooming should stop animation.
  35186. */
  35187. zoomStopsAnimation: boolean;
  35188. /**
  35189. * Sets the default speed at which the camera rotates around the model.
  35190. */
  35191. /**
  35192. * Gets the default speed at which the camera rotates around the model.
  35193. */
  35194. idleRotationSpeed: number;
  35195. /**
  35196. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35197. */
  35198. /**
  35199. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35200. */
  35201. idleRotationWaitTime: number;
  35202. /**
  35203. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35204. */
  35205. /**
  35206. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35207. */
  35208. idleRotationSpinupTime: number;
  35209. /**
  35210. * Gets a value indicating if the camera is currently rotating because of this behavior
  35211. */
  35212. readonly rotationInProgress: boolean;
  35213. private _onPrePointerObservableObserver;
  35214. private _onAfterCheckInputsObserver;
  35215. private _attachedCamera;
  35216. private _isPointerDown;
  35217. private _lastFrameTime;
  35218. private _lastInteractionTime;
  35219. private _cameraRotationSpeed;
  35220. /**
  35221. * Initializes the behavior.
  35222. */
  35223. init(): void;
  35224. /**
  35225. * Attaches the behavior to its arc rotate camera.
  35226. * @param camera Defines the camera to attach the behavior to
  35227. */
  35228. attach(camera: ArcRotateCamera): void;
  35229. /**
  35230. * Detaches the behavior from its current arc rotate camera.
  35231. */
  35232. detach(): void;
  35233. /**
  35234. * Returns true if user is scrolling.
  35235. * @return true if user is scrolling.
  35236. */
  35237. private _userIsZooming;
  35238. private _lastFrameRadius;
  35239. private _shouldAnimationStopForInteraction;
  35240. /**
  35241. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35242. */
  35243. private _applyUserInteraction;
  35244. private _userIsMoving;
  35245. }
  35246. }
  35247. declare module "babylonjs/Behaviors/Cameras/index" {
  35248. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35249. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35250. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  35251. }
  35252. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  35253. import { Mesh } from "babylonjs/Meshes/mesh";
  35254. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35255. import { Behavior } from "babylonjs/Behaviors/behavior";
  35256. /**
  35257. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35258. */
  35259. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35260. private ui;
  35261. /**
  35262. * The name of the behavior
  35263. */
  35264. name: string;
  35265. /**
  35266. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35267. */
  35268. distanceAwayFromFace: number;
  35269. /**
  35270. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35271. */
  35272. distanceAwayFromBottomOfFace: number;
  35273. private _faceVectors;
  35274. private _target;
  35275. private _scene;
  35276. private _onRenderObserver;
  35277. private _tmpMatrix;
  35278. private _tmpVector;
  35279. /**
  35280. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35281. * @param ui The transform node that should be attched to the mesh
  35282. */
  35283. constructor(ui: TransformNode);
  35284. /**
  35285. * Initializes the behavior
  35286. */
  35287. init(): void;
  35288. private _closestFace;
  35289. private _zeroVector;
  35290. private _lookAtTmpMatrix;
  35291. private _lookAtToRef;
  35292. /**
  35293. * Attaches the AttachToBoxBehavior to the passed in mesh
  35294. * @param target The mesh that the specified node will be attached to
  35295. */
  35296. attach(target: Mesh): void;
  35297. /**
  35298. * Detaches the behavior from the mesh
  35299. */
  35300. detach(): void;
  35301. }
  35302. }
  35303. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  35304. import { Behavior } from "babylonjs/Behaviors/behavior";
  35305. import { Mesh } from "babylonjs/Meshes/mesh";
  35306. /**
  35307. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35308. */
  35309. export class FadeInOutBehavior implements Behavior<Mesh> {
  35310. /**
  35311. * Time in milliseconds to delay before fading in (Default: 0)
  35312. */
  35313. delay: number;
  35314. /**
  35315. * Time in milliseconds for the mesh to fade in (Default: 300)
  35316. */
  35317. fadeInTime: number;
  35318. private _millisecondsPerFrame;
  35319. private _hovered;
  35320. private _hoverValue;
  35321. private _ownerNode;
  35322. /**
  35323. * Instatiates the FadeInOutBehavior
  35324. */
  35325. constructor();
  35326. /**
  35327. * The name of the behavior
  35328. */
  35329. readonly name: string;
  35330. /**
  35331. * Initializes the behavior
  35332. */
  35333. init(): void;
  35334. /**
  35335. * Attaches the fade behavior on the passed in mesh
  35336. * @param ownerNode The mesh that will be faded in/out once attached
  35337. */
  35338. attach(ownerNode: Mesh): void;
  35339. /**
  35340. * Detaches the behavior from the mesh
  35341. */
  35342. detach(): void;
  35343. /**
  35344. * Triggers the mesh to begin fading in or out
  35345. * @param value if the object should fade in or out (true to fade in)
  35346. */
  35347. fadeIn(value: boolean): void;
  35348. private _update;
  35349. private _setAllVisibility;
  35350. }
  35351. }
  35352. declare module "babylonjs/Misc/pivotTools" {
  35353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35354. /**
  35355. * Class containing a set of static utilities functions for managing Pivots
  35356. * @hidden
  35357. */
  35358. export class PivotTools {
  35359. private static _PivotCached;
  35360. private static _OldPivotPoint;
  35361. private static _PivotTranslation;
  35362. private static _PivotTmpVector;
  35363. /** @hidden */
  35364. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35365. /** @hidden */
  35366. static _RestorePivotPoint(mesh: AbstractMesh): void;
  35367. }
  35368. }
  35369. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  35370. import { Scene } from "babylonjs/scene";
  35371. import { Vector4, Plane } from "babylonjs/Maths/math";
  35372. import { Mesh } from "babylonjs/Meshes/mesh";
  35373. /**
  35374. * Class containing static functions to help procedurally build meshes
  35375. */
  35376. export class PlaneBuilder {
  35377. /**
  35378. * Creates a plane mesh
  35379. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35380. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35381. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35383. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35385. * @param name defines the name of the mesh
  35386. * @param options defines the options used to create the mesh
  35387. * @param scene defines the hosting scene
  35388. * @returns the plane mesh
  35389. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35390. */
  35391. static CreatePlane(name: string, options: {
  35392. size?: number;
  35393. width?: number;
  35394. height?: number;
  35395. sideOrientation?: number;
  35396. frontUVs?: Vector4;
  35397. backUVs?: Vector4;
  35398. updatable?: boolean;
  35399. sourcePlane?: Plane;
  35400. }, scene: Scene): Mesh;
  35401. }
  35402. }
  35403. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  35404. import { Behavior } from "babylonjs/Behaviors/behavior";
  35405. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35406. import { Observable } from "babylonjs/Misc/observable";
  35407. import { Vector3 } from "babylonjs/Maths/math";
  35408. import { Ray } from "babylonjs/Culling/ray";
  35409. import "babylonjs/Meshes/Builders/planeBuilder";
  35410. /**
  35411. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35412. */
  35413. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35414. private static _AnyMouseID;
  35415. private _attachedNode;
  35416. private _dragPlane;
  35417. private _scene;
  35418. private _pointerObserver;
  35419. private _beforeRenderObserver;
  35420. private static _planeScene;
  35421. /**
  35422. * 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)
  35423. */
  35424. maxDragAngle: number;
  35425. /**
  35426. * @hidden
  35427. */
  35428. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35429. /**
  35430. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35431. */
  35432. currentDraggingPointerID: number;
  35433. /**
  35434. * The last position where the pointer hit the drag plane in world space
  35435. */
  35436. lastDragPosition: Vector3;
  35437. /**
  35438. * If the behavior is currently in a dragging state
  35439. */
  35440. dragging: boolean;
  35441. /**
  35442. * 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)
  35443. */
  35444. dragDeltaRatio: number;
  35445. /**
  35446. * If the drag plane orientation should be updated during the dragging (Default: true)
  35447. */
  35448. updateDragPlane: boolean;
  35449. private _debugMode;
  35450. private _moving;
  35451. /**
  35452. * Fires each time the attached mesh is dragged with the pointer
  35453. * * delta between last drag position and current drag position in world space
  35454. * * dragDistance along the drag axis
  35455. * * dragPlaneNormal normal of the current drag plane used during the drag
  35456. * * dragPlanePoint in world space where the drag intersects the drag plane
  35457. */
  35458. onDragObservable: Observable<{
  35459. delta: Vector3;
  35460. dragPlanePoint: Vector3;
  35461. dragPlaneNormal: Vector3;
  35462. dragDistance: number;
  35463. pointerId: number;
  35464. }>;
  35465. /**
  35466. * Fires each time a drag begins (eg. mouse down on mesh)
  35467. */
  35468. onDragStartObservable: Observable<{
  35469. dragPlanePoint: Vector3;
  35470. pointerId: number;
  35471. }>;
  35472. /**
  35473. * Fires each time a drag ends (eg. mouse release after drag)
  35474. */
  35475. onDragEndObservable: Observable<{
  35476. dragPlanePoint: Vector3;
  35477. pointerId: number;
  35478. }>;
  35479. /**
  35480. * If the attached mesh should be moved when dragged
  35481. */
  35482. moveAttached: boolean;
  35483. /**
  35484. * If the drag behavior will react to drag events (Default: true)
  35485. */
  35486. enabled: boolean;
  35487. /**
  35488. * If camera controls should be detached during the drag
  35489. */
  35490. detachCameraControls: boolean;
  35491. /**
  35492. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35493. */
  35494. useObjectOrienationForDragging: boolean;
  35495. private _options;
  35496. /**
  35497. * Creates a pointer drag behavior that can be attached to a mesh
  35498. * @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)
  35499. */
  35500. constructor(options?: {
  35501. dragAxis?: Vector3;
  35502. dragPlaneNormal?: Vector3;
  35503. });
  35504. /**
  35505. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35506. */
  35507. validateDrag: (targetPosition: Vector3) => boolean;
  35508. /**
  35509. * The name of the behavior
  35510. */
  35511. readonly name: string;
  35512. /**
  35513. * Initializes the behavior
  35514. */
  35515. init(): void;
  35516. private _tmpVector;
  35517. private _alternatePickedPoint;
  35518. private _worldDragAxis;
  35519. private _targetPosition;
  35520. private _attachedElement;
  35521. /**
  35522. * Attaches the drag behavior the passed in mesh
  35523. * @param ownerNode The mesh that will be dragged around once attached
  35524. */
  35525. attach(ownerNode: AbstractMesh): void;
  35526. /**
  35527. * Force relase the drag action by code.
  35528. */
  35529. releaseDrag(): void;
  35530. private _startDragRay;
  35531. private _lastPointerRay;
  35532. /**
  35533. * Simulates the start of a pointer drag event on the behavior
  35534. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35535. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35536. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35537. */
  35538. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35539. private _startDrag;
  35540. private _dragDelta;
  35541. private _moveDrag;
  35542. private _pickWithRayOnDragPlane;
  35543. private _pointA;
  35544. private _pointB;
  35545. private _pointC;
  35546. private _lineA;
  35547. private _lineB;
  35548. private _localAxis;
  35549. private _lookAt;
  35550. private _updateDragPlanePosition;
  35551. /**
  35552. * Detaches the behavior from the mesh
  35553. */
  35554. detach(): void;
  35555. }
  35556. }
  35557. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  35558. import { Mesh } from "babylonjs/Meshes/mesh";
  35559. import { Behavior } from "babylonjs/Behaviors/behavior";
  35560. /**
  35561. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35562. */
  35563. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35564. private _dragBehaviorA;
  35565. private _dragBehaviorB;
  35566. private _startDistance;
  35567. private _initialScale;
  35568. private _targetScale;
  35569. private _ownerNode;
  35570. private _sceneRenderObserver;
  35571. /**
  35572. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35573. */
  35574. constructor();
  35575. /**
  35576. * The name of the behavior
  35577. */
  35578. readonly name: string;
  35579. /**
  35580. * Initializes the behavior
  35581. */
  35582. init(): void;
  35583. private _getCurrentDistance;
  35584. /**
  35585. * Attaches the scale behavior the passed in mesh
  35586. * @param ownerNode The mesh that will be scaled around once attached
  35587. */
  35588. attach(ownerNode: Mesh): void;
  35589. /**
  35590. * Detaches the behavior from the mesh
  35591. */
  35592. detach(): void;
  35593. }
  35594. }
  35595. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  35596. import { Behavior } from "babylonjs/Behaviors/behavior";
  35597. import { Mesh } from "babylonjs/Meshes/mesh";
  35598. import { Observable } from "babylonjs/Misc/observable";
  35599. /**
  35600. * 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
  35601. */
  35602. export class SixDofDragBehavior implements Behavior<Mesh> {
  35603. private static _virtualScene;
  35604. private _ownerNode;
  35605. private _sceneRenderObserver;
  35606. private _scene;
  35607. private _targetPosition;
  35608. private _virtualOriginMesh;
  35609. private _virtualDragMesh;
  35610. private _pointerObserver;
  35611. private _moving;
  35612. private _startingOrientation;
  35613. /**
  35614. * 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)
  35615. */
  35616. private zDragFactor;
  35617. /**
  35618. * If the object should rotate to face the drag origin
  35619. */
  35620. rotateDraggedObject: boolean;
  35621. /**
  35622. * If the behavior is currently in a dragging state
  35623. */
  35624. dragging: boolean;
  35625. /**
  35626. * 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)
  35627. */
  35628. dragDeltaRatio: number;
  35629. /**
  35630. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35631. */
  35632. currentDraggingPointerID: number;
  35633. /**
  35634. * If camera controls should be detached during the drag
  35635. */
  35636. detachCameraControls: boolean;
  35637. /**
  35638. * Fires each time a drag starts
  35639. */
  35640. onDragStartObservable: Observable<{}>;
  35641. /**
  35642. * Fires each time a drag ends (eg. mouse release after drag)
  35643. */
  35644. onDragEndObservable: Observable<{}>;
  35645. /**
  35646. * 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
  35647. */
  35648. constructor();
  35649. /**
  35650. * The name of the behavior
  35651. */
  35652. readonly name: string;
  35653. /**
  35654. * Initializes the behavior
  35655. */
  35656. init(): void;
  35657. /**
  35658. * Attaches the scale behavior the passed in mesh
  35659. * @param ownerNode The mesh that will be scaled around once attached
  35660. */
  35661. attach(ownerNode: Mesh): void;
  35662. /**
  35663. * Detaches the behavior from the mesh
  35664. */
  35665. detach(): void;
  35666. }
  35667. }
  35668. declare module "babylonjs/Behaviors/Meshes/index" {
  35669. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  35670. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  35671. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  35672. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  35673. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  35674. }
  35675. declare module "babylonjs/Behaviors/index" {
  35676. export * from "babylonjs/Behaviors/behavior";
  35677. export * from "babylonjs/Behaviors/Cameras/index";
  35678. export * from "babylonjs/Behaviors/Meshes/index";
  35679. }
  35680. declare module "babylonjs/Bones/boneIKController" {
  35681. import { Bone } from "babylonjs/Bones/bone";
  35682. import { Vector3 } from "babylonjs/Maths/math";
  35683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35684. import { Nullable } from "babylonjs/types";
  35685. /**
  35686. * Class used to apply inverse kinematics to bones
  35687. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35688. */
  35689. export class BoneIKController {
  35690. private static _tmpVecs;
  35691. private static _tmpQuat;
  35692. private static _tmpMats;
  35693. /**
  35694. * Gets or sets the target mesh
  35695. */
  35696. targetMesh: AbstractMesh;
  35697. /** Gets or sets the mesh used as pole */
  35698. poleTargetMesh: AbstractMesh;
  35699. /**
  35700. * Gets or sets the bone used as pole
  35701. */
  35702. poleTargetBone: Nullable<Bone>;
  35703. /**
  35704. * Gets or sets the target position
  35705. */
  35706. targetPosition: Vector3;
  35707. /**
  35708. * Gets or sets the pole target position
  35709. */
  35710. poleTargetPosition: Vector3;
  35711. /**
  35712. * Gets or sets the pole target local offset
  35713. */
  35714. poleTargetLocalOffset: Vector3;
  35715. /**
  35716. * Gets or sets the pole angle
  35717. */
  35718. poleAngle: number;
  35719. /**
  35720. * Gets or sets the mesh associated with the controller
  35721. */
  35722. mesh: AbstractMesh;
  35723. /**
  35724. * 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)
  35725. */
  35726. slerpAmount: number;
  35727. private _bone1Quat;
  35728. private _bone1Mat;
  35729. private _bone2Ang;
  35730. private _bone1;
  35731. private _bone2;
  35732. private _bone1Length;
  35733. private _bone2Length;
  35734. private _maxAngle;
  35735. private _maxReach;
  35736. private _rightHandedSystem;
  35737. private _bendAxis;
  35738. private _slerping;
  35739. private _adjustRoll;
  35740. /**
  35741. * Gets or sets maximum allowed angle
  35742. */
  35743. maxAngle: number;
  35744. /**
  35745. * Creates a new BoneIKController
  35746. * @param mesh defines the mesh to control
  35747. * @param bone defines the bone to control
  35748. * @param options defines options to set up the controller
  35749. */
  35750. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35751. targetMesh?: AbstractMesh;
  35752. poleTargetMesh?: AbstractMesh;
  35753. poleTargetBone?: Bone;
  35754. poleTargetLocalOffset?: Vector3;
  35755. poleAngle?: number;
  35756. bendAxis?: Vector3;
  35757. maxAngle?: number;
  35758. slerpAmount?: number;
  35759. });
  35760. private _setMaxAngle;
  35761. /**
  35762. * Force the controller to update the bones
  35763. */
  35764. update(): void;
  35765. }
  35766. }
  35767. declare module "babylonjs/Bones/boneLookController" {
  35768. import { Vector3, Space } from "babylonjs/Maths/math";
  35769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35770. import { Bone } from "babylonjs/Bones/bone";
  35771. /**
  35772. * Class used to make a bone look toward a point in space
  35773. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35774. */
  35775. export class BoneLookController {
  35776. private static _tmpVecs;
  35777. private static _tmpQuat;
  35778. private static _tmpMats;
  35779. /**
  35780. * The target Vector3 that the bone will look at
  35781. */
  35782. target: Vector3;
  35783. /**
  35784. * The mesh that the bone is attached to
  35785. */
  35786. mesh: AbstractMesh;
  35787. /**
  35788. * The bone that will be looking to the target
  35789. */
  35790. bone: Bone;
  35791. /**
  35792. * The up axis of the coordinate system that is used when the bone is rotated
  35793. */
  35794. upAxis: Vector3;
  35795. /**
  35796. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35797. */
  35798. upAxisSpace: Space;
  35799. /**
  35800. * Used to make an adjustment to the yaw of the bone
  35801. */
  35802. adjustYaw: number;
  35803. /**
  35804. * Used to make an adjustment to the pitch of the bone
  35805. */
  35806. adjustPitch: number;
  35807. /**
  35808. * Used to make an adjustment to the roll of the bone
  35809. */
  35810. adjustRoll: number;
  35811. /**
  35812. * 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)
  35813. */
  35814. slerpAmount: number;
  35815. private _minYaw;
  35816. private _maxYaw;
  35817. private _minPitch;
  35818. private _maxPitch;
  35819. private _minYawSin;
  35820. private _minYawCos;
  35821. private _maxYawSin;
  35822. private _maxYawCos;
  35823. private _midYawConstraint;
  35824. private _minPitchTan;
  35825. private _maxPitchTan;
  35826. private _boneQuat;
  35827. private _slerping;
  35828. private _transformYawPitch;
  35829. private _transformYawPitchInv;
  35830. private _firstFrameSkipped;
  35831. private _yawRange;
  35832. private _fowardAxis;
  35833. /**
  35834. * Gets or sets the minimum yaw angle that the bone can look to
  35835. */
  35836. minYaw: number;
  35837. /**
  35838. * Gets or sets the maximum yaw angle that the bone can look to
  35839. */
  35840. maxYaw: number;
  35841. /**
  35842. * Gets or sets the minimum pitch angle that the bone can look to
  35843. */
  35844. minPitch: number;
  35845. /**
  35846. * Gets or sets the maximum pitch angle that the bone can look to
  35847. */
  35848. maxPitch: number;
  35849. /**
  35850. * Create a BoneLookController
  35851. * @param mesh the mesh that the bone belongs to
  35852. * @param bone the bone that will be looking to the target
  35853. * @param target the target Vector3 to look at
  35854. * @param options optional settings:
  35855. * * maxYaw: the maximum angle the bone will yaw to
  35856. * * minYaw: the minimum angle the bone will yaw to
  35857. * * maxPitch: the maximum angle the bone will pitch to
  35858. * * minPitch: the minimum angle the bone will yaw to
  35859. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35860. * * upAxis: the up axis of the coordinate system
  35861. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35862. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35863. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35864. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35865. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35866. * * adjustRoll: used to make an adjustment to the roll of the bone
  35867. **/
  35868. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35869. maxYaw?: number;
  35870. minYaw?: number;
  35871. maxPitch?: number;
  35872. minPitch?: number;
  35873. slerpAmount?: number;
  35874. upAxis?: Vector3;
  35875. upAxisSpace?: Space;
  35876. yawAxis?: Vector3;
  35877. pitchAxis?: Vector3;
  35878. adjustYaw?: number;
  35879. adjustPitch?: number;
  35880. adjustRoll?: number;
  35881. });
  35882. /**
  35883. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35884. */
  35885. update(): void;
  35886. private _getAngleDiff;
  35887. private _getAngleBetween;
  35888. private _isAngleBetween;
  35889. }
  35890. }
  35891. declare module "babylonjs/Bones/index" {
  35892. export * from "babylonjs/Bones/bone";
  35893. export * from "babylonjs/Bones/boneIKController";
  35894. export * from "babylonjs/Bones/boneLookController";
  35895. export * from "babylonjs/Bones/skeleton";
  35896. }
  35897. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  35898. import { Nullable } from "babylonjs/types";
  35899. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35900. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35901. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  35902. /**
  35903. * Manage the gamepad inputs to control an arc rotate camera.
  35904. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35905. */
  35906. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35907. /**
  35908. * Defines the camera the input is attached to.
  35909. */
  35910. camera: ArcRotateCamera;
  35911. /**
  35912. * Defines the gamepad the input is gathering event from.
  35913. */
  35914. gamepad: Nullable<Gamepad>;
  35915. /**
  35916. * Defines the gamepad rotation sensiblity.
  35917. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35918. */
  35919. gamepadRotationSensibility: number;
  35920. /**
  35921. * Defines the gamepad move sensiblity.
  35922. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35923. */
  35924. gamepadMoveSensibility: number;
  35925. private _onGamepadConnectedObserver;
  35926. private _onGamepadDisconnectedObserver;
  35927. /**
  35928. * Attach the input controls to a specific dom element to get the input from.
  35929. * @param element Defines the element the controls should be listened from
  35930. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35931. */
  35932. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35933. /**
  35934. * Detach the current controls from the specified dom element.
  35935. * @param element Defines the element to stop listening the inputs from
  35936. */
  35937. detachControl(element: Nullable<HTMLElement>): void;
  35938. /**
  35939. * Update the current camera state depending on the inputs that have been used this frame.
  35940. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35941. */
  35942. checkInputs(): void;
  35943. /**
  35944. * Gets the class name of the current intput.
  35945. * @returns the class name
  35946. */
  35947. getClassName(): string;
  35948. /**
  35949. * Get the friendly name associated with the input class.
  35950. * @returns the input friendly name
  35951. */
  35952. getSimpleName(): string;
  35953. }
  35954. }
  35955. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  35956. import { Nullable } from "babylonjs/types";
  35957. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35958. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35959. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35960. interface ArcRotateCameraInputsManager {
  35961. /**
  35962. * Add orientation input support to the input manager.
  35963. * @returns the current input manager
  35964. */
  35965. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35966. }
  35967. }
  35968. /**
  35969. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35970. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35971. */
  35972. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35973. /**
  35974. * Defines the camera the input is attached to.
  35975. */
  35976. camera: ArcRotateCamera;
  35977. /**
  35978. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35979. */
  35980. alphaCorrection: number;
  35981. /**
  35982. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35983. */
  35984. gammaCorrection: number;
  35985. private _alpha;
  35986. private _gamma;
  35987. private _dirty;
  35988. private _deviceOrientationHandler;
  35989. /**
  35990. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35991. */
  35992. constructor();
  35993. /**
  35994. * Attach the input controls to a specific dom element to get the input from.
  35995. * @param element Defines the element the controls should be listened from
  35996. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35997. */
  35998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35999. /** @hidden */
  36000. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36001. /**
  36002. * Update the current camera state depending on the inputs that have been used this frame.
  36003. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36004. */
  36005. checkInputs(): void;
  36006. /**
  36007. * Detach the current controls from the specified dom element.
  36008. * @param element Defines the element to stop listening the inputs from
  36009. */
  36010. detachControl(element: Nullable<HTMLElement>): void;
  36011. /**
  36012. * Gets the class name of the current intput.
  36013. * @returns the class name
  36014. */
  36015. getClassName(): string;
  36016. /**
  36017. * Get the friendly name associated with the input class.
  36018. * @returns the input friendly name
  36019. */
  36020. getSimpleName(): string;
  36021. }
  36022. }
  36023. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  36024. import { Nullable } from "babylonjs/types";
  36025. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36026. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36027. /**
  36028. * Listen to mouse events to control the camera.
  36029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36030. */
  36031. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36032. /**
  36033. * Defines the camera the input is attached to.
  36034. */
  36035. camera: FlyCamera;
  36036. /**
  36037. * Defines if touch is enabled. (Default is true.)
  36038. */
  36039. touchEnabled: boolean;
  36040. /**
  36041. * Defines the buttons associated with the input to handle camera rotation.
  36042. */
  36043. buttons: number[];
  36044. /**
  36045. * Assign buttons for Yaw control.
  36046. */
  36047. buttonsYaw: number[];
  36048. /**
  36049. * Assign buttons for Pitch control.
  36050. */
  36051. buttonsPitch: number[];
  36052. /**
  36053. * Assign buttons for Roll control.
  36054. */
  36055. buttonsRoll: number[];
  36056. /**
  36057. * Detect if any button is being pressed while mouse is moved.
  36058. * -1 = Mouse locked.
  36059. * 0 = Left button.
  36060. * 1 = Middle Button.
  36061. * 2 = Right Button.
  36062. */
  36063. activeButton: number;
  36064. /**
  36065. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36066. * Higher values reduce its sensitivity.
  36067. */
  36068. angularSensibility: number;
  36069. private _mousemoveCallback;
  36070. private _observer;
  36071. private _rollObserver;
  36072. private previousPosition;
  36073. private noPreventDefault;
  36074. private element;
  36075. /**
  36076. * Listen to mouse events to control the camera.
  36077. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36079. */
  36080. constructor(touchEnabled?: boolean);
  36081. /**
  36082. * Attach the mouse control to the HTML DOM element.
  36083. * @param element Defines the element that listens to the input events.
  36084. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36085. */
  36086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36087. /**
  36088. * Detach the current controls from the specified dom element.
  36089. * @param element Defines the element to stop listening the inputs from
  36090. */
  36091. detachControl(element: Nullable<HTMLElement>): void;
  36092. /**
  36093. * Gets the class name of the current input.
  36094. * @returns the class name.
  36095. */
  36096. getClassName(): string;
  36097. /**
  36098. * Get the friendly name associated with the input class.
  36099. * @returns the input's friendly name.
  36100. */
  36101. getSimpleName(): string;
  36102. private _pointerInput;
  36103. private _onMouseMove;
  36104. /**
  36105. * Rotate camera by mouse offset.
  36106. */
  36107. private rotateCamera;
  36108. }
  36109. }
  36110. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  36111. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36112. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36113. /**
  36114. * Default Inputs manager for the FlyCamera.
  36115. * It groups all the default supported inputs for ease of use.
  36116. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36117. */
  36118. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36119. /**
  36120. * Instantiates a new FlyCameraInputsManager.
  36121. * @param camera Defines the camera the inputs belong to.
  36122. */
  36123. constructor(camera: FlyCamera);
  36124. /**
  36125. * Add keyboard input support to the input manager.
  36126. * @returns the new FlyCameraKeyboardMoveInput().
  36127. */
  36128. addKeyboard(): FlyCameraInputsManager;
  36129. /**
  36130. * Add mouse input support to the input manager.
  36131. * @param touchEnabled Enable touch screen support.
  36132. * @returns the new FlyCameraMouseInput().
  36133. */
  36134. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36135. }
  36136. }
  36137. declare module "babylonjs/Cameras/flyCamera" {
  36138. import { Scene } from "babylonjs/scene";
  36139. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  36140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36141. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36142. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  36143. /**
  36144. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36145. * such as in a 3D Space Shooter or a Flight Simulator.
  36146. */
  36147. export class FlyCamera extends TargetCamera {
  36148. /**
  36149. * Define the collision ellipsoid of the camera.
  36150. * This is helpful for simulating a camera body, like a player's body.
  36151. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36152. */
  36153. ellipsoid: Vector3;
  36154. /**
  36155. * Define an offset for the position of the ellipsoid around the camera.
  36156. * This can be helpful if the camera is attached away from the player's body center,
  36157. * such as at its head.
  36158. */
  36159. ellipsoidOffset: Vector3;
  36160. /**
  36161. * Enable or disable collisions of the camera with the rest of the scene objects.
  36162. */
  36163. checkCollisions: boolean;
  36164. /**
  36165. * Enable or disable gravity on the camera.
  36166. */
  36167. applyGravity: boolean;
  36168. /**
  36169. * Define the current direction the camera is moving to.
  36170. */
  36171. cameraDirection: Vector3;
  36172. /**
  36173. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36174. * This overrides and empties cameraRotation.
  36175. */
  36176. rotationQuaternion: Quaternion;
  36177. /**
  36178. * Track Roll to maintain the wanted Rolling when looking around.
  36179. */
  36180. _trackRoll: number;
  36181. /**
  36182. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36183. */
  36184. rollCorrect: number;
  36185. /**
  36186. * Mimic a banked turn, Rolling the camera when Yawing.
  36187. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36188. */
  36189. bankedTurn: boolean;
  36190. /**
  36191. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36192. */
  36193. bankedTurnLimit: number;
  36194. /**
  36195. * Value of 0 disables the banked Roll.
  36196. * Value of 1 is equal to the Yaw angle in radians.
  36197. */
  36198. bankedTurnMultiplier: number;
  36199. /**
  36200. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36201. */
  36202. inputs: FlyCameraInputsManager;
  36203. /**
  36204. * Gets the input sensibility for mouse input.
  36205. * Higher values reduce sensitivity.
  36206. */
  36207. /**
  36208. * Sets the input sensibility for a mouse input.
  36209. * Higher values reduce sensitivity.
  36210. */
  36211. angularSensibility: number;
  36212. /**
  36213. * Get the keys for camera movement forward.
  36214. */
  36215. /**
  36216. * Set the keys for camera movement forward.
  36217. */
  36218. keysForward: number[];
  36219. /**
  36220. * Get the keys for camera movement backward.
  36221. */
  36222. keysBackward: number[];
  36223. /**
  36224. * Get the keys for camera movement up.
  36225. */
  36226. /**
  36227. * Set the keys for camera movement up.
  36228. */
  36229. keysUp: number[];
  36230. /**
  36231. * Get the keys for camera movement down.
  36232. */
  36233. /**
  36234. * Set the keys for camera movement down.
  36235. */
  36236. keysDown: number[];
  36237. /**
  36238. * Get the keys for camera movement left.
  36239. */
  36240. /**
  36241. * Set the keys for camera movement left.
  36242. */
  36243. keysLeft: number[];
  36244. /**
  36245. * Set the keys for camera movement right.
  36246. */
  36247. /**
  36248. * Set the keys for camera movement right.
  36249. */
  36250. keysRight: number[];
  36251. /**
  36252. * Event raised when the camera collides with a mesh in the scene.
  36253. */
  36254. onCollide: (collidedMesh: AbstractMesh) => void;
  36255. private _collider;
  36256. private _needMoveForGravity;
  36257. private _oldPosition;
  36258. private _diffPosition;
  36259. private _newPosition;
  36260. /** @hidden */
  36261. _localDirection: Vector3;
  36262. /** @hidden */
  36263. _transformedDirection: Vector3;
  36264. /**
  36265. * Instantiates a FlyCamera.
  36266. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36267. * such as in a 3D Space Shooter or a Flight Simulator.
  36268. * @param name Define the name of the camera in the scene.
  36269. * @param position Define the starting position of the camera in the scene.
  36270. * @param scene Define the scene the camera belongs to.
  36271. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36272. */
  36273. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36274. /**
  36275. * Attach a control to the HTML DOM element.
  36276. * @param element Defines the element that listens to the input events.
  36277. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36278. */
  36279. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36280. /**
  36281. * Detach a control from the HTML DOM element.
  36282. * The camera will stop reacting to that input.
  36283. * @param element Defines the element that listens to the input events.
  36284. */
  36285. detachControl(element: HTMLElement): void;
  36286. private _collisionMask;
  36287. /**
  36288. * Get the mask that the camera ignores in collision events.
  36289. */
  36290. /**
  36291. * Set the mask that the camera ignores in collision events.
  36292. */
  36293. collisionMask: number;
  36294. /** @hidden */
  36295. _collideWithWorld(displacement: Vector3): void;
  36296. /** @hidden */
  36297. private _onCollisionPositionChange;
  36298. /** @hidden */
  36299. _checkInputs(): void;
  36300. /** @hidden */
  36301. _decideIfNeedsToMove(): boolean;
  36302. /** @hidden */
  36303. _updatePosition(): void;
  36304. /**
  36305. * Restore the Roll to its target value at the rate specified.
  36306. * @param rate - Higher means slower restoring.
  36307. * @hidden
  36308. */
  36309. restoreRoll(rate: number): void;
  36310. /**
  36311. * Destroy the camera and release the current resources held by it.
  36312. */
  36313. dispose(): void;
  36314. /**
  36315. * Get the current object class name.
  36316. * @returns the class name.
  36317. */
  36318. getClassName(): string;
  36319. }
  36320. }
  36321. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  36322. import { Nullable } from "babylonjs/types";
  36323. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36324. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  36325. /**
  36326. * Listen to keyboard events to control the camera.
  36327. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36328. */
  36329. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36330. /**
  36331. * Defines the camera the input is attached to.
  36332. */
  36333. camera: FlyCamera;
  36334. /**
  36335. * The list of keyboard keys used to control the forward move of the camera.
  36336. */
  36337. keysForward: number[];
  36338. /**
  36339. * The list of keyboard keys used to control the backward move of the camera.
  36340. */
  36341. keysBackward: number[];
  36342. /**
  36343. * The list of keyboard keys used to control the forward move of the camera.
  36344. */
  36345. keysUp: number[];
  36346. /**
  36347. * The list of keyboard keys used to control the backward move of the camera.
  36348. */
  36349. keysDown: number[];
  36350. /**
  36351. * The list of keyboard keys used to control the right strafe move of the camera.
  36352. */
  36353. keysRight: number[];
  36354. /**
  36355. * The list of keyboard keys used to control the left strafe move of the camera.
  36356. */
  36357. keysLeft: number[];
  36358. private _keys;
  36359. private _onCanvasBlurObserver;
  36360. private _onKeyboardObserver;
  36361. private _engine;
  36362. private _scene;
  36363. /**
  36364. * Attach the input controls to a specific dom element to get the input from.
  36365. * @param element Defines the element the controls should be listened from
  36366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36367. */
  36368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36369. /**
  36370. * Detach the current controls from the specified dom element.
  36371. * @param element Defines the element to stop listening the inputs from
  36372. */
  36373. detachControl(element: Nullable<HTMLElement>): void;
  36374. /**
  36375. * Gets the class name of the current intput.
  36376. * @returns the class name
  36377. */
  36378. getClassName(): string;
  36379. /** @hidden */
  36380. _onLostFocus(e: FocusEvent): void;
  36381. /**
  36382. * Get the friendly name associated with the input class.
  36383. * @returns the input friendly name
  36384. */
  36385. getSimpleName(): string;
  36386. /**
  36387. * Update the current camera state depending on the inputs that have been used this frame.
  36388. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36389. */
  36390. checkInputs(): void;
  36391. }
  36392. }
  36393. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  36394. import { Nullable } from "babylonjs/types";
  36395. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36396. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36397. module "babylonjs/Cameras/freeCameraInputsManager" {
  36398. interface FreeCameraInputsManager {
  36399. /**
  36400. * Add orientation input support to the input manager.
  36401. * @returns the current input manager
  36402. */
  36403. addDeviceOrientation(): FreeCameraInputsManager;
  36404. }
  36405. }
  36406. /**
  36407. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36408. * Screen rotation is taken into account.
  36409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36410. */
  36411. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36412. private _camera;
  36413. private _screenOrientationAngle;
  36414. private _constantTranform;
  36415. private _screenQuaternion;
  36416. private _alpha;
  36417. private _beta;
  36418. private _gamma;
  36419. /**
  36420. * Instantiates a new input
  36421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36422. */
  36423. constructor();
  36424. /**
  36425. * Define the camera controlled by the input.
  36426. */
  36427. camera: FreeCamera;
  36428. /**
  36429. * Attach the input controls to a specific dom element to get the input from.
  36430. * @param element Defines the element the controls should be listened from
  36431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36432. */
  36433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36434. private _orientationChanged;
  36435. private _deviceOrientation;
  36436. /**
  36437. * Detach the current controls from the specified dom element.
  36438. * @param element Defines the element to stop listening the inputs from
  36439. */
  36440. detachControl(element: Nullable<HTMLElement>): void;
  36441. /**
  36442. * Update the current camera state depending on the inputs that have been used this frame.
  36443. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36444. */
  36445. checkInputs(): void;
  36446. /**
  36447. * Gets the class name of the current intput.
  36448. * @returns the class name
  36449. */
  36450. getClassName(): string;
  36451. /**
  36452. * Get the friendly name associated with the input class.
  36453. * @returns the input friendly name
  36454. */
  36455. getSimpleName(): string;
  36456. }
  36457. }
  36458. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  36459. import { Nullable } from "babylonjs/types";
  36460. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36461. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36462. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  36463. /**
  36464. * Manage the gamepad inputs to control a free camera.
  36465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36466. */
  36467. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36468. /**
  36469. * Define the camera the input is attached to.
  36470. */
  36471. camera: FreeCamera;
  36472. /**
  36473. * Define the Gamepad controlling the input
  36474. */
  36475. gamepad: Nullable<Gamepad>;
  36476. /**
  36477. * Defines the gamepad rotation sensiblity.
  36478. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36479. */
  36480. gamepadAngularSensibility: number;
  36481. /**
  36482. * Defines the gamepad move sensiblity.
  36483. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36484. */
  36485. gamepadMoveSensibility: number;
  36486. private _onGamepadConnectedObserver;
  36487. private _onGamepadDisconnectedObserver;
  36488. private _cameraTransform;
  36489. private _deltaTransform;
  36490. private _vector3;
  36491. private _vector2;
  36492. /**
  36493. * Attach the input controls to a specific dom element to get the input from.
  36494. * @param element Defines the element the controls should be listened from
  36495. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36496. */
  36497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36498. /**
  36499. * Detach the current controls from the specified dom element.
  36500. * @param element Defines the element to stop listening the inputs from
  36501. */
  36502. detachControl(element: Nullable<HTMLElement>): void;
  36503. /**
  36504. * Update the current camera state depending on the inputs that have been used this frame.
  36505. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36506. */
  36507. checkInputs(): void;
  36508. /**
  36509. * Gets the class name of the current intput.
  36510. * @returns the class name
  36511. */
  36512. getClassName(): string;
  36513. /**
  36514. * Get the friendly name associated with the input class.
  36515. * @returns the input friendly name
  36516. */
  36517. getSimpleName(): string;
  36518. }
  36519. }
  36520. declare module "babylonjs/Misc/virtualJoystick" {
  36521. import { Nullable } from "babylonjs/types";
  36522. import { Vector3 } from "babylonjs/Maths/math";
  36523. /**
  36524. * Defines the potential axis of a Joystick
  36525. */
  36526. export enum JoystickAxis {
  36527. /** X axis */
  36528. X = 0,
  36529. /** Y axis */
  36530. Y = 1,
  36531. /** Z axis */
  36532. Z = 2
  36533. }
  36534. /**
  36535. * Class used to define virtual joystick (used in touch mode)
  36536. */
  36537. export class VirtualJoystick {
  36538. /**
  36539. * Gets or sets a boolean indicating that left and right values must be inverted
  36540. */
  36541. reverseLeftRight: boolean;
  36542. /**
  36543. * Gets or sets a boolean indicating that up and down values must be inverted
  36544. */
  36545. reverseUpDown: boolean;
  36546. /**
  36547. * Gets the offset value for the position (ie. the change of the position value)
  36548. */
  36549. deltaPosition: Vector3;
  36550. /**
  36551. * Gets a boolean indicating if the virtual joystick was pressed
  36552. */
  36553. pressed: boolean;
  36554. /**
  36555. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36556. */
  36557. static Canvas: Nullable<HTMLCanvasElement>;
  36558. private static _globalJoystickIndex;
  36559. private static vjCanvasContext;
  36560. private static vjCanvasWidth;
  36561. private static vjCanvasHeight;
  36562. private static halfWidth;
  36563. private _action;
  36564. private _axisTargetedByLeftAndRight;
  36565. private _axisTargetedByUpAndDown;
  36566. private _joystickSensibility;
  36567. private _inversedSensibility;
  36568. private _joystickPointerID;
  36569. private _joystickColor;
  36570. private _joystickPointerPos;
  36571. private _joystickPreviousPointerPos;
  36572. private _joystickPointerStartPos;
  36573. private _deltaJoystickVector;
  36574. private _leftJoystick;
  36575. private _touches;
  36576. private _onPointerDownHandlerRef;
  36577. private _onPointerMoveHandlerRef;
  36578. private _onPointerUpHandlerRef;
  36579. private _onResize;
  36580. /**
  36581. * Creates a new virtual joystick
  36582. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36583. */
  36584. constructor(leftJoystick?: boolean);
  36585. /**
  36586. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36587. * @param newJoystickSensibility defines the new sensibility
  36588. */
  36589. setJoystickSensibility(newJoystickSensibility: number): void;
  36590. private _onPointerDown;
  36591. private _onPointerMove;
  36592. private _onPointerUp;
  36593. /**
  36594. * Change the color of the virtual joystick
  36595. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36596. */
  36597. setJoystickColor(newColor: string): void;
  36598. /**
  36599. * Defines a callback to call when the joystick is touched
  36600. * @param action defines the callback
  36601. */
  36602. setActionOnTouch(action: () => any): void;
  36603. /**
  36604. * Defines which axis you'd like to control for left & right
  36605. * @param axis defines the axis to use
  36606. */
  36607. setAxisForLeftRight(axis: JoystickAxis): void;
  36608. /**
  36609. * Defines which axis you'd like to control for up & down
  36610. * @param axis defines the axis to use
  36611. */
  36612. setAxisForUpDown(axis: JoystickAxis): void;
  36613. private _drawVirtualJoystick;
  36614. /**
  36615. * Release internal HTML canvas
  36616. */
  36617. releaseCanvas(): void;
  36618. }
  36619. }
  36620. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  36621. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  36622. import { Nullable } from "babylonjs/types";
  36623. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36624. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36625. module "babylonjs/Cameras/freeCameraInputsManager" {
  36626. interface FreeCameraInputsManager {
  36627. /**
  36628. * Add virtual joystick input support to the input manager.
  36629. * @returns the current input manager
  36630. */
  36631. addVirtualJoystick(): FreeCameraInputsManager;
  36632. }
  36633. }
  36634. /**
  36635. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36636. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36637. */
  36638. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36639. /**
  36640. * Defines the camera the input is attached to.
  36641. */
  36642. camera: FreeCamera;
  36643. private _leftjoystick;
  36644. private _rightjoystick;
  36645. /**
  36646. * Gets the left stick of the virtual joystick.
  36647. * @returns The virtual Joystick
  36648. */
  36649. getLeftJoystick(): VirtualJoystick;
  36650. /**
  36651. * Gets the right stick of the virtual joystick.
  36652. * @returns The virtual Joystick
  36653. */
  36654. getRightJoystick(): VirtualJoystick;
  36655. /**
  36656. * Update the current camera state depending on the inputs that have been used this frame.
  36657. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36658. */
  36659. checkInputs(): void;
  36660. /**
  36661. * Attach the input controls to a specific dom element to get the input from.
  36662. * @param element Defines the element the controls should be listened from
  36663. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36664. */
  36665. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36666. /**
  36667. * Detach the current controls from the specified dom element.
  36668. * @param element Defines the element to stop listening the inputs from
  36669. */
  36670. detachControl(element: Nullable<HTMLElement>): void;
  36671. /**
  36672. * Gets the class name of the current intput.
  36673. * @returns the class name
  36674. */
  36675. getClassName(): string;
  36676. /**
  36677. * Get the friendly name associated with the input class.
  36678. * @returns the input friendly name
  36679. */
  36680. getSimpleName(): string;
  36681. }
  36682. }
  36683. declare module "babylonjs/Cameras/Inputs/index" {
  36684. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  36685. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  36686. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  36687. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  36688. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  36689. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  36690. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  36691. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36692. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  36693. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  36694. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  36695. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  36696. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  36697. }
  36698. declare module "babylonjs/Cameras/touchCamera" {
  36699. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36700. import { Scene } from "babylonjs/scene";
  36701. import { Vector3 } from "babylonjs/Maths/math";
  36702. /**
  36703. * This represents a FPS type of camera controlled by touch.
  36704. * This is like a universal camera minus the Gamepad controls.
  36705. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36706. */
  36707. export class TouchCamera extends FreeCamera {
  36708. /**
  36709. * Defines the touch sensibility for rotation.
  36710. * The higher the faster.
  36711. */
  36712. touchAngularSensibility: number;
  36713. /**
  36714. * Defines the touch sensibility for move.
  36715. * The higher the faster.
  36716. */
  36717. touchMoveSensibility: number;
  36718. /**
  36719. * Instantiates a new touch camera.
  36720. * This represents a FPS type of camera controlled by touch.
  36721. * This is like a universal camera minus the Gamepad controls.
  36722. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36723. * @param name Define the name of the camera in the scene
  36724. * @param position Define the start position of the camera in the scene
  36725. * @param scene Define the scene the camera belongs to
  36726. */
  36727. constructor(name: string, position: Vector3, scene: Scene);
  36728. /**
  36729. * Gets the current object class name.
  36730. * @return the class name
  36731. */
  36732. getClassName(): string;
  36733. /** @hidden */
  36734. _setupInputs(): void;
  36735. }
  36736. }
  36737. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  36738. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  36739. import { Scene } from "babylonjs/scene";
  36740. import { Vector3, Axis } from "babylonjs/Maths/math";
  36741. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  36742. /**
  36743. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36744. * being tilted forward or back and left or right.
  36745. */
  36746. export class DeviceOrientationCamera extends FreeCamera {
  36747. private _initialQuaternion;
  36748. private _quaternionCache;
  36749. /**
  36750. * Creates a new device orientation camera
  36751. * @param name The name of the camera
  36752. * @param position The start position camera
  36753. * @param scene The scene the camera belongs to
  36754. */
  36755. constructor(name: string, position: Vector3, scene: Scene);
  36756. /**
  36757. * Gets the current instance class name ("DeviceOrientationCamera").
  36758. * This helps avoiding instanceof at run time.
  36759. * @returns the class name
  36760. */
  36761. getClassName(): string;
  36762. /**
  36763. * @hidden
  36764. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36765. */
  36766. _checkInputs(): void;
  36767. /**
  36768. * Reset the camera to its default orientation on the specified axis only.
  36769. * @param axis The axis to reset
  36770. */
  36771. resetToCurrentRotation(axis?: Axis): void;
  36772. }
  36773. }
  36774. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  36775. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36776. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36777. import { Nullable } from "babylonjs/types";
  36778. /**
  36779. * Manage the keyboard inputs to control the movement of a follow camera.
  36780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36781. */
  36782. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36783. /**
  36784. * Defines the camera the input is attached to.
  36785. */
  36786. camera: FollowCamera;
  36787. /**
  36788. * Defines the list of key codes associated with the up action (increase heightOffset)
  36789. */
  36790. keysHeightOffsetIncr: number[];
  36791. /**
  36792. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36793. */
  36794. keysHeightOffsetDecr: number[];
  36795. /**
  36796. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36797. */
  36798. keysHeightOffsetModifierAlt: boolean;
  36799. /**
  36800. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36801. */
  36802. keysHeightOffsetModifierCtrl: boolean;
  36803. /**
  36804. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36805. */
  36806. keysHeightOffsetModifierShift: boolean;
  36807. /**
  36808. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36809. */
  36810. keysRotationOffsetIncr: number[];
  36811. /**
  36812. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36813. */
  36814. keysRotationOffsetDecr: number[];
  36815. /**
  36816. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36817. */
  36818. keysRotationOffsetModifierAlt: boolean;
  36819. /**
  36820. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36821. */
  36822. keysRotationOffsetModifierCtrl: boolean;
  36823. /**
  36824. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36825. */
  36826. keysRotationOffsetModifierShift: boolean;
  36827. /**
  36828. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36829. */
  36830. keysRadiusIncr: number[];
  36831. /**
  36832. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36833. */
  36834. keysRadiusDecr: number[];
  36835. /**
  36836. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36837. */
  36838. keysRadiusModifierAlt: boolean;
  36839. /**
  36840. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36841. */
  36842. keysRadiusModifierCtrl: boolean;
  36843. /**
  36844. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36845. */
  36846. keysRadiusModifierShift: boolean;
  36847. /**
  36848. * Defines the rate of change of heightOffset.
  36849. */
  36850. heightSensibility: number;
  36851. /**
  36852. * Defines the rate of change of rotationOffset.
  36853. */
  36854. rotationSensibility: number;
  36855. /**
  36856. * Defines the rate of change of radius.
  36857. */
  36858. radiusSensibility: number;
  36859. private _keys;
  36860. private _ctrlPressed;
  36861. private _altPressed;
  36862. private _shiftPressed;
  36863. private _onCanvasBlurObserver;
  36864. private _onKeyboardObserver;
  36865. private _engine;
  36866. private _scene;
  36867. /**
  36868. * Attach the input controls to a specific dom element to get the input from.
  36869. * @param element Defines the element the controls should be listened from
  36870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36871. */
  36872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36873. /**
  36874. * Detach the current controls from the specified dom element.
  36875. * @param element Defines the element to stop listening the inputs from
  36876. */
  36877. detachControl(element: Nullable<HTMLElement>): void;
  36878. /**
  36879. * Update the current camera state depending on the inputs that have been used this frame.
  36880. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36881. */
  36882. checkInputs(): void;
  36883. /**
  36884. * Gets the class name of the current input.
  36885. * @returns the class name
  36886. */
  36887. getClassName(): string;
  36888. /**
  36889. * Get the friendly name associated with the input class.
  36890. * @returns the input friendly name
  36891. */
  36892. getSimpleName(): string;
  36893. /**
  36894. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36895. * allow modification of the heightOffset value.
  36896. */
  36897. private _modifierHeightOffset;
  36898. /**
  36899. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36900. * allow modification of the rotationOffset value.
  36901. */
  36902. private _modifierRotationOffset;
  36903. /**
  36904. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36905. * allow modification of the radius value.
  36906. */
  36907. private _modifierRadius;
  36908. }
  36909. }
  36910. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  36911. import { Nullable } from "babylonjs/types";
  36912. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36913. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36914. /**
  36915. * Manage the mouse wheel inputs to control a follow camera.
  36916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36917. */
  36918. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36919. /**
  36920. * Defines the camera the input is attached to.
  36921. */
  36922. camera: FollowCamera;
  36923. /**
  36924. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  36925. */
  36926. axisControlRadius: boolean;
  36927. /**
  36928. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  36929. */
  36930. axisControlHeight: boolean;
  36931. /**
  36932. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  36933. */
  36934. axisControlRotation: boolean;
  36935. /**
  36936. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36937. * relation to mouseWheel events.
  36938. */
  36939. wheelPrecision: number;
  36940. /**
  36941. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36942. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36943. */
  36944. wheelDeltaPercentage: number;
  36945. private _wheel;
  36946. private _observer;
  36947. /**
  36948. * Attach the input controls to a specific dom element to get the input from.
  36949. * @param element Defines the element the controls should be listened from
  36950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36951. */
  36952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36953. /**
  36954. * Detach the current controls from the specified dom element.
  36955. * @param element Defines the element to stop listening the inputs from
  36956. */
  36957. detachControl(element: Nullable<HTMLElement>): void;
  36958. /**
  36959. * Gets the class name of the current intput.
  36960. * @returns the class name
  36961. */
  36962. getClassName(): string;
  36963. /**
  36964. * Get the friendly name associated with the input class.
  36965. * @returns the input friendly name
  36966. */
  36967. getSimpleName(): string;
  36968. }
  36969. }
  36970. declare module "babylonjs/Cameras/followCameraInputsManager" {
  36971. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36972. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  36973. /**
  36974. * Default Inputs manager for the FollowCamera.
  36975. * It groups all the default supported inputs for ease of use.
  36976. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36977. */
  36978. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36979. /**
  36980. * Instantiates a new FollowCameraInputsManager.
  36981. * @param camera Defines the camera the inputs belong to
  36982. */
  36983. constructor(camera: FollowCamera);
  36984. /**
  36985. * Add keyboard input support to the input manager.
  36986. * @returns the current input manager
  36987. */
  36988. addKeyboard(): FollowCameraInputsManager;
  36989. /**
  36990. * Add mouse wheel input support to the input manager.
  36991. * @returns the current input manager
  36992. */
  36993. addMouseWheel(): FollowCameraInputsManager;
  36994. /**
  36995. * Add pointers input support to the input manager.
  36996. * @returns the current input manager
  36997. */
  36998. addPointers(): FollowCameraInputsManager;
  36999. /**
  37000. * Add orientation input support to the input manager.
  37001. * @returns the current input manager
  37002. */
  37003. addVRDeviceOrientation(): FollowCameraInputsManager;
  37004. }
  37005. }
  37006. declare module "babylonjs/Cameras/followCamera" {
  37007. import { Nullable } from "babylonjs/types";
  37008. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37009. import { Scene } from "babylonjs/scene";
  37010. import { Vector3 } from "babylonjs/Maths/math";
  37011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37012. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37013. /**
  37014. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37015. * an arc rotate version arcFollowCamera are available.
  37016. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37017. */
  37018. export class FollowCamera extends TargetCamera {
  37019. /**
  37020. * Distance the follow camera should follow an object at
  37021. */
  37022. radius: number;
  37023. /**
  37024. * Minimum allowed distance of the camera to the axis of rotation
  37025. * (The camera can not get closer).
  37026. * This can help limiting how the Camera is able to move in the scene.
  37027. */
  37028. lowerRadiusLimit: Nullable<number>;
  37029. /**
  37030. * Maximum allowed distance of the camera to the axis of rotation
  37031. * (The camera can not get further).
  37032. * This can help limiting how the Camera is able to move in the scene.
  37033. */
  37034. upperRadiusLimit: Nullable<number>;
  37035. /**
  37036. * Define a rotation offset between the camera and the object it follows
  37037. */
  37038. rotationOffset: number;
  37039. /**
  37040. * Minimum allowed angle to camera position relative to target object.
  37041. * This can help limiting how the Camera is able to move in the scene.
  37042. */
  37043. lowerRotationOffsetLimit: Nullable<number>;
  37044. /**
  37045. * Maximum allowed angle to camera position relative to target object.
  37046. * This can help limiting how the Camera is able to move in the scene.
  37047. */
  37048. upperRotationOffsetLimit: Nullable<number>;
  37049. /**
  37050. * Define a height offset between the camera and the object it follows.
  37051. * It can help following an object from the top (like a car chaing a plane)
  37052. */
  37053. heightOffset: number;
  37054. /**
  37055. * Minimum allowed height of camera position relative to target object.
  37056. * This can help limiting how the Camera is able to move in the scene.
  37057. */
  37058. lowerHeightOffsetLimit: Nullable<number>;
  37059. /**
  37060. * Maximum allowed height of camera position relative to target object.
  37061. * This can help limiting how the Camera is able to move in the scene.
  37062. */
  37063. upperHeightOffsetLimit: Nullable<number>;
  37064. /**
  37065. * Define how fast the camera can accelerate to follow it s target.
  37066. */
  37067. cameraAcceleration: number;
  37068. /**
  37069. * Define the speed limit of the camera following an object.
  37070. */
  37071. maxCameraSpeed: number;
  37072. /**
  37073. * Define the target of the camera.
  37074. */
  37075. lockedTarget: Nullable<AbstractMesh>;
  37076. /**
  37077. * Defines the input associated with the camera.
  37078. */
  37079. inputs: FollowCameraInputsManager;
  37080. /**
  37081. * Instantiates the follow camera.
  37082. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37083. * @param name Define the name of the camera in the scene
  37084. * @param position Define the position of the camera
  37085. * @param scene Define the scene the camera belong to
  37086. * @param lockedTarget Define the target of the camera
  37087. */
  37088. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37089. private _follow;
  37090. /**
  37091. * Attached controls to the current camera.
  37092. * @param element Defines the element the controls should be listened from
  37093. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37094. */
  37095. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37096. /**
  37097. * Detach the current controls from the camera.
  37098. * The camera will stop reacting to inputs.
  37099. * @param element Defines the element to stop listening the inputs from
  37100. */
  37101. detachControl(element: HTMLElement): void;
  37102. /** @hidden */
  37103. _checkInputs(): void;
  37104. private _checkLimits;
  37105. /**
  37106. * Gets the camera class name.
  37107. * @returns the class name
  37108. */
  37109. getClassName(): string;
  37110. }
  37111. /**
  37112. * Arc Rotate version of the follow camera.
  37113. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37114. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37115. */
  37116. export class ArcFollowCamera extends TargetCamera {
  37117. /** The longitudinal angle of the camera */
  37118. alpha: number;
  37119. /** The latitudinal angle of the camera */
  37120. beta: number;
  37121. /** The radius of the camera from its target */
  37122. radius: number;
  37123. /** Define the camera target (the messh it should follow) */
  37124. target: Nullable<AbstractMesh>;
  37125. private _cartesianCoordinates;
  37126. /**
  37127. * Instantiates a new ArcFollowCamera
  37128. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37129. * @param name Define the name of the camera
  37130. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37131. * @param beta Define the rotation angle of the camera around the elevation axis
  37132. * @param radius Define the radius of the camera from its target point
  37133. * @param target Define the target of the camera
  37134. * @param scene Define the scene the camera belongs to
  37135. */
  37136. constructor(name: string,
  37137. /** The longitudinal angle of the camera */
  37138. alpha: number,
  37139. /** The latitudinal angle of the camera */
  37140. beta: number,
  37141. /** The radius of the camera from its target */
  37142. radius: number,
  37143. /** Define the camera target (the messh it should follow) */
  37144. target: Nullable<AbstractMesh>, scene: Scene);
  37145. private _follow;
  37146. /** @hidden */
  37147. _checkInputs(): void;
  37148. /**
  37149. * Returns the class name of the object.
  37150. * It is mostly used internally for serialization purposes.
  37151. */
  37152. getClassName(): string;
  37153. }
  37154. }
  37155. declare module "babylonjs/Cameras/universalCamera" {
  37156. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  37157. import { Scene } from "babylonjs/scene";
  37158. import { Vector3 } from "babylonjs/Maths/math";
  37159. /**
  37160. * 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,
  37161. * which still works and will still be found in many Playgrounds.
  37162. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37163. */
  37164. export class UniversalCamera extends TouchCamera {
  37165. /**
  37166. * Defines the gamepad rotation sensiblity.
  37167. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37168. */
  37169. gamepadAngularSensibility: number;
  37170. /**
  37171. * Defines the gamepad move sensiblity.
  37172. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37173. */
  37174. gamepadMoveSensibility: number;
  37175. /**
  37176. * 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,
  37177. * which still works and will still be found in many Playgrounds.
  37178. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37179. * @param name Define the name of the camera in the scene
  37180. * @param position Define the start position of the camera in the scene
  37181. * @param scene Define the scene the camera belongs to
  37182. */
  37183. constructor(name: string, position: Vector3, scene: Scene);
  37184. /**
  37185. * Gets the current object class name.
  37186. * @return the class name
  37187. */
  37188. getClassName(): string;
  37189. }
  37190. }
  37191. declare module "babylonjs/Cameras/gamepadCamera" {
  37192. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37193. import { Scene } from "babylonjs/scene";
  37194. import { Vector3 } from "babylonjs/Maths/math";
  37195. /**
  37196. * This represents a FPS type of camera. This is only here for back compat purpose.
  37197. * Please use the UniversalCamera instead as both are identical.
  37198. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37199. */
  37200. export class GamepadCamera extends UniversalCamera {
  37201. /**
  37202. * Instantiates a new Gamepad Camera
  37203. * This represents a FPS type of camera. This is only here for back compat purpose.
  37204. * Please use the UniversalCamera instead as both are identical.
  37205. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37206. * @param name Define the name of the camera in the scene
  37207. * @param position Define the start position of the camera in the scene
  37208. * @param scene Define the scene the camera belongs to
  37209. */
  37210. constructor(name: string, position: Vector3, scene: Scene);
  37211. /**
  37212. * Gets the current object class name.
  37213. * @return the class name
  37214. */
  37215. getClassName(): string;
  37216. }
  37217. }
  37218. declare module "babylonjs/Shaders/pass.fragment" {
  37219. /** @hidden */
  37220. export var passPixelShader: {
  37221. name: string;
  37222. shader: string;
  37223. };
  37224. }
  37225. declare module "babylonjs/Shaders/passCube.fragment" {
  37226. /** @hidden */
  37227. export var passCubePixelShader: {
  37228. name: string;
  37229. shader: string;
  37230. };
  37231. }
  37232. declare module "babylonjs/PostProcesses/passPostProcess" {
  37233. import { Nullable } from "babylonjs/types";
  37234. import { Camera } from "babylonjs/Cameras/camera";
  37235. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37236. import { Engine } from "babylonjs/Engines/engine";
  37237. import "babylonjs/Shaders/pass.fragment";
  37238. import "babylonjs/Shaders/passCube.fragment";
  37239. /**
  37240. * PassPostProcess which produces an output the same as it's input
  37241. */
  37242. export class PassPostProcess extends PostProcess {
  37243. /**
  37244. * Creates the PassPostProcess
  37245. * @param name The name of the effect.
  37246. * @param options The required width/height ratio to downsize to before computing the render pass.
  37247. * @param camera The camera to apply the render pass to.
  37248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37249. * @param engine The engine which the post process will be applied. (default: current engine)
  37250. * @param reusable If the post process can be reused on the same frame. (default: false)
  37251. * @param textureType The type of texture to be used when performing the post processing.
  37252. * @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)
  37253. */
  37254. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37255. }
  37256. /**
  37257. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37258. */
  37259. export class PassCubePostProcess extends PostProcess {
  37260. private _face;
  37261. /**
  37262. * Gets or sets the cube face to display.
  37263. * * 0 is +X
  37264. * * 1 is -X
  37265. * * 2 is +Y
  37266. * * 3 is -Y
  37267. * * 4 is +Z
  37268. * * 5 is -Z
  37269. */
  37270. face: number;
  37271. /**
  37272. * Creates the PassCubePostProcess
  37273. * @param name The name of the effect.
  37274. * @param options The required width/height ratio to downsize to before computing the render pass.
  37275. * @param camera The camera to apply the render pass to.
  37276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37277. * @param engine The engine which the post process will be applied. (default: current engine)
  37278. * @param reusable If the post process can be reused on the same frame. (default: false)
  37279. * @param textureType The type of texture to be used when performing the post processing.
  37280. * @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)
  37281. */
  37282. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37283. }
  37284. }
  37285. declare module "babylonjs/Shaders/anaglyph.fragment" {
  37286. /** @hidden */
  37287. export var anaglyphPixelShader: {
  37288. name: string;
  37289. shader: string;
  37290. };
  37291. }
  37292. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  37293. import { Engine } from "babylonjs/Engines/engine";
  37294. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  37295. import { Camera } from "babylonjs/Cameras/camera";
  37296. import "babylonjs/Shaders/anaglyph.fragment";
  37297. /**
  37298. * Postprocess used to generate anaglyphic rendering
  37299. */
  37300. export class AnaglyphPostProcess extends PostProcess {
  37301. private _passedProcess;
  37302. /**
  37303. * Creates a new AnaglyphPostProcess
  37304. * @param name defines postprocess name
  37305. * @param options defines creation options or target ratio scale
  37306. * @param rigCameras defines cameras using this postprocess
  37307. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37308. * @param engine defines hosting engine
  37309. * @param reusable defines if the postprocess will be reused multiple times per frame
  37310. */
  37311. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37312. }
  37313. }
  37314. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  37315. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  37316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37317. import { Scene } from "babylonjs/scene";
  37318. import { Vector3 } from "babylonjs/Maths/math";
  37319. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37320. /**
  37321. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37322. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37323. */
  37324. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37325. /**
  37326. * Creates a new AnaglyphArcRotateCamera
  37327. * @param name defines camera name
  37328. * @param alpha defines alpha angle (in radians)
  37329. * @param beta defines beta angle (in radians)
  37330. * @param radius defines radius
  37331. * @param target defines camera target
  37332. * @param interaxialDistance defines distance between each color axis
  37333. * @param scene defines the hosting scene
  37334. */
  37335. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37336. /**
  37337. * Gets camera class name
  37338. * @returns AnaglyphArcRotateCamera
  37339. */
  37340. getClassName(): string;
  37341. }
  37342. }
  37343. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  37344. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37345. import { Scene } from "babylonjs/scene";
  37346. import { Vector3 } from "babylonjs/Maths/math";
  37347. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37348. /**
  37349. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37350. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37351. */
  37352. export class AnaglyphFreeCamera extends FreeCamera {
  37353. /**
  37354. * Creates a new AnaglyphFreeCamera
  37355. * @param name defines camera name
  37356. * @param position defines initial position
  37357. * @param interaxialDistance defines distance between each color axis
  37358. * @param scene defines the hosting scene
  37359. */
  37360. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37361. /**
  37362. * Gets camera class name
  37363. * @returns AnaglyphFreeCamera
  37364. */
  37365. getClassName(): string;
  37366. }
  37367. }
  37368. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  37369. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37370. import { Scene } from "babylonjs/scene";
  37371. import { Vector3 } from "babylonjs/Maths/math";
  37372. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37373. /**
  37374. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37375. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37376. */
  37377. export class AnaglyphGamepadCamera extends GamepadCamera {
  37378. /**
  37379. * Creates a new AnaglyphGamepadCamera
  37380. * @param name defines camera name
  37381. * @param position defines initial position
  37382. * @param interaxialDistance defines distance between each color axis
  37383. * @param scene defines the hosting scene
  37384. */
  37385. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37386. /**
  37387. * Gets camera class name
  37388. * @returns AnaglyphGamepadCamera
  37389. */
  37390. getClassName(): string;
  37391. }
  37392. }
  37393. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  37394. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37395. import { Scene } from "babylonjs/scene";
  37396. import { Vector3 } from "babylonjs/Maths/math";
  37397. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  37398. /**
  37399. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37400. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37401. */
  37402. export class AnaglyphUniversalCamera extends UniversalCamera {
  37403. /**
  37404. * Creates a new AnaglyphUniversalCamera
  37405. * @param name defines camera name
  37406. * @param position defines initial position
  37407. * @param interaxialDistance defines distance between each color axis
  37408. * @param scene defines the hosting scene
  37409. */
  37410. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37411. /**
  37412. * Gets camera class name
  37413. * @returns AnaglyphUniversalCamera
  37414. */
  37415. getClassName(): string;
  37416. }
  37417. }
  37418. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  37419. /** @hidden */
  37420. export var stereoscopicInterlacePixelShader: {
  37421. name: string;
  37422. shader: string;
  37423. };
  37424. }
  37425. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  37426. import { Camera } from "babylonjs/Cameras/camera";
  37427. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37428. import { Engine } from "babylonjs/Engines/engine";
  37429. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  37430. /**
  37431. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37432. */
  37433. export class StereoscopicInterlacePostProcess extends PostProcess {
  37434. private _stepSize;
  37435. private _passedProcess;
  37436. /**
  37437. * Initializes a StereoscopicInterlacePostProcess
  37438. * @param name The name of the effect.
  37439. * @param rigCameras The rig cameras to be appled to the post process
  37440. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37442. * @param engine The engine which the post process will be applied. (default: current engine)
  37443. * @param reusable If the post process can be reused on the same frame. (default: false)
  37444. */
  37445. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37446. }
  37447. }
  37448. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  37449. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  37450. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37451. import { Scene } from "babylonjs/scene";
  37452. import { Vector3 } from "babylonjs/Maths/math";
  37453. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37454. /**
  37455. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37456. * @see http://doc.babylonjs.com/features/cameras
  37457. */
  37458. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37459. /**
  37460. * Creates a new StereoscopicArcRotateCamera
  37461. * @param name defines camera name
  37462. * @param alpha defines alpha angle (in radians)
  37463. * @param beta defines beta angle (in radians)
  37464. * @param radius defines radius
  37465. * @param target defines camera target
  37466. * @param interaxialDistance defines distance between each color axis
  37467. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37468. * @param scene defines the hosting scene
  37469. */
  37470. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37471. /**
  37472. * Gets camera class name
  37473. * @returns StereoscopicArcRotateCamera
  37474. */
  37475. getClassName(): string;
  37476. }
  37477. }
  37478. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  37479. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37480. import { Scene } from "babylonjs/scene";
  37481. import { Vector3 } from "babylonjs/Maths/math";
  37482. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37483. /**
  37484. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37485. * @see http://doc.babylonjs.com/features/cameras
  37486. */
  37487. export class StereoscopicFreeCamera extends FreeCamera {
  37488. /**
  37489. * Creates a new StereoscopicFreeCamera
  37490. * @param name defines camera name
  37491. * @param position defines initial position
  37492. * @param interaxialDistance defines distance between each color axis
  37493. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37494. * @param scene defines the hosting scene
  37495. */
  37496. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37497. /**
  37498. * Gets camera class name
  37499. * @returns StereoscopicFreeCamera
  37500. */
  37501. getClassName(): string;
  37502. }
  37503. }
  37504. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  37505. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  37506. import { Scene } from "babylonjs/scene";
  37507. import { Vector3 } from "babylonjs/Maths/math";
  37508. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37509. /**
  37510. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37511. * @see http://doc.babylonjs.com/features/cameras
  37512. */
  37513. export class StereoscopicGamepadCamera extends GamepadCamera {
  37514. /**
  37515. * Creates a new StereoscopicGamepadCamera
  37516. * @param name defines camera name
  37517. * @param position defines initial position
  37518. * @param interaxialDistance defines distance between each color axis
  37519. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37520. * @param scene defines the hosting scene
  37521. */
  37522. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37523. /**
  37524. * Gets camera class name
  37525. * @returns StereoscopicGamepadCamera
  37526. */
  37527. getClassName(): string;
  37528. }
  37529. }
  37530. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  37531. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  37532. import { Scene } from "babylonjs/scene";
  37533. import { Vector3 } from "babylonjs/Maths/math";
  37534. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  37535. /**
  37536. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37537. * @see http://doc.babylonjs.com/features/cameras
  37538. */
  37539. export class StereoscopicUniversalCamera extends UniversalCamera {
  37540. /**
  37541. * Creates a new StereoscopicUniversalCamera
  37542. * @param name defines camera name
  37543. * @param position defines initial position
  37544. * @param interaxialDistance defines distance between each color axis
  37545. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37546. * @param scene defines the hosting scene
  37547. */
  37548. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37549. /**
  37550. * Gets camera class name
  37551. * @returns StereoscopicUniversalCamera
  37552. */
  37553. getClassName(): string;
  37554. }
  37555. }
  37556. declare module "babylonjs/Cameras/Stereoscopic/index" {
  37557. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  37558. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  37559. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  37560. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  37561. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  37562. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  37563. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  37564. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  37565. }
  37566. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  37567. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37568. import { Scene } from "babylonjs/scene";
  37569. import { Vector3 } from "babylonjs/Maths/math";
  37570. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  37571. /**
  37572. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37573. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37574. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37575. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37576. */
  37577. export class VirtualJoysticksCamera extends FreeCamera {
  37578. /**
  37579. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37580. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37581. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37582. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37583. * @param name Define the name of the camera in the scene
  37584. * @param position Define the start position of the camera in the scene
  37585. * @param scene Define the scene the camera belongs to
  37586. */
  37587. constructor(name: string, position: Vector3, scene: Scene);
  37588. /**
  37589. * Gets the current object class name.
  37590. * @return the class name
  37591. */
  37592. getClassName(): string;
  37593. }
  37594. }
  37595. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  37596. import { Matrix } from "babylonjs/Maths/math";
  37597. /**
  37598. * This represents all the required metrics to create a VR camera.
  37599. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37600. */
  37601. export class VRCameraMetrics {
  37602. /**
  37603. * Define the horizontal resolution off the screen.
  37604. */
  37605. hResolution: number;
  37606. /**
  37607. * Define the vertical resolution off the screen.
  37608. */
  37609. vResolution: number;
  37610. /**
  37611. * Define the horizontal screen size.
  37612. */
  37613. hScreenSize: number;
  37614. /**
  37615. * Define the vertical screen size.
  37616. */
  37617. vScreenSize: number;
  37618. /**
  37619. * Define the vertical screen center position.
  37620. */
  37621. vScreenCenter: number;
  37622. /**
  37623. * Define the distance of the eyes to the screen.
  37624. */
  37625. eyeToScreenDistance: number;
  37626. /**
  37627. * Define the distance between both lenses
  37628. */
  37629. lensSeparationDistance: number;
  37630. /**
  37631. * Define the distance between both viewer's eyes.
  37632. */
  37633. interpupillaryDistance: number;
  37634. /**
  37635. * Define the distortion factor of the VR postprocess.
  37636. * Please, touch with care.
  37637. */
  37638. distortionK: number[];
  37639. /**
  37640. * Define the chromatic aberration correction factors for the VR post process.
  37641. */
  37642. chromaAbCorrection: number[];
  37643. /**
  37644. * Define the scale factor of the post process.
  37645. * The smaller the better but the slower.
  37646. */
  37647. postProcessScaleFactor: number;
  37648. /**
  37649. * Define an offset for the lens center.
  37650. */
  37651. lensCenterOffset: number;
  37652. /**
  37653. * Define if the current vr camera should compensate the distortion of the lense or not.
  37654. */
  37655. compensateDistortion: boolean;
  37656. /**
  37657. * Gets the rendering aspect ratio based on the provided resolutions.
  37658. */
  37659. readonly aspectRatio: number;
  37660. /**
  37661. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37662. */
  37663. readonly aspectRatioFov: number;
  37664. /**
  37665. * @hidden
  37666. */
  37667. readonly leftHMatrix: Matrix;
  37668. /**
  37669. * @hidden
  37670. */
  37671. readonly rightHMatrix: Matrix;
  37672. /**
  37673. * @hidden
  37674. */
  37675. readonly leftPreViewMatrix: Matrix;
  37676. /**
  37677. * @hidden
  37678. */
  37679. readonly rightPreViewMatrix: Matrix;
  37680. /**
  37681. * Get the default VRMetrics based on the most generic setup.
  37682. * @returns the default vr metrics
  37683. */
  37684. static GetDefault(): VRCameraMetrics;
  37685. }
  37686. }
  37687. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  37688. /** @hidden */
  37689. export var vrDistortionCorrectionPixelShader: {
  37690. name: string;
  37691. shader: string;
  37692. };
  37693. }
  37694. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  37695. import { Camera } from "babylonjs/Cameras/camera";
  37696. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37697. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37698. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  37699. /**
  37700. * VRDistortionCorrectionPostProcess used for mobile VR
  37701. */
  37702. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37703. private _isRightEye;
  37704. private _distortionFactors;
  37705. private _postProcessScaleFactor;
  37706. private _lensCenterOffset;
  37707. private _scaleIn;
  37708. private _scaleFactor;
  37709. private _lensCenter;
  37710. /**
  37711. * Initializes the VRDistortionCorrectionPostProcess
  37712. * @param name The name of the effect.
  37713. * @param camera The camera to apply the render pass to.
  37714. * @param isRightEye If this is for the right eye distortion
  37715. * @param vrMetrics All the required metrics for the VR camera
  37716. */
  37717. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37718. }
  37719. }
  37720. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  37721. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  37722. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37723. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37724. import { Scene } from "babylonjs/scene";
  37725. import { Vector3 } from "babylonjs/Maths/math";
  37726. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  37727. import "babylonjs/Cameras/RigModes/vrRigMode";
  37728. /**
  37729. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37730. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37731. */
  37732. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37733. /**
  37734. * Creates a new VRDeviceOrientationArcRotateCamera
  37735. * @param name defines camera name
  37736. * @param alpha defines the camera rotation along the logitudinal axis
  37737. * @param beta defines the camera rotation along the latitudinal axis
  37738. * @param radius defines the camera distance from its target
  37739. * @param target defines the camera target
  37740. * @param scene defines the scene the camera belongs to
  37741. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37742. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37743. */
  37744. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37745. /**
  37746. * Gets camera class name
  37747. * @returns VRDeviceOrientationArcRotateCamera
  37748. */
  37749. getClassName(): string;
  37750. }
  37751. }
  37752. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  37753. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  37754. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37755. import { Scene } from "babylonjs/scene";
  37756. import { Vector3 } from "babylonjs/Maths/math";
  37757. import "babylonjs/Cameras/RigModes/vrRigMode";
  37758. /**
  37759. * Camera used to simulate VR rendering (based on FreeCamera)
  37760. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37761. */
  37762. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37763. /**
  37764. * Creates a new VRDeviceOrientationFreeCamera
  37765. * @param name defines camera name
  37766. * @param position defines the start position of the camera
  37767. * @param scene defines the scene the camera belongs to
  37768. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37769. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37770. */
  37771. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37772. /**
  37773. * Gets camera class name
  37774. * @returns VRDeviceOrientationFreeCamera
  37775. */
  37776. getClassName(): string;
  37777. }
  37778. }
  37779. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  37780. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  37781. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  37782. import { Scene } from "babylonjs/scene";
  37783. import { Vector3 } from "babylonjs/Maths/math";
  37784. /**
  37785. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37786. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37787. */
  37788. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37789. /**
  37790. * Creates a new VRDeviceOrientationGamepadCamera
  37791. * @param name defines camera name
  37792. * @param position defines the start position of the camera
  37793. * @param scene defines the scene the camera belongs to
  37794. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37795. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37796. */
  37797. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37798. /**
  37799. * Gets camera class name
  37800. * @returns VRDeviceOrientationGamepadCamera
  37801. */
  37802. getClassName(): string;
  37803. }
  37804. }
  37805. declare module "babylonjs/Gamepads/xboxGamepad" {
  37806. import { Observable } from "babylonjs/Misc/observable";
  37807. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37808. /**
  37809. * Defines supported buttons for XBox360 compatible gamepads
  37810. */
  37811. export enum Xbox360Button {
  37812. /** A */
  37813. A = 0,
  37814. /** B */
  37815. B = 1,
  37816. /** X */
  37817. X = 2,
  37818. /** Y */
  37819. Y = 3,
  37820. /** Start */
  37821. Start = 4,
  37822. /** Back */
  37823. Back = 5,
  37824. /** Left button */
  37825. LB = 6,
  37826. /** Right button */
  37827. RB = 7,
  37828. /** Left stick */
  37829. LeftStick = 8,
  37830. /** Right stick */
  37831. RightStick = 9
  37832. }
  37833. /** Defines values for XBox360 DPad */
  37834. export enum Xbox360Dpad {
  37835. /** Up */
  37836. Up = 0,
  37837. /** Down */
  37838. Down = 1,
  37839. /** Left */
  37840. Left = 2,
  37841. /** Right */
  37842. Right = 3
  37843. }
  37844. /**
  37845. * Defines a XBox360 gamepad
  37846. */
  37847. export class Xbox360Pad extends Gamepad {
  37848. private _leftTrigger;
  37849. private _rightTrigger;
  37850. private _onlefttriggerchanged;
  37851. private _onrighttriggerchanged;
  37852. private _onbuttondown;
  37853. private _onbuttonup;
  37854. private _ondpaddown;
  37855. private _ondpadup;
  37856. /** Observable raised when a button is pressed */
  37857. onButtonDownObservable: Observable<Xbox360Button>;
  37858. /** Observable raised when a button is released */
  37859. onButtonUpObservable: Observable<Xbox360Button>;
  37860. /** Observable raised when a pad is pressed */
  37861. onPadDownObservable: Observable<Xbox360Dpad>;
  37862. /** Observable raised when a pad is released */
  37863. onPadUpObservable: Observable<Xbox360Dpad>;
  37864. private _buttonA;
  37865. private _buttonB;
  37866. private _buttonX;
  37867. private _buttonY;
  37868. private _buttonBack;
  37869. private _buttonStart;
  37870. private _buttonLB;
  37871. private _buttonRB;
  37872. private _buttonLeftStick;
  37873. private _buttonRightStick;
  37874. private _dPadUp;
  37875. private _dPadDown;
  37876. private _dPadLeft;
  37877. private _dPadRight;
  37878. private _isXboxOnePad;
  37879. /**
  37880. * Creates a new XBox360 gamepad object
  37881. * @param id defines the id of this gamepad
  37882. * @param index defines its index
  37883. * @param gamepad defines the internal HTML gamepad object
  37884. * @param xboxOne defines if it is a XBox One gamepad
  37885. */
  37886. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37887. /**
  37888. * Defines the callback to call when left trigger is pressed
  37889. * @param callback defines the callback to use
  37890. */
  37891. onlefttriggerchanged(callback: (value: number) => void): void;
  37892. /**
  37893. * Defines the callback to call when right trigger is pressed
  37894. * @param callback defines the callback to use
  37895. */
  37896. onrighttriggerchanged(callback: (value: number) => void): void;
  37897. /**
  37898. * Gets the left trigger value
  37899. */
  37900. /**
  37901. * Sets the left trigger value
  37902. */
  37903. leftTrigger: number;
  37904. /**
  37905. * Gets the right trigger value
  37906. */
  37907. /**
  37908. * Sets the right trigger value
  37909. */
  37910. rightTrigger: number;
  37911. /**
  37912. * Defines the callback to call when a button is pressed
  37913. * @param callback defines the callback to use
  37914. */
  37915. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37916. /**
  37917. * Defines the callback to call when a button is released
  37918. * @param callback defines the callback to use
  37919. */
  37920. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37921. /**
  37922. * Defines the callback to call when a pad is pressed
  37923. * @param callback defines the callback to use
  37924. */
  37925. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37926. /**
  37927. * Defines the callback to call when a pad is released
  37928. * @param callback defines the callback to use
  37929. */
  37930. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37931. private _setButtonValue;
  37932. private _setDPadValue;
  37933. /**
  37934. * Gets the value of the `A` button
  37935. */
  37936. /**
  37937. * Sets the value of the `A` button
  37938. */
  37939. buttonA: number;
  37940. /**
  37941. * Gets the value of the `B` button
  37942. */
  37943. /**
  37944. * Sets the value of the `B` button
  37945. */
  37946. buttonB: number;
  37947. /**
  37948. * Gets the value of the `X` button
  37949. */
  37950. /**
  37951. * Sets the value of the `X` button
  37952. */
  37953. buttonX: number;
  37954. /**
  37955. * Gets the value of the `Y` button
  37956. */
  37957. /**
  37958. * Sets the value of the `Y` button
  37959. */
  37960. buttonY: number;
  37961. /**
  37962. * Gets the value of the `Start` button
  37963. */
  37964. /**
  37965. * Sets the value of the `Start` button
  37966. */
  37967. buttonStart: number;
  37968. /**
  37969. * Gets the value of the `Back` button
  37970. */
  37971. /**
  37972. * Sets the value of the `Back` button
  37973. */
  37974. buttonBack: number;
  37975. /**
  37976. * Gets the value of the `Left` button
  37977. */
  37978. /**
  37979. * Sets the value of the `Left` button
  37980. */
  37981. buttonLB: number;
  37982. /**
  37983. * Gets the value of the `Right` button
  37984. */
  37985. /**
  37986. * Sets the value of the `Right` button
  37987. */
  37988. buttonRB: number;
  37989. /**
  37990. * Gets the value of the Left joystick
  37991. */
  37992. /**
  37993. * Sets the value of the Left joystick
  37994. */
  37995. buttonLeftStick: number;
  37996. /**
  37997. * Gets the value of the Right joystick
  37998. */
  37999. /**
  38000. * Sets the value of the Right joystick
  38001. */
  38002. buttonRightStick: number;
  38003. /**
  38004. * Gets the value of D-pad up
  38005. */
  38006. /**
  38007. * Sets the value of D-pad up
  38008. */
  38009. dPadUp: number;
  38010. /**
  38011. * Gets the value of D-pad down
  38012. */
  38013. /**
  38014. * Sets the value of D-pad down
  38015. */
  38016. dPadDown: number;
  38017. /**
  38018. * Gets the value of D-pad left
  38019. */
  38020. /**
  38021. * Sets the value of D-pad left
  38022. */
  38023. dPadLeft: number;
  38024. /**
  38025. * Gets the value of D-pad right
  38026. */
  38027. /**
  38028. * Sets the value of D-pad right
  38029. */
  38030. dPadRight: number;
  38031. /**
  38032. * Force the gamepad to synchronize with device values
  38033. */
  38034. update(): void;
  38035. /**
  38036. * Disposes the gamepad
  38037. */
  38038. dispose(): void;
  38039. }
  38040. }
  38041. declare module "babylonjs/Materials/pushMaterial" {
  38042. import { Nullable } from "babylonjs/types";
  38043. import { Scene } from "babylonjs/scene";
  38044. import { Matrix } from "babylonjs/Maths/math";
  38045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38046. import { Mesh } from "babylonjs/Meshes/mesh";
  38047. import { Material } from "babylonjs/Materials/material";
  38048. import { Effect } from "babylonjs/Materials/effect";
  38049. /**
  38050. * Base class of materials working in push mode in babylon JS
  38051. * @hidden
  38052. */
  38053. export class PushMaterial extends Material {
  38054. protected _activeEffect: Effect;
  38055. protected _normalMatrix: Matrix;
  38056. /**
  38057. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38058. * This means that the material can keep using a previous shader while a new one is being compiled.
  38059. * This is mostly used when shader parallel compilation is supported (true by default)
  38060. */
  38061. allowShaderHotSwapping: boolean;
  38062. constructor(name: string, scene: Scene);
  38063. getEffect(): Effect;
  38064. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38065. /**
  38066. * Binds the given world matrix to the active effect
  38067. *
  38068. * @param world the matrix to bind
  38069. */
  38070. bindOnlyWorldMatrix(world: Matrix): void;
  38071. /**
  38072. * Binds the given normal matrix to the active effect
  38073. *
  38074. * @param normalMatrix the matrix to bind
  38075. */
  38076. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38077. bind(world: Matrix, mesh?: Mesh): void;
  38078. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38079. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38080. }
  38081. }
  38082. declare module "babylonjs/Materials/materialFlags" {
  38083. /**
  38084. * This groups all the flags used to control the materials channel.
  38085. */
  38086. export class MaterialFlags {
  38087. private static _DiffuseTextureEnabled;
  38088. /**
  38089. * Are diffuse textures enabled in the application.
  38090. */
  38091. static DiffuseTextureEnabled: boolean;
  38092. private static _AmbientTextureEnabled;
  38093. /**
  38094. * Are ambient textures enabled in the application.
  38095. */
  38096. static AmbientTextureEnabled: boolean;
  38097. private static _OpacityTextureEnabled;
  38098. /**
  38099. * Are opacity textures enabled in the application.
  38100. */
  38101. static OpacityTextureEnabled: boolean;
  38102. private static _ReflectionTextureEnabled;
  38103. /**
  38104. * Are reflection textures enabled in the application.
  38105. */
  38106. static ReflectionTextureEnabled: boolean;
  38107. private static _EmissiveTextureEnabled;
  38108. /**
  38109. * Are emissive textures enabled in the application.
  38110. */
  38111. static EmissiveTextureEnabled: boolean;
  38112. private static _SpecularTextureEnabled;
  38113. /**
  38114. * Are specular textures enabled in the application.
  38115. */
  38116. static SpecularTextureEnabled: boolean;
  38117. private static _BumpTextureEnabled;
  38118. /**
  38119. * Are bump textures enabled in the application.
  38120. */
  38121. static BumpTextureEnabled: boolean;
  38122. private static _LightmapTextureEnabled;
  38123. /**
  38124. * Are lightmap textures enabled in the application.
  38125. */
  38126. static LightmapTextureEnabled: boolean;
  38127. private static _RefractionTextureEnabled;
  38128. /**
  38129. * Are refraction textures enabled in the application.
  38130. */
  38131. static RefractionTextureEnabled: boolean;
  38132. private static _ColorGradingTextureEnabled;
  38133. /**
  38134. * Are color grading textures enabled in the application.
  38135. */
  38136. static ColorGradingTextureEnabled: boolean;
  38137. private static _FresnelEnabled;
  38138. /**
  38139. * Are fresnels enabled in the application.
  38140. */
  38141. static FresnelEnabled: boolean;
  38142. }
  38143. }
  38144. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  38145. /** @hidden */
  38146. export var defaultFragmentDeclaration: {
  38147. name: string;
  38148. shader: string;
  38149. };
  38150. }
  38151. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  38152. /** @hidden */
  38153. export var defaultUboDeclaration: {
  38154. name: string;
  38155. shader: string;
  38156. };
  38157. }
  38158. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  38159. /** @hidden */
  38160. export var lightFragmentDeclaration: {
  38161. name: string;
  38162. shader: string;
  38163. };
  38164. }
  38165. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  38166. /** @hidden */
  38167. export var lightUboDeclaration: {
  38168. name: string;
  38169. shader: string;
  38170. };
  38171. }
  38172. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  38173. /** @hidden */
  38174. export var lightsFragmentFunctions: {
  38175. name: string;
  38176. shader: string;
  38177. };
  38178. }
  38179. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  38180. /** @hidden */
  38181. export var shadowsFragmentFunctions: {
  38182. name: string;
  38183. shader: string;
  38184. };
  38185. }
  38186. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  38187. /** @hidden */
  38188. export var fresnelFunction: {
  38189. name: string;
  38190. shader: string;
  38191. };
  38192. }
  38193. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  38194. /** @hidden */
  38195. export var reflectionFunction: {
  38196. name: string;
  38197. shader: string;
  38198. };
  38199. }
  38200. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  38201. /** @hidden */
  38202. export var bumpFragmentFunctions: {
  38203. name: string;
  38204. shader: string;
  38205. };
  38206. }
  38207. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  38208. /** @hidden */
  38209. export var logDepthDeclaration: {
  38210. name: string;
  38211. shader: string;
  38212. };
  38213. }
  38214. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  38215. /** @hidden */
  38216. export var bumpFragment: {
  38217. name: string;
  38218. shader: string;
  38219. };
  38220. }
  38221. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  38222. /** @hidden */
  38223. export var depthPrePass: {
  38224. name: string;
  38225. shader: string;
  38226. };
  38227. }
  38228. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  38229. /** @hidden */
  38230. export var lightFragment: {
  38231. name: string;
  38232. shader: string;
  38233. };
  38234. }
  38235. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  38236. /** @hidden */
  38237. export var logDepthFragment: {
  38238. name: string;
  38239. shader: string;
  38240. };
  38241. }
  38242. declare module "babylonjs/Shaders/default.fragment" {
  38243. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  38244. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38245. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38246. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38247. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38248. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  38249. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  38250. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  38251. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  38252. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  38253. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  38254. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  38255. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  38256. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38257. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  38258. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  38259. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  38260. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  38261. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  38262. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  38263. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  38264. /** @hidden */
  38265. export var defaultPixelShader: {
  38266. name: string;
  38267. shader: string;
  38268. };
  38269. }
  38270. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  38271. /** @hidden */
  38272. export var defaultVertexDeclaration: {
  38273. name: string;
  38274. shader: string;
  38275. };
  38276. }
  38277. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  38278. /** @hidden */
  38279. export var bumpVertexDeclaration: {
  38280. name: string;
  38281. shader: string;
  38282. };
  38283. }
  38284. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  38285. /** @hidden */
  38286. export var bumpVertex: {
  38287. name: string;
  38288. shader: string;
  38289. };
  38290. }
  38291. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  38292. /** @hidden */
  38293. export var fogVertex: {
  38294. name: string;
  38295. shader: string;
  38296. };
  38297. }
  38298. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  38299. /** @hidden */
  38300. export var shadowsVertex: {
  38301. name: string;
  38302. shader: string;
  38303. };
  38304. }
  38305. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  38306. /** @hidden */
  38307. export var pointCloudVertex: {
  38308. name: string;
  38309. shader: string;
  38310. };
  38311. }
  38312. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  38313. /** @hidden */
  38314. export var logDepthVertex: {
  38315. name: string;
  38316. shader: string;
  38317. };
  38318. }
  38319. declare module "babylonjs/Shaders/default.vertex" {
  38320. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  38321. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  38322. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  38323. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  38324. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  38325. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  38326. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  38327. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  38328. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  38329. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  38330. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  38331. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  38332. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  38333. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  38334. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  38335. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  38336. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  38337. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  38338. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  38339. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  38340. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  38341. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  38342. /** @hidden */
  38343. export var defaultVertexShader: {
  38344. name: string;
  38345. shader: string;
  38346. };
  38347. }
  38348. declare module "babylonjs/Materials/standardMaterial" {
  38349. import { SmartArray } from "babylonjs/Misc/smartArray";
  38350. import { IAnimatable } from "babylonjs/Misc/tools";
  38351. import { Nullable } from "babylonjs/types";
  38352. import { Scene } from "babylonjs/scene";
  38353. import { Matrix, Color3 } from "babylonjs/Maths/math";
  38354. import { SubMesh } from "babylonjs/Meshes/subMesh";
  38355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38356. import { Mesh } from "babylonjs/Meshes/mesh";
  38357. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  38358. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38359. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38360. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  38361. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  38362. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38364. import "babylonjs/Shaders/default.fragment";
  38365. import "babylonjs/Shaders/default.vertex";
  38366. /** @hidden */
  38367. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38368. MAINUV1: boolean;
  38369. MAINUV2: boolean;
  38370. DIFFUSE: boolean;
  38371. DIFFUSEDIRECTUV: number;
  38372. AMBIENT: boolean;
  38373. AMBIENTDIRECTUV: number;
  38374. OPACITY: boolean;
  38375. OPACITYDIRECTUV: number;
  38376. OPACITYRGB: boolean;
  38377. REFLECTION: boolean;
  38378. EMISSIVE: boolean;
  38379. EMISSIVEDIRECTUV: number;
  38380. SPECULAR: boolean;
  38381. SPECULARDIRECTUV: number;
  38382. BUMP: boolean;
  38383. BUMPDIRECTUV: number;
  38384. PARALLAX: boolean;
  38385. PARALLAXOCCLUSION: boolean;
  38386. SPECULAROVERALPHA: boolean;
  38387. CLIPPLANE: boolean;
  38388. CLIPPLANE2: boolean;
  38389. CLIPPLANE3: boolean;
  38390. CLIPPLANE4: boolean;
  38391. ALPHATEST: boolean;
  38392. DEPTHPREPASS: boolean;
  38393. ALPHAFROMDIFFUSE: boolean;
  38394. POINTSIZE: boolean;
  38395. FOG: boolean;
  38396. SPECULARTERM: boolean;
  38397. DIFFUSEFRESNEL: boolean;
  38398. OPACITYFRESNEL: boolean;
  38399. REFLECTIONFRESNEL: boolean;
  38400. REFRACTIONFRESNEL: boolean;
  38401. EMISSIVEFRESNEL: boolean;
  38402. FRESNEL: boolean;
  38403. NORMAL: boolean;
  38404. UV1: boolean;
  38405. UV2: boolean;
  38406. VERTEXCOLOR: boolean;
  38407. VERTEXALPHA: boolean;
  38408. NUM_BONE_INFLUENCERS: number;
  38409. BonesPerMesh: number;
  38410. BONETEXTURE: boolean;
  38411. INSTANCES: boolean;
  38412. GLOSSINESS: boolean;
  38413. ROUGHNESS: boolean;
  38414. EMISSIVEASILLUMINATION: boolean;
  38415. LINKEMISSIVEWITHDIFFUSE: boolean;
  38416. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38417. LIGHTMAP: boolean;
  38418. LIGHTMAPDIRECTUV: number;
  38419. OBJECTSPACE_NORMALMAP: boolean;
  38420. USELIGHTMAPASSHADOWMAP: boolean;
  38421. REFLECTIONMAP_3D: boolean;
  38422. REFLECTIONMAP_SPHERICAL: boolean;
  38423. REFLECTIONMAP_PLANAR: boolean;
  38424. REFLECTIONMAP_CUBIC: boolean;
  38425. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38426. REFLECTIONMAP_PROJECTION: boolean;
  38427. REFLECTIONMAP_SKYBOX: boolean;
  38428. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38429. REFLECTIONMAP_EXPLICIT: boolean;
  38430. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38431. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38432. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38433. INVERTCUBICMAP: boolean;
  38434. LOGARITHMICDEPTH: boolean;
  38435. REFRACTION: boolean;
  38436. REFRACTIONMAP_3D: boolean;
  38437. REFLECTIONOVERALPHA: boolean;
  38438. TWOSIDEDLIGHTING: boolean;
  38439. SHADOWFLOAT: boolean;
  38440. MORPHTARGETS: boolean;
  38441. MORPHTARGETS_NORMAL: boolean;
  38442. MORPHTARGETS_TANGENT: boolean;
  38443. NUM_MORPH_INFLUENCERS: number;
  38444. NONUNIFORMSCALING: boolean;
  38445. PREMULTIPLYALPHA: boolean;
  38446. IMAGEPROCESSING: boolean;
  38447. VIGNETTE: boolean;
  38448. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38449. VIGNETTEBLENDMODEOPAQUE: boolean;
  38450. TONEMAPPING: boolean;
  38451. TONEMAPPING_ACES: boolean;
  38452. CONTRAST: boolean;
  38453. COLORCURVES: boolean;
  38454. COLORGRADING: boolean;
  38455. COLORGRADING3D: boolean;
  38456. SAMPLER3DGREENDEPTH: boolean;
  38457. SAMPLER3DBGRMAP: boolean;
  38458. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38459. /**
  38460. * If the reflection texture on this material is in linear color space
  38461. * @hidden
  38462. */
  38463. IS_REFLECTION_LINEAR: boolean;
  38464. /**
  38465. * If the refraction texture on this material is in linear color space
  38466. * @hidden
  38467. */
  38468. IS_REFRACTION_LINEAR: boolean;
  38469. EXPOSURE: boolean;
  38470. constructor();
  38471. setReflectionMode(modeToEnable: string): void;
  38472. }
  38473. /**
  38474. * This is the default material used in Babylon. It is the best trade off between quality
  38475. * and performances.
  38476. * @see http://doc.babylonjs.com/babylon101/materials
  38477. */
  38478. export class StandardMaterial extends PushMaterial {
  38479. private _diffuseTexture;
  38480. /**
  38481. * The basic texture of the material as viewed under a light.
  38482. */
  38483. diffuseTexture: Nullable<BaseTexture>;
  38484. private _ambientTexture;
  38485. /**
  38486. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38487. */
  38488. ambientTexture: Nullable<BaseTexture>;
  38489. private _opacityTexture;
  38490. /**
  38491. * Define the transparency of the material from a texture.
  38492. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38493. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38494. */
  38495. opacityTexture: Nullable<BaseTexture>;
  38496. private _reflectionTexture;
  38497. /**
  38498. * Define the texture used to display the reflection.
  38499. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38500. */
  38501. reflectionTexture: Nullable<BaseTexture>;
  38502. private _emissiveTexture;
  38503. /**
  38504. * Define texture of the material as if self lit.
  38505. * This will be mixed in the final result even in the absence of light.
  38506. */
  38507. emissiveTexture: Nullable<BaseTexture>;
  38508. private _specularTexture;
  38509. /**
  38510. * Define how the color and intensity of the highlight given by the light in the material.
  38511. */
  38512. specularTexture: Nullable<BaseTexture>;
  38513. private _bumpTexture;
  38514. /**
  38515. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38516. * 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.
  38517. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38518. */
  38519. bumpTexture: Nullable<BaseTexture>;
  38520. private _lightmapTexture;
  38521. /**
  38522. * Complex lighting can be computationally expensive to compute at runtime.
  38523. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38524. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38525. */
  38526. lightmapTexture: Nullable<BaseTexture>;
  38527. private _refractionTexture;
  38528. /**
  38529. * Define the texture used to display the refraction.
  38530. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38531. */
  38532. refractionTexture: Nullable<BaseTexture>;
  38533. /**
  38534. * The color of the material lit by the environmental background lighting.
  38535. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38536. */
  38537. ambientColor: Color3;
  38538. /**
  38539. * The basic color of the material as viewed under a light.
  38540. */
  38541. diffuseColor: Color3;
  38542. /**
  38543. * Define how the color and intensity of the highlight given by the light in the material.
  38544. */
  38545. specularColor: Color3;
  38546. /**
  38547. * Define the color of the material as if self lit.
  38548. * This will be mixed in the final result even in the absence of light.
  38549. */
  38550. emissiveColor: Color3;
  38551. /**
  38552. * Defines how sharp are the highlights in the material.
  38553. * The bigger the value the sharper giving a more glossy feeling to the result.
  38554. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38555. */
  38556. specularPower: number;
  38557. private _useAlphaFromDiffuseTexture;
  38558. /**
  38559. * Does the transparency come from the diffuse texture alpha channel.
  38560. */
  38561. useAlphaFromDiffuseTexture: boolean;
  38562. private _useEmissiveAsIllumination;
  38563. /**
  38564. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38565. */
  38566. useEmissiveAsIllumination: boolean;
  38567. private _linkEmissiveWithDiffuse;
  38568. /**
  38569. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38570. * the emissive level when the final color is close to one.
  38571. */
  38572. linkEmissiveWithDiffuse: boolean;
  38573. private _useSpecularOverAlpha;
  38574. /**
  38575. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38576. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38577. */
  38578. useSpecularOverAlpha: boolean;
  38579. private _useReflectionOverAlpha;
  38580. /**
  38581. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38582. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38583. */
  38584. useReflectionOverAlpha: boolean;
  38585. private _disableLighting;
  38586. /**
  38587. * Does lights from the scene impacts this material.
  38588. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38589. */
  38590. disableLighting: boolean;
  38591. private _useObjectSpaceNormalMap;
  38592. /**
  38593. * Allows using an object space normal map (instead of tangent space).
  38594. */
  38595. useObjectSpaceNormalMap: boolean;
  38596. private _useParallax;
  38597. /**
  38598. * Is parallax enabled or not.
  38599. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38600. */
  38601. useParallax: boolean;
  38602. private _useParallaxOcclusion;
  38603. /**
  38604. * Is parallax occlusion enabled or not.
  38605. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38606. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38607. */
  38608. useParallaxOcclusion: boolean;
  38609. /**
  38610. * 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.
  38611. */
  38612. parallaxScaleBias: number;
  38613. private _roughness;
  38614. /**
  38615. * Helps to define how blurry the reflections should appears in the material.
  38616. */
  38617. roughness: number;
  38618. /**
  38619. * In case of refraction, define the value of the indice of refraction.
  38620. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38621. */
  38622. indexOfRefraction: number;
  38623. /**
  38624. * Invert the refraction texture alongside the y axis.
  38625. * It can be useful with procedural textures or probe for instance.
  38626. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38627. */
  38628. invertRefractionY: boolean;
  38629. /**
  38630. * Defines the alpha limits in alpha test mode.
  38631. */
  38632. alphaCutOff: number;
  38633. private _useLightmapAsShadowmap;
  38634. /**
  38635. * In case of light mapping, define whether the map contains light or shadow informations.
  38636. */
  38637. useLightmapAsShadowmap: boolean;
  38638. private _diffuseFresnelParameters;
  38639. /**
  38640. * Define the diffuse fresnel parameters of the material.
  38641. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38642. */
  38643. diffuseFresnelParameters: FresnelParameters;
  38644. private _opacityFresnelParameters;
  38645. /**
  38646. * Define the opacity fresnel parameters of the material.
  38647. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38648. */
  38649. opacityFresnelParameters: FresnelParameters;
  38650. private _reflectionFresnelParameters;
  38651. /**
  38652. * Define the reflection fresnel parameters of the material.
  38653. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38654. */
  38655. reflectionFresnelParameters: FresnelParameters;
  38656. private _refractionFresnelParameters;
  38657. /**
  38658. * Define the refraction fresnel parameters of the material.
  38659. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38660. */
  38661. refractionFresnelParameters: FresnelParameters;
  38662. private _emissiveFresnelParameters;
  38663. /**
  38664. * Define the emissive fresnel parameters of the material.
  38665. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38666. */
  38667. emissiveFresnelParameters: FresnelParameters;
  38668. private _useReflectionFresnelFromSpecular;
  38669. /**
  38670. * If true automatically deducts the fresnels values from the material specularity.
  38671. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38672. */
  38673. useReflectionFresnelFromSpecular: boolean;
  38674. private _useGlossinessFromSpecularMapAlpha;
  38675. /**
  38676. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38677. */
  38678. useGlossinessFromSpecularMapAlpha: boolean;
  38679. private _maxSimultaneousLights;
  38680. /**
  38681. * Defines the maximum number of lights that can be used in the material
  38682. */
  38683. maxSimultaneousLights: number;
  38684. private _invertNormalMapX;
  38685. /**
  38686. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38687. */
  38688. invertNormalMapX: boolean;
  38689. private _invertNormalMapY;
  38690. /**
  38691. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38692. */
  38693. invertNormalMapY: boolean;
  38694. private _twoSidedLighting;
  38695. /**
  38696. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38697. */
  38698. twoSidedLighting: boolean;
  38699. /**
  38700. * Default configuration related to image processing available in the standard Material.
  38701. */
  38702. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38703. /**
  38704. * Gets the image processing configuration used either in this material.
  38705. */
  38706. /**
  38707. * Sets the Default image processing configuration used either in the this material.
  38708. *
  38709. * If sets to null, the scene one is in use.
  38710. */
  38711. imageProcessingConfiguration: ImageProcessingConfiguration;
  38712. /**
  38713. * Keep track of the image processing observer to allow dispose and replace.
  38714. */
  38715. private _imageProcessingObserver;
  38716. /**
  38717. * Attaches a new image processing configuration to the Standard Material.
  38718. * @param configuration
  38719. */
  38720. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38721. /**
  38722. * Gets wether the color curves effect is enabled.
  38723. */
  38724. /**
  38725. * Sets wether the color curves effect is enabled.
  38726. */
  38727. cameraColorCurvesEnabled: boolean;
  38728. /**
  38729. * Gets wether the color grading effect is enabled.
  38730. */
  38731. /**
  38732. * Gets wether the color grading effect is enabled.
  38733. */
  38734. cameraColorGradingEnabled: boolean;
  38735. /**
  38736. * Gets wether tonemapping is enabled or not.
  38737. */
  38738. /**
  38739. * Sets wether tonemapping is enabled or not
  38740. */
  38741. cameraToneMappingEnabled: boolean;
  38742. /**
  38743. * The camera exposure used on this material.
  38744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38745. * This corresponds to a photographic exposure.
  38746. */
  38747. /**
  38748. * The camera exposure used on this material.
  38749. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38750. * This corresponds to a photographic exposure.
  38751. */
  38752. cameraExposure: number;
  38753. /**
  38754. * Gets The camera contrast used on this material.
  38755. */
  38756. /**
  38757. * Sets The camera contrast used on this material.
  38758. */
  38759. cameraContrast: number;
  38760. /**
  38761. * Gets the Color Grading 2D Lookup Texture.
  38762. */
  38763. /**
  38764. * Sets the Color Grading 2D Lookup Texture.
  38765. */
  38766. cameraColorGradingTexture: Nullable<BaseTexture>;
  38767. /**
  38768. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38769. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38770. * 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;
  38771. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38772. */
  38773. /**
  38774. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38775. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38776. * 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;
  38777. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38778. */
  38779. cameraColorCurves: Nullable<ColorCurves>;
  38780. /**
  38781. * Custom callback helping to override the default shader used in the material.
  38782. */
  38783. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38784. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38785. protected _worldViewProjectionMatrix: Matrix;
  38786. protected _globalAmbientColor: Color3;
  38787. protected _useLogarithmicDepth: boolean;
  38788. /**
  38789. * Instantiates a new standard material.
  38790. * This is the default material used in Babylon. It is the best trade off between quality
  38791. * and performances.
  38792. * @see http://doc.babylonjs.com/babylon101/materials
  38793. * @param name Define the name of the material in the scene
  38794. * @param scene Define the scene the material belong to
  38795. */
  38796. constructor(name: string, scene: Scene);
  38797. /**
  38798. * Gets a boolean indicating that current material needs to register RTT
  38799. */
  38800. readonly hasRenderTargetTextures: boolean;
  38801. /**
  38802. * Gets the current class name of the material e.g. "StandardMaterial"
  38803. * Mainly use in serialization.
  38804. * @returns the class name
  38805. */
  38806. getClassName(): string;
  38807. /**
  38808. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38809. * You can try switching to logarithmic depth.
  38810. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38811. */
  38812. useLogarithmicDepth: boolean;
  38813. /**
  38814. * Specifies if the material will require alpha blending
  38815. * @returns a boolean specifying if alpha blending is needed
  38816. */
  38817. needAlphaBlending(): boolean;
  38818. /**
  38819. * Specifies if this material should be rendered in alpha test mode
  38820. * @returns a boolean specifying if an alpha test is needed.
  38821. */
  38822. needAlphaTesting(): boolean;
  38823. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38824. /**
  38825. * Get the texture used for alpha test purpose.
  38826. * @returns the diffuse texture in case of the standard material.
  38827. */
  38828. getAlphaTestTexture(): Nullable<BaseTexture>;
  38829. /**
  38830. * Get if the submesh is ready to be used and all its information available.
  38831. * Child classes can use it to update shaders
  38832. * @param mesh defines the mesh to check
  38833. * @param subMesh defines which submesh to check
  38834. * @param useInstances specifies that instances should be used
  38835. * @returns a boolean indicating that the submesh is ready or not
  38836. */
  38837. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38838. /**
  38839. * Builds the material UBO layouts.
  38840. * Used internally during the effect preparation.
  38841. */
  38842. buildUniformLayout(): void;
  38843. /**
  38844. * Unbinds the material from the mesh
  38845. */
  38846. unbind(): void;
  38847. /**
  38848. * Binds the submesh to this material by preparing the effect and shader to draw
  38849. * @param world defines the world transformation matrix
  38850. * @param mesh defines the mesh containing the submesh
  38851. * @param subMesh defines the submesh to bind the material to
  38852. */
  38853. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38854. /**
  38855. * Get the list of animatables in the material.
  38856. * @returns the list of animatables object used in the material
  38857. */
  38858. getAnimatables(): IAnimatable[];
  38859. /**
  38860. * Gets the active textures from the material
  38861. * @returns an array of textures
  38862. */
  38863. getActiveTextures(): BaseTexture[];
  38864. /**
  38865. * Specifies if the material uses a texture
  38866. * @param texture defines the texture to check against the material
  38867. * @returns a boolean specifying if the material uses the texture
  38868. */
  38869. hasTexture(texture: BaseTexture): boolean;
  38870. /**
  38871. * Disposes the material
  38872. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38873. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38874. */
  38875. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38876. /**
  38877. * Makes a duplicate of the material, and gives it a new name
  38878. * @param name defines the new name for the duplicated material
  38879. * @returns the cloned material
  38880. */
  38881. clone(name: string): StandardMaterial;
  38882. /**
  38883. * Serializes this material in a JSON representation
  38884. * @returns the serialized material object
  38885. */
  38886. serialize(): any;
  38887. /**
  38888. * Creates a standard material from parsed material data
  38889. * @param source defines the JSON representation of the material
  38890. * @param scene defines the hosting scene
  38891. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38892. * @returns a new standard material
  38893. */
  38894. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38895. /**
  38896. * Are diffuse textures enabled in the application.
  38897. */
  38898. static DiffuseTextureEnabled: boolean;
  38899. /**
  38900. * Are ambient textures enabled in the application.
  38901. */
  38902. static AmbientTextureEnabled: boolean;
  38903. /**
  38904. * Are opacity textures enabled in the application.
  38905. */
  38906. static OpacityTextureEnabled: boolean;
  38907. /**
  38908. * Are reflection textures enabled in the application.
  38909. */
  38910. static ReflectionTextureEnabled: boolean;
  38911. /**
  38912. * Are emissive textures enabled in the application.
  38913. */
  38914. static EmissiveTextureEnabled: boolean;
  38915. /**
  38916. * Are specular textures enabled in the application.
  38917. */
  38918. static SpecularTextureEnabled: boolean;
  38919. /**
  38920. * Are bump textures enabled in the application.
  38921. */
  38922. static BumpTextureEnabled: boolean;
  38923. /**
  38924. * Are lightmap textures enabled in the application.
  38925. */
  38926. static LightmapTextureEnabled: boolean;
  38927. /**
  38928. * Are refraction textures enabled in the application.
  38929. */
  38930. static RefractionTextureEnabled: boolean;
  38931. /**
  38932. * Are color grading textures enabled in the application.
  38933. */
  38934. static ColorGradingTextureEnabled: boolean;
  38935. /**
  38936. * Are fresnels enabled in the application.
  38937. */
  38938. static FresnelEnabled: boolean;
  38939. }
  38940. }
  38941. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  38942. import { Scene } from "babylonjs/scene";
  38943. import { Texture } from "babylonjs/Materials/Textures/texture";
  38944. /**
  38945. * A class extending Texture allowing drawing on a texture
  38946. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38947. */
  38948. export class DynamicTexture extends Texture {
  38949. private _generateMipMaps;
  38950. private _canvas;
  38951. private _context;
  38952. private _engine;
  38953. /**
  38954. * Creates a DynamicTexture
  38955. * @param name defines the name of the texture
  38956. * @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
  38957. * @param scene defines the scene where you want the texture
  38958. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38959. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38960. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38961. */
  38962. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38963. /**
  38964. * Get the current class name of the texture useful for serialization or dynamic coding.
  38965. * @returns "DynamicTexture"
  38966. */
  38967. getClassName(): string;
  38968. /**
  38969. * Gets the current state of canRescale
  38970. */
  38971. readonly canRescale: boolean;
  38972. private _recreate;
  38973. /**
  38974. * Scales the texture
  38975. * @param ratio the scale factor to apply to both width and height
  38976. */
  38977. scale(ratio: number): void;
  38978. /**
  38979. * Resizes the texture
  38980. * @param width the new width
  38981. * @param height the new height
  38982. */
  38983. scaleTo(width: number, height: number): void;
  38984. /**
  38985. * Gets the context of the canvas used by the texture
  38986. * @returns the canvas context of the dynamic texture
  38987. */
  38988. getContext(): CanvasRenderingContext2D;
  38989. /**
  38990. * Clears the texture
  38991. */
  38992. clear(): void;
  38993. /**
  38994. * Updates the texture
  38995. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38996. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38997. */
  38998. update(invertY?: boolean, premulAlpha?: boolean): void;
  38999. /**
  39000. * Draws text onto the texture
  39001. * @param text defines the text to be drawn
  39002. * @param x defines the placement of the text from the left
  39003. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39004. * @param font defines the font to be used with font-style, font-size, font-name
  39005. * @param color defines the color used for the text
  39006. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39007. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39008. * @param update defines whether texture is immediately update (default is true)
  39009. */
  39010. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39011. /**
  39012. * Clones the texture
  39013. * @returns the clone of the texture.
  39014. */
  39015. clone(): DynamicTexture;
  39016. /**
  39017. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39018. * @returns a serialized dynamic texture object
  39019. */
  39020. serialize(): any;
  39021. /** @hidden */
  39022. _rebuild(): void;
  39023. }
  39024. }
  39025. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  39026. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39027. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39028. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39029. /** @hidden */
  39030. export var imageProcessingPixelShader: {
  39031. name: string;
  39032. shader: string;
  39033. };
  39034. }
  39035. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  39036. import { Nullable } from "babylonjs/types";
  39037. import { Color4 } from "babylonjs/Maths/math";
  39038. import { Camera } from "babylonjs/Cameras/camera";
  39039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39040. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39041. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39042. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39043. import { Engine } from "babylonjs/Engines/engine";
  39044. import "babylonjs/Shaders/imageProcessing.fragment";
  39045. import "babylonjs/Shaders/postprocess.vertex";
  39046. /**
  39047. * ImageProcessingPostProcess
  39048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39049. */
  39050. export class ImageProcessingPostProcess extends PostProcess {
  39051. /**
  39052. * Default configuration related to image processing available in the PBR Material.
  39053. */
  39054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39055. /**
  39056. * Gets the image processing configuration used either in this material.
  39057. */
  39058. /**
  39059. * Sets the Default image processing configuration used either in the this material.
  39060. *
  39061. * If sets to null, the scene one is in use.
  39062. */
  39063. imageProcessingConfiguration: ImageProcessingConfiguration;
  39064. /**
  39065. * Keep track of the image processing observer to allow dispose and replace.
  39066. */
  39067. private _imageProcessingObserver;
  39068. /**
  39069. * Attaches a new image processing configuration to the PBR Material.
  39070. * @param configuration
  39071. */
  39072. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39073. /**
  39074. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39075. */
  39076. /**
  39077. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39078. */
  39079. colorCurves: Nullable<ColorCurves>;
  39080. /**
  39081. * Gets wether the color curves effect is enabled.
  39082. */
  39083. /**
  39084. * Sets wether the color curves effect is enabled.
  39085. */
  39086. colorCurvesEnabled: boolean;
  39087. /**
  39088. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39089. */
  39090. /**
  39091. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39092. */
  39093. colorGradingTexture: Nullable<BaseTexture>;
  39094. /**
  39095. * Gets wether the color grading effect is enabled.
  39096. */
  39097. /**
  39098. * Gets wether the color grading effect is enabled.
  39099. */
  39100. colorGradingEnabled: boolean;
  39101. /**
  39102. * Gets exposure used in the effect.
  39103. */
  39104. /**
  39105. * Sets exposure used in the effect.
  39106. */
  39107. exposure: number;
  39108. /**
  39109. * Gets wether tonemapping is enabled or not.
  39110. */
  39111. /**
  39112. * Sets wether tonemapping is enabled or not
  39113. */
  39114. toneMappingEnabled: boolean;
  39115. /**
  39116. * Gets contrast used in the effect.
  39117. */
  39118. /**
  39119. * Sets contrast used in the effect.
  39120. */
  39121. contrast: number;
  39122. /**
  39123. * Gets Vignette stretch size.
  39124. */
  39125. /**
  39126. * Sets Vignette stretch size.
  39127. */
  39128. vignetteStretch: number;
  39129. /**
  39130. * Gets Vignette centre X Offset.
  39131. */
  39132. /**
  39133. * Sets Vignette centre X Offset.
  39134. */
  39135. vignetteCentreX: number;
  39136. /**
  39137. * Gets Vignette centre Y Offset.
  39138. */
  39139. /**
  39140. * Sets Vignette centre Y Offset.
  39141. */
  39142. vignetteCentreY: number;
  39143. /**
  39144. * Gets Vignette weight or intensity of the vignette effect.
  39145. */
  39146. /**
  39147. * Sets Vignette weight or intensity of the vignette effect.
  39148. */
  39149. vignetteWeight: number;
  39150. /**
  39151. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39152. * if vignetteEnabled is set to true.
  39153. */
  39154. /**
  39155. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39156. * if vignetteEnabled is set to true.
  39157. */
  39158. vignetteColor: Color4;
  39159. /**
  39160. * Gets Camera field of view used by the Vignette effect.
  39161. */
  39162. /**
  39163. * Sets Camera field of view used by the Vignette effect.
  39164. */
  39165. vignetteCameraFov: number;
  39166. /**
  39167. * Gets the vignette blend mode allowing different kind of effect.
  39168. */
  39169. /**
  39170. * Sets the vignette blend mode allowing different kind of effect.
  39171. */
  39172. vignetteBlendMode: number;
  39173. /**
  39174. * Gets wether the vignette effect is enabled.
  39175. */
  39176. /**
  39177. * Sets wether the vignette effect is enabled.
  39178. */
  39179. vignetteEnabled: boolean;
  39180. private _fromLinearSpace;
  39181. /**
  39182. * Gets wether the input of the processing is in Gamma or Linear Space.
  39183. */
  39184. /**
  39185. * Sets wether the input of the processing is in Gamma or Linear Space.
  39186. */
  39187. fromLinearSpace: boolean;
  39188. /**
  39189. * Defines cache preventing GC.
  39190. */
  39191. private _defines;
  39192. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39193. /**
  39194. * "ImageProcessingPostProcess"
  39195. * @returns "ImageProcessingPostProcess"
  39196. */
  39197. getClassName(): string;
  39198. protected _updateParameters(): void;
  39199. dispose(camera?: Camera): void;
  39200. }
  39201. }
  39202. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  39203. import { Scene } from "babylonjs/scene";
  39204. import { Color3 } from "babylonjs/Maths/math";
  39205. import { Mesh } from "babylonjs/Meshes/mesh";
  39206. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  39207. /**
  39208. * Class containing static functions to help procedurally build meshes
  39209. */
  39210. export class GroundBuilder {
  39211. /**
  39212. * Creates a ground mesh
  39213. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39214. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39216. * @param name defines the name of the mesh
  39217. * @param options defines the options used to create the mesh
  39218. * @param scene defines the hosting scene
  39219. * @returns the ground mesh
  39220. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39221. */
  39222. static CreateGround(name: string, options: {
  39223. width?: number;
  39224. height?: number;
  39225. subdivisions?: number;
  39226. subdivisionsX?: number;
  39227. subdivisionsY?: number;
  39228. updatable?: boolean;
  39229. }, scene: any): Mesh;
  39230. /**
  39231. * Creates a tiled ground mesh
  39232. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39233. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39234. * * 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
  39235. * * 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
  39236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39237. * @param name defines the name of the mesh
  39238. * @param options defines the options used to create the mesh
  39239. * @param scene defines the hosting scene
  39240. * @returns the tiled ground mesh
  39241. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39242. */
  39243. static CreateTiledGround(name: string, options: {
  39244. xmin: number;
  39245. zmin: number;
  39246. xmax: number;
  39247. zmax: number;
  39248. subdivisions?: {
  39249. w: number;
  39250. h: number;
  39251. };
  39252. precision?: {
  39253. w: number;
  39254. h: number;
  39255. };
  39256. updatable?: boolean;
  39257. }, scene: Scene): Mesh;
  39258. /**
  39259. * Creates a ground mesh from a height map
  39260. * * The parameter `url` sets the URL of the height map image resource.
  39261. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39262. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39263. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39264. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39265. * * 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.
  39266. * * 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).
  39267. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39269. * @param name defines the name of the mesh
  39270. * @param url defines the url to the height map
  39271. * @param options defines the options used to create the mesh
  39272. * @param scene defines the hosting scene
  39273. * @returns the ground mesh
  39274. * @see https://doc.babylonjs.com/babylon101/height_map
  39275. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39276. */
  39277. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39278. width?: number;
  39279. height?: number;
  39280. subdivisions?: number;
  39281. minHeight?: number;
  39282. maxHeight?: number;
  39283. colorFilter?: Color3;
  39284. alphaFilter?: number;
  39285. updatable?: boolean;
  39286. onReady?: (mesh: GroundMesh) => void;
  39287. }, scene: Scene): GroundMesh;
  39288. }
  39289. }
  39290. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  39291. import { Vector4 } from "babylonjs/Maths/math";
  39292. import { Mesh } from "babylonjs/Meshes/mesh";
  39293. /**
  39294. * Class containing static functions to help procedurally build meshes
  39295. */
  39296. export class TorusBuilder {
  39297. /**
  39298. * Creates a torus mesh
  39299. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39300. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39301. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39305. * @param name defines the name of the mesh
  39306. * @param options defines the options used to create the mesh
  39307. * @param scene defines the hosting scene
  39308. * @returns the torus mesh
  39309. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39310. */
  39311. static CreateTorus(name: string, options: {
  39312. diameter?: number;
  39313. thickness?: number;
  39314. tessellation?: number;
  39315. updatable?: boolean;
  39316. sideOrientation?: number;
  39317. frontUVs?: Vector4;
  39318. backUVs?: Vector4;
  39319. }, scene: any): Mesh;
  39320. }
  39321. }
  39322. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  39323. import { Color4, Vector4 } from "babylonjs/Maths/math";
  39324. import { Mesh } from "babylonjs/Meshes/mesh";
  39325. /**
  39326. * Class containing static functions to help procedurally build meshes
  39327. */
  39328. export class CylinderBuilder {
  39329. /**
  39330. * Creates a cylinder or a cone mesh
  39331. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39332. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39333. * * 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.
  39334. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39335. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39336. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39337. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39338. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39339. * * 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).
  39340. * * 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
  39341. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39342. * * 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
  39343. * * 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.
  39344. * * If `enclose` is false, a ring surface is one element.
  39345. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  39346. * * 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
  39347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  39349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39350. * @param name defines the name of the mesh
  39351. * @param options defines the options used to create the mesh
  39352. * @param scene defines the hosting scene
  39353. * @returns the cylinder mesh
  39354. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  39355. */
  39356. static CreateCylinder(name: string, options: {
  39357. height?: number;
  39358. diameterTop?: number;
  39359. diameterBottom?: number;
  39360. diameter?: number;
  39361. tessellation?: number;
  39362. subdivisions?: number;
  39363. arc?: number;
  39364. faceColors?: Color4[];
  39365. faceUV?: Vector4[];
  39366. updatable?: boolean;
  39367. hasRings?: boolean;
  39368. enclose?: boolean;
  39369. sideOrientation?: number;
  39370. frontUVs?: Vector4;
  39371. backUVs?: Vector4;
  39372. }, scene: any): Mesh;
  39373. }
  39374. }
  39375. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  39376. import { Observable } from "babylonjs/Misc/observable";
  39377. import { Nullable } from "babylonjs/types";
  39378. import { Camera } from "babylonjs/Cameras/camera";
  39379. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39380. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39381. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  39382. import { Scene } from "babylonjs/scene";
  39383. import { Vector3, Color3 } from "babylonjs/Maths/math";
  39384. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  39385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39386. import { Mesh } from "babylonjs/Meshes/mesh";
  39387. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39388. import "babylonjs/Meshes/Builders/groundBuilder";
  39389. import "babylonjs/Meshes/Builders/torusBuilder";
  39390. import "babylonjs/Meshes/Builders/cylinderBuilder";
  39391. /**
  39392. * Options to modify the vr teleportation behavior.
  39393. */
  39394. export interface VRTeleportationOptions {
  39395. /**
  39396. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39397. */
  39398. floorMeshName?: string;
  39399. /**
  39400. * A list of meshes to be used as the teleportation floor. (default: empty)
  39401. */
  39402. floorMeshes?: Mesh[];
  39403. }
  39404. /**
  39405. * Options to modify the vr experience helper's behavior.
  39406. */
  39407. export interface VRExperienceHelperOptions extends WebVROptions {
  39408. /**
  39409. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39410. */
  39411. createDeviceOrientationCamera?: boolean;
  39412. /**
  39413. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39414. */
  39415. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39416. /**
  39417. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39418. */
  39419. laserToggle?: boolean;
  39420. /**
  39421. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39422. */
  39423. floorMeshes?: Mesh[];
  39424. }
  39425. /**
  39426. * Helps to quickly add VR support to an existing scene.
  39427. * See http://doc.babylonjs.com/how_to/webvr_helper
  39428. */
  39429. export class VRExperienceHelper {
  39430. /** Options to modify the vr experience helper's behavior. */
  39431. webVROptions: VRExperienceHelperOptions;
  39432. private _scene;
  39433. private _position;
  39434. private _btnVR;
  39435. private _btnVRDisplayed;
  39436. private _webVRsupported;
  39437. private _webVRready;
  39438. private _webVRrequesting;
  39439. private _webVRpresenting;
  39440. private _hasEnteredVR;
  39441. private _fullscreenVRpresenting;
  39442. private _canvas;
  39443. private _webVRCamera;
  39444. private _vrDeviceOrientationCamera;
  39445. private _deviceOrientationCamera;
  39446. private _existingCamera;
  39447. private _onKeyDown;
  39448. private _onVrDisplayPresentChange;
  39449. private _onVRDisplayChanged;
  39450. private _onVRRequestPresentStart;
  39451. private _onVRRequestPresentComplete;
  39452. /**
  39453. * Observable raised when entering VR.
  39454. */
  39455. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39456. /**
  39457. * Observable raised when exiting VR.
  39458. */
  39459. onExitingVRObservable: Observable<VRExperienceHelper>;
  39460. /**
  39461. * Observable raised when controller mesh is loaded.
  39462. */
  39463. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39464. /** Return this.onEnteringVRObservable
  39465. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39466. */
  39467. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39468. /** Return this.onExitingVRObservable
  39469. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39470. */
  39471. readonly onExitingVR: Observable<VRExperienceHelper>;
  39472. /** Return this.onControllerMeshLoadedObservable
  39473. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39474. */
  39475. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39476. private _rayLength;
  39477. private _useCustomVRButton;
  39478. private _teleportationRequested;
  39479. private _teleportActive;
  39480. private _floorMeshName;
  39481. private _floorMeshesCollection;
  39482. private _rotationAllowed;
  39483. private _teleportBackwardsVector;
  39484. private _teleportationTarget;
  39485. private _isDefaultTeleportationTarget;
  39486. private _postProcessMove;
  39487. private _teleportationFillColor;
  39488. private _teleportationBorderColor;
  39489. private _rotationAngle;
  39490. private _haloCenter;
  39491. private _cameraGazer;
  39492. private _padSensibilityUp;
  39493. private _padSensibilityDown;
  39494. private _leftController;
  39495. private _rightController;
  39496. /**
  39497. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39498. */
  39499. onNewMeshSelected: Observable<AbstractMesh>;
  39500. /**
  39501. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39502. */
  39503. onNewMeshPicked: Observable<PickingInfo>;
  39504. private _circleEase;
  39505. /**
  39506. * Observable raised before camera teleportation
  39507. */
  39508. onBeforeCameraTeleport: Observable<Vector3>;
  39509. /**
  39510. * Observable raised after camera teleportation
  39511. */
  39512. onAfterCameraTeleport: Observable<Vector3>;
  39513. /**
  39514. * Observable raised when current selected mesh gets unselected
  39515. */
  39516. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39517. private _raySelectionPredicate;
  39518. /**
  39519. * To be optionaly changed by user to define custom ray selection
  39520. */
  39521. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39522. /**
  39523. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39524. */
  39525. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39526. /**
  39527. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39528. */
  39529. teleportationEnabled: boolean;
  39530. private _defaultHeight;
  39531. private _teleportationInitialized;
  39532. private _interactionsEnabled;
  39533. private _interactionsRequested;
  39534. private _displayGaze;
  39535. private _displayLaserPointer;
  39536. /**
  39537. * The mesh used to display where the user is going to teleport.
  39538. */
  39539. /**
  39540. * Sets the mesh to be used to display where the user is going to teleport.
  39541. */
  39542. teleportationTarget: Mesh;
  39543. /**
  39544. * 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
  39545. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39546. * See http://doc.babylonjs.com/resources/baking_transformations
  39547. */
  39548. gazeTrackerMesh: Mesh;
  39549. /**
  39550. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39551. */
  39552. updateGazeTrackerScale: boolean;
  39553. /**
  39554. * If the gaze trackers color should be updated when selecting meshes
  39555. */
  39556. updateGazeTrackerColor: boolean;
  39557. /**
  39558. * The gaze tracking mesh corresponding to the left controller
  39559. */
  39560. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39561. /**
  39562. * The gaze tracking mesh corresponding to the right controller
  39563. */
  39564. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39565. /**
  39566. * If the ray of the gaze should be displayed.
  39567. */
  39568. /**
  39569. * Sets if the ray of the gaze should be displayed.
  39570. */
  39571. displayGaze: boolean;
  39572. /**
  39573. * If the ray of the LaserPointer should be displayed.
  39574. */
  39575. /**
  39576. * Sets if the ray of the LaserPointer should be displayed.
  39577. */
  39578. displayLaserPointer: boolean;
  39579. /**
  39580. * The deviceOrientationCamera used as the camera when not in VR.
  39581. */
  39582. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39583. /**
  39584. * Based on the current WebVR support, returns the current VR camera used.
  39585. */
  39586. readonly currentVRCamera: Nullable<Camera>;
  39587. /**
  39588. * The webVRCamera which is used when in VR.
  39589. */
  39590. readonly webVRCamera: WebVRFreeCamera;
  39591. /**
  39592. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39593. */
  39594. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39595. private readonly _teleportationRequestInitiated;
  39596. /**
  39597. * Instantiates a VRExperienceHelper.
  39598. * Helps to quickly add VR support to an existing scene.
  39599. * @param scene The scene the VRExperienceHelper belongs to.
  39600. * @param webVROptions Options to modify the vr experience helper's behavior.
  39601. */
  39602. constructor(scene: Scene,
  39603. /** Options to modify the vr experience helper's behavior. */
  39604. webVROptions?: VRExperienceHelperOptions);
  39605. private _onDefaultMeshLoaded;
  39606. private _onResize;
  39607. private _onFullscreenChange;
  39608. /**
  39609. * Gets a value indicating if we are currently in VR mode.
  39610. */
  39611. readonly isInVRMode: boolean;
  39612. private onVrDisplayPresentChange;
  39613. private onVRDisplayChanged;
  39614. private moveButtonToBottomRight;
  39615. private displayVRButton;
  39616. private updateButtonVisibility;
  39617. private _cachedAngularSensibility;
  39618. /**
  39619. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39620. * Otherwise, will use the fullscreen API.
  39621. */
  39622. enterVR(): void;
  39623. /**
  39624. * Attempt to exit VR, or fullscreen.
  39625. */
  39626. exitVR(): void;
  39627. /**
  39628. * The position of the vr experience helper.
  39629. */
  39630. /**
  39631. * Sets the position of the vr experience helper.
  39632. */
  39633. position: Vector3;
  39634. /**
  39635. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39636. */
  39637. enableInteractions(): void;
  39638. private readonly _noControllerIsActive;
  39639. private beforeRender;
  39640. private _isTeleportationFloor;
  39641. /**
  39642. * Adds a floor mesh to be used for teleportation.
  39643. * @param floorMesh the mesh to be used for teleportation.
  39644. */
  39645. addFloorMesh(floorMesh: Mesh): void;
  39646. /**
  39647. * Removes a floor mesh from being used for teleportation.
  39648. * @param floorMesh the mesh to be removed.
  39649. */
  39650. removeFloorMesh(floorMesh: Mesh): void;
  39651. /**
  39652. * Enables interactions and teleportation using the VR controllers and gaze.
  39653. * @param vrTeleportationOptions options to modify teleportation behavior.
  39654. */
  39655. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39656. private _onNewGamepadConnected;
  39657. private _tryEnableInteractionOnController;
  39658. private _onNewGamepadDisconnected;
  39659. private _enableInteractionOnController;
  39660. private _checkTeleportWithRay;
  39661. private _checkRotate;
  39662. private _checkTeleportBackwards;
  39663. private _enableTeleportationOnController;
  39664. private _createTeleportationCircles;
  39665. private _displayTeleportationTarget;
  39666. private _hideTeleportationTarget;
  39667. private _rotateCamera;
  39668. private _moveTeleportationSelectorTo;
  39669. private _workingVector;
  39670. private _workingQuaternion;
  39671. private _workingMatrix;
  39672. /**
  39673. * Teleports the users feet to the desired location
  39674. * @param location The location where the user's feet should be placed
  39675. */
  39676. teleportCamera(location: Vector3): void;
  39677. private _convertNormalToDirectionOfRay;
  39678. private _castRayAndSelectObject;
  39679. private _notifySelectedMeshUnselected;
  39680. /**
  39681. * Sets the color of the laser ray from the vr controllers.
  39682. * @param color new color for the ray.
  39683. */
  39684. changeLaserColor(color: Color3): void;
  39685. /**
  39686. * Sets the color of the ray from the vr headsets gaze.
  39687. * @param color new color for the ray.
  39688. */
  39689. changeGazeColor(color: Color3): void;
  39690. /**
  39691. * Exits VR and disposes of the vr experience helper
  39692. */
  39693. dispose(): void;
  39694. /**
  39695. * Gets the name of the VRExperienceHelper class
  39696. * @returns "VRExperienceHelper"
  39697. */
  39698. getClassName(): string;
  39699. }
  39700. }
  39701. declare module "babylonjs/Cameras/VR/index" {
  39702. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  39703. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  39704. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39705. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  39706. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  39707. export * from "babylonjs/Cameras/VR/webVRCamera";
  39708. }
  39709. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  39710. import { Observable } from "babylonjs/Misc/observable";
  39711. import { Nullable } from "babylonjs/types";
  39712. import { IDisposable, Scene } from "babylonjs/scene";
  39713. import { Vector3 } from "babylonjs/Maths/math";
  39714. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39715. import { Ray } from "babylonjs/Culling/ray";
  39716. /**
  39717. * Manages an XRSession
  39718. * @see https://doc.babylonjs.com/how_to/webxr
  39719. */
  39720. export class WebXRSessionManager implements IDisposable {
  39721. private scene;
  39722. /**
  39723. * Fires every time a new xrFrame arrives which can be used to update the camera
  39724. */
  39725. onXRFrameObservable: Observable<any>;
  39726. /**
  39727. * Fires when the xr session is ended either by the device or manually done
  39728. */
  39729. onXRSessionEnded: Observable<any>;
  39730. /** @hidden */
  39731. _xrSession: XRSession;
  39732. /** @hidden */
  39733. _frameOfReference: XRFrameOfReference;
  39734. /** @hidden */
  39735. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39736. /** @hidden */
  39737. _currentXRFrame: Nullable<XRFrame>;
  39738. private _xrNavigator;
  39739. private _xrDevice;
  39740. private _tmpMatrix;
  39741. /**
  39742. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39743. * @param scene The scene which the session should be created for
  39744. */
  39745. constructor(scene: Scene);
  39746. /**
  39747. * Initializes the manager
  39748. * After initialization enterXR can be called to start an XR session
  39749. * @returns Promise which resolves after it is initialized
  39750. */
  39751. initializeAsync(): Promise<void>;
  39752. /**
  39753. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39754. * @param sessionCreationOptions xr options to create the session with
  39755. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39756. * @returns Promise which resolves after it enters XR
  39757. */
  39758. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39759. /**
  39760. * Stops the xrSession and restores the renderloop
  39761. * @returns Promise which resolves after it exits XR
  39762. */
  39763. exitXRAsync(): Promise<void>;
  39764. /**
  39765. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39766. * @param ray ray to cast into the environment
  39767. * @returns Promise which resolves with a collision point in the environment if it exists
  39768. */
  39769. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39770. /**
  39771. * Checks if a session would be supported for the creation options specified
  39772. * @param options creation options to check if they are supported
  39773. * @returns true if supported
  39774. */
  39775. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39776. /**
  39777. * @hidden
  39778. * Converts the render layer of xrSession to a render target
  39779. * @param session session to create render target for
  39780. * @param scene scene the new render target should be created for
  39781. */
  39782. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39783. /**
  39784. * Disposes of the session manager
  39785. */
  39786. dispose(): void;
  39787. }
  39788. }
  39789. declare module "babylonjs/Cameras/XR/webXRCamera" {
  39790. import { Scene } from "babylonjs/scene";
  39791. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39792. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39793. /**
  39794. * WebXR Camera which holds the views for the xrSession
  39795. * @see https://doc.babylonjs.com/how_to/webxr
  39796. */
  39797. export class WebXRCamera extends FreeCamera {
  39798. private static _TmpMatrix;
  39799. /**
  39800. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39801. * @param name the name of the camera
  39802. * @param scene the scene to add the camera to
  39803. */
  39804. constructor(name: string, scene: Scene);
  39805. private _updateNumberOfRigCameras;
  39806. /** @hidden */
  39807. _updateForDualEyeDebugging(pupilDistance?: number): void;
  39808. /**
  39809. * Updates the cameras position from the current pose information of the XR session
  39810. * @param xrSessionManager the session containing pose information
  39811. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39812. */
  39813. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39814. }
  39815. }
  39816. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  39817. import { Nullable } from "babylonjs/types";
  39818. import { Observable } from "babylonjs/Misc/observable";
  39819. import { IDisposable, Scene } from "babylonjs/scene";
  39820. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  39821. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39822. import { Ray } from "babylonjs/Culling/ray";
  39823. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  39824. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  39825. /**
  39826. * States of the webXR experience
  39827. */
  39828. export enum WebXRState {
  39829. /**
  39830. * Transitioning to being in XR mode
  39831. */
  39832. ENTERING_XR = 0,
  39833. /**
  39834. * Transitioning to non XR mode
  39835. */
  39836. EXITING_XR = 1,
  39837. /**
  39838. * In XR mode and presenting
  39839. */
  39840. IN_XR = 2,
  39841. /**
  39842. * Not entered XR mode
  39843. */
  39844. NOT_IN_XR = 3
  39845. }
  39846. /**
  39847. * Helper class used to enable XR
  39848. * @see https://doc.babylonjs.com/how_to/webxr
  39849. */
  39850. export class WebXRExperienceHelper implements IDisposable {
  39851. private scene;
  39852. /**
  39853. * 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
  39854. */
  39855. container: AbstractMesh;
  39856. /**
  39857. * Camera used to render xr content
  39858. */
  39859. camera: WebXRCamera;
  39860. /**
  39861. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39862. */
  39863. state: WebXRState;
  39864. private _setState;
  39865. private static _TmpVector;
  39866. /**
  39867. * Fires when the state of the experience helper has changed
  39868. */
  39869. onStateChangedObservable: Observable<WebXRState>;
  39870. /** @hidden */
  39871. _sessionManager: WebXRSessionManager;
  39872. private _nonVRCamera;
  39873. private _originalSceneAutoClear;
  39874. private _supported;
  39875. /**
  39876. * Creates the experience helper
  39877. * @param scene the scene to attach the experience helper to
  39878. * @returns a promise for the experience helper
  39879. */
  39880. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39881. /**
  39882. * Creates a WebXRExperienceHelper
  39883. * @param scene The scene the helper should be created in
  39884. */
  39885. private constructor();
  39886. /**
  39887. * Exits XR mode and returns the scene to its original state
  39888. * @returns promise that resolves after xr mode has exited
  39889. */
  39890. exitXRAsync(): Promise<void>;
  39891. /**
  39892. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39893. * @param sessionCreationOptions options for the XR session
  39894. * @param frameOfReference frame of reference of the XR session
  39895. * @returns promise that resolves after xr mode has entered
  39896. */
  39897. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39898. /**
  39899. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39900. * @param ray ray to cast into the environment
  39901. * @returns Promise which resolves with a collision point in the environment if it exists
  39902. */
  39903. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39904. /**
  39905. * Updates the global position of the camera by moving the camera's container
  39906. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39907. * @param position The desired global position of the camera
  39908. */
  39909. setPositionOfCameraUsingContainer(position: Vector3): void;
  39910. /**
  39911. * Rotates the xr camera by rotating the camera's container around the camera's position
  39912. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39913. * @param rotation the desired quaternion rotation to apply to the camera
  39914. */
  39915. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39916. /**
  39917. * Checks if the creation options are supported by the xr session
  39918. * @param options creation options
  39919. * @returns true if supported
  39920. */
  39921. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39922. /**
  39923. * Disposes of the experience helper
  39924. */
  39925. dispose(): void;
  39926. }
  39927. }
  39928. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  39929. import { Nullable } from "babylonjs/types";
  39930. import { Observable } from "babylonjs/Misc/observable";
  39931. import { IDisposable, Scene } from "babylonjs/scene";
  39932. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  39933. /**
  39934. * Button which can be used to enter a different mode of XR
  39935. */
  39936. export class WebXREnterExitUIButton {
  39937. /** button element */
  39938. element: HTMLElement;
  39939. /** XR initialization options for the button */
  39940. initializationOptions: XRSessionCreationOptions;
  39941. /**
  39942. * Creates a WebXREnterExitUIButton
  39943. * @param element button element
  39944. * @param initializationOptions XR initialization options for the button
  39945. */
  39946. constructor(
  39947. /** button element */
  39948. element: HTMLElement,
  39949. /** XR initialization options for the button */
  39950. initializationOptions: XRSessionCreationOptions);
  39951. /**
  39952. * Overwritable function which can be used to update the button's visuals when the state changes
  39953. * @param activeButton the current active button in the UI
  39954. */
  39955. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39956. }
  39957. /**
  39958. * Options to create the webXR UI
  39959. */
  39960. export class WebXREnterExitUIOptions {
  39961. /**
  39962. * Context to enter xr with
  39963. */
  39964. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39965. /**
  39966. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39967. */
  39968. customButtons?: Array<WebXREnterExitUIButton>;
  39969. }
  39970. /**
  39971. * UI to allow the user to enter/exit XR mode
  39972. */
  39973. export class WebXREnterExitUI implements IDisposable {
  39974. private scene;
  39975. private _overlay;
  39976. private _buttons;
  39977. private _activeButton;
  39978. /**
  39979. * Fired every time the active button is changed.
  39980. *
  39981. * When xr is entered via a button that launches xr that button will be the callback parameter
  39982. *
  39983. * When exiting xr the callback parameter will be null)
  39984. */
  39985. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39986. /**
  39987. * Creates UI to allow the user to enter/exit XR mode
  39988. * @param scene the scene to add the ui to
  39989. * @param helper the xr experience helper to enter/exit xr with
  39990. * @param options options to configure the UI
  39991. * @returns the created ui
  39992. */
  39993. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39994. private constructor();
  39995. private _updateButtons;
  39996. /**
  39997. * Disposes of the object
  39998. */
  39999. dispose(): void;
  40000. }
  40001. }
  40002. declare module "babylonjs/Cameras/XR/webXRInput" {
  40003. import { IDisposable, Scene } from "babylonjs/scene";
  40004. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40005. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40006. /**
  40007. * Represents an XR input
  40008. */
  40009. export class WebXRController {
  40010. /**
  40011. * 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
  40012. */
  40013. grip?: AbstractMesh;
  40014. /**
  40015. * Pointer which can be used to select objects or attach a visible laser to
  40016. */
  40017. pointer: AbstractMesh;
  40018. /**
  40019. * Creates the controller
  40020. * @see https://doc.babylonjs.com/how_to/webxr
  40021. * @param scene the scene which the controller should be associated to
  40022. */
  40023. constructor(scene: Scene);
  40024. /**
  40025. * Disposes of the object
  40026. */
  40027. dispose(): void;
  40028. }
  40029. /**
  40030. * XR input used to track XR inputs such as controllers/rays
  40031. */
  40032. export class WebXRInput implements IDisposable {
  40033. private helper;
  40034. /**
  40035. * XR controllers being tracked
  40036. */
  40037. controllers: Array<WebXRController>;
  40038. private _tmpMatrix;
  40039. private _frameObserver;
  40040. /**
  40041. * Initializes the WebXRInput
  40042. * @param helper experience helper which the input should be created for
  40043. */
  40044. constructor(helper: WebXRExperienceHelper);
  40045. /**
  40046. * Disposes of the object
  40047. */
  40048. dispose(): void;
  40049. }
  40050. }
  40051. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  40052. import { Nullable } from "babylonjs/types";
  40053. import { IDisposable } from "babylonjs/scene";
  40054. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40055. /**
  40056. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40057. */
  40058. export class WebXRManagedOutputCanvas implements IDisposable {
  40059. private _canvas;
  40060. /**
  40061. * xrpresent context of the canvas which can be used to display/mirror xr content
  40062. */
  40063. canvasContext: Nullable<WebGLRenderingContext>;
  40064. /**
  40065. * Initializes the canvas to be added/removed upon entering/exiting xr
  40066. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40067. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40068. */
  40069. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40070. /**
  40071. * Disposes of the object
  40072. */
  40073. dispose(): void;
  40074. private _setManagedOutputCanvas;
  40075. private _addCanvas;
  40076. private _removeCanvas;
  40077. }
  40078. }
  40079. declare module "babylonjs/Cameras/XR/index" {
  40080. export * from "babylonjs/Cameras/XR/webXRCamera";
  40081. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  40082. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  40083. export * from "babylonjs/Cameras/XR/webXRInput";
  40084. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  40085. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  40086. }
  40087. declare module "babylonjs/Cameras/RigModes/index" {
  40088. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40089. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40090. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  40091. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  40092. }
  40093. declare module "babylonjs/Cameras/index" {
  40094. export * from "babylonjs/Cameras/Inputs/index";
  40095. export * from "babylonjs/Cameras/cameraInputsManager";
  40096. export * from "babylonjs/Cameras/camera";
  40097. export * from "babylonjs/Cameras/targetCamera";
  40098. export * from "babylonjs/Cameras/freeCamera";
  40099. export * from "babylonjs/Cameras/freeCameraInputsManager";
  40100. export * from "babylonjs/Cameras/touchCamera";
  40101. export * from "babylonjs/Cameras/arcRotateCamera";
  40102. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40103. export * from "babylonjs/Cameras/deviceOrientationCamera";
  40104. export * from "babylonjs/Cameras/flyCamera";
  40105. export * from "babylonjs/Cameras/flyCameraInputsManager";
  40106. export * from "babylonjs/Cameras/followCamera";
  40107. export * from "babylonjs/Cameras/gamepadCamera";
  40108. export * from "babylonjs/Cameras/Stereoscopic/index";
  40109. export * from "babylonjs/Cameras/universalCamera";
  40110. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  40111. export * from "babylonjs/Cameras/VR/index";
  40112. export * from "babylonjs/Cameras/XR/index";
  40113. export * from "babylonjs/Cameras/RigModes/index";
  40114. }
  40115. declare module "babylonjs/Collisions/index" {
  40116. export * from "babylonjs/Collisions/collider";
  40117. export * from "babylonjs/Collisions/collisionCoordinator";
  40118. export * from "babylonjs/Collisions/pickingInfo";
  40119. export * from "babylonjs/Collisions/intersectionInfo";
  40120. }
  40121. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  40122. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  40123. import { Vector3, Plane } from "babylonjs/Maths/math";
  40124. import { Ray } from "babylonjs/Culling/ray";
  40125. /**
  40126. * Contains an array of blocks representing the octree
  40127. */
  40128. export interface IOctreeContainer<T> {
  40129. /**
  40130. * Blocks within the octree
  40131. */
  40132. blocks: Array<OctreeBlock<T>>;
  40133. }
  40134. /**
  40135. * Class used to store a cell in an octree
  40136. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40137. */
  40138. export class OctreeBlock<T> {
  40139. /**
  40140. * Gets the content of the current block
  40141. */
  40142. entries: T[];
  40143. /**
  40144. * Gets the list of block children
  40145. */
  40146. blocks: Array<OctreeBlock<T>>;
  40147. private _depth;
  40148. private _maxDepth;
  40149. private _capacity;
  40150. private _minPoint;
  40151. private _maxPoint;
  40152. private _boundingVectors;
  40153. private _creationFunc;
  40154. /**
  40155. * Creates a new block
  40156. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  40157. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  40158. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40159. * @param depth defines the current depth of this block in the octree
  40160. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  40161. * @param creationFunc defines a callback to call when an element is added to the block
  40162. */
  40163. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  40164. /**
  40165. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  40166. */
  40167. readonly capacity: number;
  40168. /**
  40169. * Gets the minimum vector (in world space) of the block's bounding box
  40170. */
  40171. readonly minPoint: Vector3;
  40172. /**
  40173. * Gets the maximum vector (in world space) of the block's bounding box
  40174. */
  40175. readonly maxPoint: Vector3;
  40176. /**
  40177. * Add a new element to this block
  40178. * @param entry defines the element to add
  40179. */
  40180. addEntry(entry: T): void;
  40181. /**
  40182. * Remove an element from this block
  40183. * @param entry defines the element to remove
  40184. */
  40185. removeEntry(entry: T): void;
  40186. /**
  40187. * Add an array of elements to this block
  40188. * @param entries defines the array of elements to add
  40189. */
  40190. addEntries(entries: T[]): void;
  40191. /**
  40192. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  40193. * @param frustumPlanes defines the frustum planes to test
  40194. * @param selection defines the array to store current content if selection is positive
  40195. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40196. */
  40197. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40198. /**
  40199. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  40200. * @param sphereCenter defines the bounding sphere center
  40201. * @param sphereRadius defines the bounding sphere radius
  40202. * @param selection defines the array to store current content if selection is positive
  40203. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40204. */
  40205. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  40206. /**
  40207. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  40208. * @param ray defines the ray to test with
  40209. * @param selection defines the array to store current content if selection is positive
  40210. */
  40211. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  40212. /**
  40213. * Subdivide the content into child blocks (this block will then be empty)
  40214. */
  40215. createInnerBlocks(): void;
  40216. /**
  40217. * @hidden
  40218. */
  40219. 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;
  40220. }
  40221. }
  40222. declare module "babylonjs/Culling/Octrees/octree" {
  40223. import { SmartArray } from "babylonjs/Misc/smartArray";
  40224. import { Vector3, Plane } from "babylonjs/Maths/math";
  40225. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40227. import { Ray } from "babylonjs/Culling/ray";
  40228. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  40229. /**
  40230. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  40231. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40232. */
  40233. export class Octree<T> {
  40234. /** 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.) */
  40235. maxDepth: number;
  40236. /**
  40237. * Blocks within the octree containing objects
  40238. */
  40239. blocks: Array<OctreeBlock<T>>;
  40240. /**
  40241. * Content stored in the octree
  40242. */
  40243. dynamicContent: T[];
  40244. private _maxBlockCapacity;
  40245. private _selectionContent;
  40246. private _creationFunc;
  40247. /**
  40248. * Creates a octree
  40249. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40250. * @param creationFunc function to be used to instatiate the octree
  40251. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  40252. * @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.)
  40253. */
  40254. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  40255. /** 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.) */
  40256. maxDepth?: number);
  40257. /**
  40258. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  40259. * @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);
  40260. * @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);
  40261. * @param entries meshes to be added to the octree blocks
  40262. */
  40263. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  40264. /**
  40265. * Adds a mesh to the octree
  40266. * @param entry Mesh to add to the octree
  40267. */
  40268. addMesh(entry: T): void;
  40269. /**
  40270. * Remove an element from the octree
  40271. * @param entry defines the element to remove
  40272. */
  40273. removeMesh(entry: T): void;
  40274. /**
  40275. * Selects an array of meshes within the frustum
  40276. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  40277. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  40278. * @returns array of meshes within the frustum
  40279. */
  40280. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  40281. /**
  40282. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  40283. * @param sphereCenter defines the bounding sphere center
  40284. * @param sphereRadius defines the bounding sphere radius
  40285. * @param allowDuplicate defines if the selection array can contains duplicated entries
  40286. * @returns an array of objects that intersect the sphere
  40287. */
  40288. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  40289. /**
  40290. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  40291. * @param ray defines the ray to test with
  40292. * @returns array of intersected objects
  40293. */
  40294. intersectsRay(ray: Ray): SmartArray<T>;
  40295. /**
  40296. * Adds a mesh into the octree block if it intersects the block
  40297. */
  40298. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  40299. /**
  40300. * Adds a submesh into the octree block if it intersects the block
  40301. */
  40302. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  40303. }
  40304. }
  40305. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  40306. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40307. import { Scene } from "babylonjs/scene";
  40308. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40310. import { Ray } from "babylonjs/Culling/ray";
  40311. import { Octree } from "babylonjs/Culling/Octrees/octree";
  40312. import { Collider } from "babylonjs/Collisions/collider";
  40313. module "babylonjs/scene" {
  40314. interface Scene {
  40315. /**
  40316. * @hidden
  40317. * Backing Filed
  40318. */
  40319. _selectionOctree: Octree<AbstractMesh>;
  40320. /**
  40321. * Gets the octree used to boost mesh selection (picking)
  40322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40323. */
  40324. selectionOctree: Octree<AbstractMesh>;
  40325. /**
  40326. * Creates or updates the octree used to boost selection (picking)
  40327. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40328. * @param maxCapacity defines the maximum capacity per leaf
  40329. * @param maxDepth defines the maximum depth of the octree
  40330. * @returns an octree of AbstractMesh
  40331. */
  40332. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  40333. }
  40334. }
  40335. module "babylonjs/Meshes/abstractMesh" {
  40336. interface AbstractMesh {
  40337. /**
  40338. * @hidden
  40339. * Backing Field
  40340. */
  40341. _submeshesOctree: Octree<SubMesh>;
  40342. /**
  40343. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  40344. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  40345. * @param maxCapacity defines the maximum size of each block (64 by default)
  40346. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  40347. * @returns the new octree
  40348. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  40349. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  40350. */
  40351. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  40352. }
  40353. }
  40354. /**
  40355. * Defines the octree scene component responsible to manage any octrees
  40356. * in a given scene.
  40357. */
  40358. export class OctreeSceneComponent {
  40359. /**
  40360. * The component name helpfull to identify the component in the list of scene components.
  40361. */
  40362. readonly name: string;
  40363. /**
  40364. * The scene the component belongs to.
  40365. */
  40366. scene: Scene;
  40367. /**
  40368. * Indicates if the meshes have been checked to make sure they are isEnabled()
  40369. */
  40370. readonly checksIsEnabled: boolean;
  40371. /**
  40372. * Creates a new instance of the component for the given scene
  40373. * @param scene Defines the scene to register the component in
  40374. */
  40375. constructor(scene: Scene);
  40376. /**
  40377. * Registers the component in a given scene
  40378. */
  40379. register(): void;
  40380. /**
  40381. * Return the list of active meshes
  40382. * @returns the list of active meshes
  40383. */
  40384. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40385. /**
  40386. * Return the list of active sub meshes
  40387. * @param mesh The mesh to get the candidates sub meshes from
  40388. * @returns the list of active sub meshes
  40389. */
  40390. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40391. private _tempRay;
  40392. /**
  40393. * Return the list of sub meshes intersecting with a given local ray
  40394. * @param mesh defines the mesh to find the submesh for
  40395. * @param localRay defines the ray in local space
  40396. * @returns the list of intersecting sub meshes
  40397. */
  40398. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  40399. /**
  40400. * Return the list of sub meshes colliding with a collider
  40401. * @param mesh defines the mesh to find the submesh for
  40402. * @param collider defines the collider to evaluate the collision against
  40403. * @returns the list of colliding sub meshes
  40404. */
  40405. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  40406. /**
  40407. * Rebuilds the elements related to this component in case of
  40408. * context lost for instance.
  40409. */
  40410. rebuild(): void;
  40411. /**
  40412. * Disposes the component and the associated ressources.
  40413. */
  40414. dispose(): void;
  40415. }
  40416. }
  40417. declare module "babylonjs/Culling/Octrees/index" {
  40418. export * from "babylonjs/Culling/Octrees/octree";
  40419. export * from "babylonjs/Culling/Octrees/octreeBlock";
  40420. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  40421. }
  40422. declare module "babylonjs/Culling/index" {
  40423. export * from "babylonjs/Culling/boundingBox";
  40424. export * from "babylonjs/Culling/boundingInfo";
  40425. export * from "babylonjs/Culling/boundingSphere";
  40426. export * from "babylonjs/Culling/Octrees/index";
  40427. export * from "babylonjs/Culling/ray";
  40428. }
  40429. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  40430. import { Vector3, Color4 } from "babylonjs/Maths/math";
  40431. import { Nullable } from "babylonjs/types";
  40432. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  40433. import { Scene } from "babylonjs/scene";
  40434. /**
  40435. * Class containing static functions to help procedurally build meshes
  40436. */
  40437. export class LinesBuilder {
  40438. /**
  40439. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40440. * * 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
  40441. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40442. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40443. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40444. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40445. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40446. * * 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
  40447. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40450. * @param name defines the name of the new line system
  40451. * @param options defines the options used to create the line system
  40452. * @param scene defines the hosting scene
  40453. * @returns a new line system mesh
  40454. */
  40455. static CreateLineSystem(name: string, options: {
  40456. lines: Vector3[][];
  40457. updatable?: boolean;
  40458. instance?: Nullable<LinesMesh>;
  40459. colors?: Nullable<Color4[][]>;
  40460. useVertexAlpha?: boolean;
  40461. }, scene: Nullable<Scene>): LinesMesh;
  40462. /**
  40463. * Creates a line mesh
  40464. * 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
  40465. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40466. * * The parameter `points` is an array successive Vector3
  40467. * * 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
  40468. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40469. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40470. * * When updating an instance, remember that only point positions can change, not the number of points
  40471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40472. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40473. * @param name defines the name of the new line system
  40474. * @param options defines the options used to create the line system
  40475. * @param scene defines the hosting scene
  40476. * @returns a new line mesh
  40477. */
  40478. static CreateLines(name: string, options: {
  40479. points: Vector3[];
  40480. updatable?: boolean;
  40481. instance?: Nullable<LinesMesh>;
  40482. colors?: Color4[];
  40483. useVertexAlpha?: boolean;
  40484. }, scene?: Nullable<Scene>): LinesMesh;
  40485. /**
  40486. * Creates a dashed line mesh
  40487. * * 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
  40488. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40489. * * The parameter `points` is an array successive Vector3
  40490. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40491. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40492. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40493. * * 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
  40494. * * When updating an instance, remember that only point positions can change, not the number of points
  40495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40496. * @param name defines the name of the mesh
  40497. * @param options defines the options used to create the mesh
  40498. * @param scene defines the hosting scene
  40499. * @returns the dashed line mesh
  40500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40501. */
  40502. static CreateDashedLines(name: string, options: {
  40503. points: Vector3[];
  40504. dashSize?: number;
  40505. gapSize?: number;
  40506. dashNb?: number;
  40507. updatable?: boolean;
  40508. instance?: LinesMesh;
  40509. }, scene?: Nullable<Scene>): LinesMesh;
  40510. }
  40511. }
  40512. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  40513. import { IDisposable, Scene } from "babylonjs/scene";
  40514. import { Nullable } from "babylonjs/types";
  40515. import { Observable } from "babylonjs/Misc/observable";
  40516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40517. /**
  40518. * Renders a layer on top of an existing scene
  40519. */
  40520. export class UtilityLayerRenderer implements IDisposable {
  40521. /** the original scene that will be rendered on top of */
  40522. originalScene: Scene;
  40523. private _pointerCaptures;
  40524. private _lastPointerEvents;
  40525. private static _DefaultUtilityLayer;
  40526. private static _DefaultKeepDepthUtilityLayer;
  40527. /**
  40528. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  40529. */
  40530. pickUtilitySceneFirst: boolean;
  40531. /**
  40532. * 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)
  40533. */
  40534. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  40535. /**
  40536. * 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)
  40537. */
  40538. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  40539. /**
  40540. * The scene that is rendered on top of the original scene
  40541. */
  40542. utilityLayerScene: Scene;
  40543. /**
  40544. * If the utility layer should automatically be rendered on top of existing scene
  40545. */
  40546. shouldRender: boolean;
  40547. /**
  40548. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  40549. */
  40550. onlyCheckPointerDownEvents: boolean;
  40551. /**
  40552. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  40553. */
  40554. processAllEvents: boolean;
  40555. /**
  40556. * Observable raised when the pointer move from the utility layer scene to the main scene
  40557. */
  40558. onPointerOutObservable: Observable<number>;
  40559. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40560. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40561. private _afterRenderObserver;
  40562. private _sceneDisposeObserver;
  40563. private _originalPointerObserver;
  40564. /**
  40565. * Instantiates a UtilityLayerRenderer
  40566. * @param originalScene the original scene that will be rendered on top of
  40567. * @param handleEvents boolean indicating if the utility layer should handle events
  40568. */
  40569. constructor(
  40570. /** the original scene that will be rendered on top of */
  40571. originalScene: Scene, handleEvents?: boolean);
  40572. private _notifyObservers;
  40573. /**
  40574. * Renders the utility layers scene on top of the original scene
  40575. */
  40576. render(): void;
  40577. /**
  40578. * Disposes of the renderer
  40579. */
  40580. dispose(): void;
  40581. private _updateCamera;
  40582. }
  40583. }
  40584. declare module "babylonjs/Gizmos/gizmo" {
  40585. import { Nullable } from "babylonjs/types";
  40586. import { IDisposable } from "babylonjs/scene";
  40587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40588. import { Mesh } from "babylonjs/Meshes/mesh";
  40589. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40590. /**
  40591. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40592. */
  40593. export class Gizmo implements IDisposable {
  40594. /** The utility layer the gizmo will be added to */
  40595. gizmoLayer: UtilityLayerRenderer;
  40596. /**
  40597. * The root mesh of the gizmo
  40598. */
  40599. protected _rootMesh: Mesh;
  40600. private _attachedMesh;
  40601. /**
  40602. * Ratio for the scale of the gizmo (Default: 1)
  40603. */
  40604. scaleRatio: number;
  40605. private _tmpMatrix;
  40606. /**
  40607. * If a custom mesh has been set (Default: false)
  40608. */
  40609. protected _customMeshSet: boolean;
  40610. /**
  40611. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40612. * * When set, interactions will be enabled
  40613. */
  40614. attachedMesh: Nullable<AbstractMesh>;
  40615. /**
  40616. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40617. * @param mesh The mesh to replace the default mesh of the gizmo
  40618. */
  40619. setCustomMesh(mesh: Mesh): void;
  40620. /**
  40621. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40622. */
  40623. updateGizmoRotationToMatchAttachedMesh: boolean;
  40624. /**
  40625. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40626. */
  40627. updateGizmoPositionToMatchAttachedMesh: boolean;
  40628. /**
  40629. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40630. */
  40631. protected _updateScale: boolean;
  40632. protected _interactionsEnabled: boolean;
  40633. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40634. private _beforeRenderObserver;
  40635. /**
  40636. * Creates a gizmo
  40637. * @param gizmoLayer The utility layer the gizmo will be added to
  40638. */
  40639. constructor(
  40640. /** The utility layer the gizmo will be added to */
  40641. gizmoLayer?: UtilityLayerRenderer);
  40642. private _tempVector;
  40643. /**
  40644. * @hidden
  40645. * Updates the gizmo to match the attached mesh's position/rotation
  40646. */
  40647. protected _update(): void;
  40648. /**
  40649. * Disposes of the gizmo
  40650. */
  40651. dispose(): void;
  40652. }
  40653. }
  40654. declare module "babylonjs/Gizmos/axisDragGizmo" {
  40655. import { Observable } from "babylonjs/Misc/observable";
  40656. import { Nullable } from "babylonjs/types";
  40657. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40658. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40660. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40661. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  40662. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  40663. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  40664. import { Scene } from "babylonjs/scene";
  40665. /**
  40666. * Single axis drag gizmo
  40667. */
  40668. export class AxisDragGizmo extends Gizmo {
  40669. /**
  40670. * Drag behavior responsible for the gizmos dragging interactions
  40671. */
  40672. dragBehavior: PointerDragBehavior;
  40673. private _pointerObserver;
  40674. /**
  40675. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40676. */
  40677. snapDistance: number;
  40678. /**
  40679. * Event that fires each time the gizmo snaps to a new location.
  40680. * * snapDistance is the the change in distance
  40681. */
  40682. onSnapObservable: Observable<{
  40683. snapDistance: number;
  40684. }>;
  40685. /** @hidden */
  40686. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40687. /** @hidden */
  40688. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40689. /**
  40690. * Creates an AxisDragGizmo
  40691. * @param gizmoLayer The utility layer the gizmo will be added to
  40692. * @param dragAxis The axis which the gizmo will be able to drag on
  40693. * @param color The color of the gizmo
  40694. */
  40695. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40696. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40697. /**
  40698. * Disposes of the gizmo
  40699. */
  40700. dispose(): void;
  40701. }
  40702. }
  40703. declare module "babylonjs/Debug/axesViewer" {
  40704. import { Vector3 } from "babylonjs/Maths/math";
  40705. import { Nullable } from "babylonjs/types";
  40706. import { Scene } from "babylonjs/scene";
  40707. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40708. /**
  40709. * The Axes viewer will show 3 axes in a specific point in space
  40710. */
  40711. export class AxesViewer {
  40712. private _xAxis;
  40713. private _yAxis;
  40714. private _zAxis;
  40715. private _scaleLinesFactor;
  40716. private _instanced;
  40717. /**
  40718. * Gets the hosting scene
  40719. */
  40720. scene: Scene;
  40721. /**
  40722. * Gets or sets a number used to scale line length
  40723. */
  40724. scaleLines: number;
  40725. /** Gets the node hierarchy used to render x-axis */
  40726. readonly xAxis: TransformNode;
  40727. /** Gets the node hierarchy used to render y-axis */
  40728. readonly yAxis: TransformNode;
  40729. /** Gets the node hierarchy used to render z-axis */
  40730. readonly zAxis: TransformNode;
  40731. /**
  40732. * Creates a new AxesViewer
  40733. * @param scene defines the hosting scene
  40734. * @param scaleLines defines a number used to scale line length (1 by default)
  40735. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40736. * @param xAxis defines the node hierarchy used to render the x-axis
  40737. * @param yAxis defines the node hierarchy used to render the y-axis
  40738. * @param zAxis defines the node hierarchy used to render the z-axis
  40739. */
  40740. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40741. /**
  40742. * Force the viewer to update
  40743. * @param position defines the position of the viewer
  40744. * @param xaxis defines the x axis of the viewer
  40745. * @param yaxis defines the y axis of the viewer
  40746. * @param zaxis defines the z axis of the viewer
  40747. */
  40748. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40749. /**
  40750. * Creates an instance of this axes viewer.
  40751. * @returns a new axes viewer with instanced meshes
  40752. */
  40753. createInstance(): AxesViewer;
  40754. /** Releases resources */
  40755. dispose(): void;
  40756. private static _SetRenderingGroupId;
  40757. }
  40758. }
  40759. declare module "babylonjs/Debug/boneAxesViewer" {
  40760. import { Nullable } from "babylonjs/types";
  40761. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  40762. import { Vector3 } from "babylonjs/Maths/math";
  40763. import { Mesh } from "babylonjs/Meshes/mesh";
  40764. import { Bone } from "babylonjs/Bones/bone";
  40765. import { Scene } from "babylonjs/scene";
  40766. /**
  40767. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40768. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40769. */
  40770. export class BoneAxesViewer extends AxesViewer {
  40771. /**
  40772. * Gets or sets the target mesh where to display the axes viewer
  40773. */
  40774. mesh: Nullable<Mesh>;
  40775. /**
  40776. * Gets or sets the target bone where to display the axes viewer
  40777. */
  40778. bone: Nullable<Bone>;
  40779. /** Gets current position */
  40780. pos: Vector3;
  40781. /** Gets direction of X axis */
  40782. xaxis: Vector3;
  40783. /** Gets direction of Y axis */
  40784. yaxis: Vector3;
  40785. /** Gets direction of Z axis */
  40786. zaxis: Vector3;
  40787. /**
  40788. * Creates a new BoneAxesViewer
  40789. * @param scene defines the hosting scene
  40790. * @param bone defines the target bone
  40791. * @param mesh defines the target mesh
  40792. * @param scaleLines defines a scaling factor for line length (1 by default)
  40793. */
  40794. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40795. /**
  40796. * Force the viewer to update
  40797. */
  40798. update(): void;
  40799. /** Releases resources */
  40800. dispose(): void;
  40801. }
  40802. }
  40803. declare module "babylonjs/Debug/debugLayer" {
  40804. import { Observable } from "babylonjs/Misc/observable";
  40805. import { Scene } from "babylonjs/scene";
  40806. /**
  40807. * Interface used to define scene explorer extensibility option
  40808. */
  40809. export interface IExplorerExtensibilityOption {
  40810. /**
  40811. * Define the option label
  40812. */
  40813. label: string;
  40814. /**
  40815. * Defines the action to execute on click
  40816. */
  40817. action: (entity: any) => void;
  40818. }
  40819. /**
  40820. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40821. */
  40822. export interface IExplorerExtensibilityGroup {
  40823. /**
  40824. * Defines a predicate to test if a given type mut be extended
  40825. */
  40826. predicate: (entity: any) => boolean;
  40827. /**
  40828. * Gets the list of options added to a type
  40829. */
  40830. entries: IExplorerExtensibilityOption[];
  40831. }
  40832. /**
  40833. * Interface used to define the options to use to create the Inspector
  40834. */
  40835. export interface IInspectorOptions {
  40836. /**
  40837. * Display in overlay mode (default: false)
  40838. */
  40839. overlay?: boolean;
  40840. /**
  40841. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40842. */
  40843. globalRoot?: HTMLElement;
  40844. /**
  40845. * Display the Scene explorer
  40846. */
  40847. showExplorer?: boolean;
  40848. /**
  40849. * Display the property inspector
  40850. */
  40851. showInspector?: boolean;
  40852. /**
  40853. * Display in embed mode (both panes on the right)
  40854. */
  40855. embedMode?: boolean;
  40856. /**
  40857. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40858. */
  40859. handleResize?: boolean;
  40860. /**
  40861. * Allow the panes to popup (default: true)
  40862. */
  40863. enablePopup?: boolean;
  40864. /**
  40865. * Allow the panes to be closed by users (default: true)
  40866. */
  40867. enableClose?: boolean;
  40868. /**
  40869. * Optional list of extensibility entries
  40870. */
  40871. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40872. }
  40873. module "babylonjs/scene" {
  40874. interface Scene {
  40875. /**
  40876. * @hidden
  40877. * Backing field
  40878. */
  40879. _debugLayer: DebugLayer;
  40880. /**
  40881. * Gets the debug layer (aka Inspector) associated with the scene
  40882. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40883. */
  40884. debugLayer: DebugLayer;
  40885. }
  40886. }
  40887. /**
  40888. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40889. * what is happening in your scene
  40890. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40891. */
  40892. export class DebugLayer {
  40893. /**
  40894. * Define the url to get the inspector script from.
  40895. * By default it uses the babylonjs CDN.
  40896. * @ignoreNaming
  40897. */
  40898. static InspectorURL: string;
  40899. private _scene;
  40900. private BJSINSPECTOR;
  40901. /**
  40902. * Observable triggered when a property is changed through the inspector.
  40903. */
  40904. onPropertyChangedObservable: Observable<{
  40905. object: any;
  40906. property: string;
  40907. value: any;
  40908. initialValue: any;
  40909. }>;
  40910. /**
  40911. * Instantiates a new debug layer.
  40912. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40913. * what is happening in your scene
  40914. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40915. * @param scene Defines the scene to inspect
  40916. */
  40917. constructor(scene: Scene);
  40918. /** Creates the inspector window. */
  40919. private _createInspector;
  40920. /** Get the inspector from bundle or global */
  40921. private _getGlobalInspector;
  40922. /**
  40923. * Get if the inspector is visible or not.
  40924. * @returns true if visible otherwise, false
  40925. */
  40926. isVisible(): boolean;
  40927. /**
  40928. * Hide the inspector and close its window.
  40929. */
  40930. hide(): void;
  40931. /**
  40932. * Launch the debugLayer.
  40933. * @param config Define the configuration of the inspector
  40934. */
  40935. show(config?: IInspectorOptions): void;
  40936. }
  40937. }
  40938. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  40939. import { Nullable } from "babylonjs/types";
  40940. import { Scene } from "babylonjs/scene";
  40941. import { Vector4, Color4 } from "babylonjs/Maths/math";
  40942. import { Mesh } from "babylonjs/Meshes/mesh";
  40943. /**
  40944. * Class containing static functions to help procedurally build meshes
  40945. */
  40946. export class BoxBuilder {
  40947. /**
  40948. * Creates a box mesh
  40949. * * The parameter `size` sets the size (float) of each box side (default 1)
  40950. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40951. * * 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)
  40952. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40954. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40956. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40957. * @param name defines the name of the mesh
  40958. * @param options defines the options used to create the mesh
  40959. * @param scene defines the hosting scene
  40960. * @returns the box mesh
  40961. */
  40962. static CreateBox(name: string, options: {
  40963. size?: number;
  40964. width?: number;
  40965. height?: number;
  40966. depth?: number;
  40967. faceUV?: Vector4[];
  40968. faceColors?: Color4[];
  40969. sideOrientation?: number;
  40970. frontUVs?: Vector4;
  40971. backUVs?: Vector4;
  40972. updatable?: boolean;
  40973. }, scene?: Nullable<Scene>): Mesh;
  40974. }
  40975. }
  40976. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  40977. import { Vector4 } from "babylonjs/Maths/math";
  40978. import { Mesh } from "babylonjs/Meshes/mesh";
  40979. /**
  40980. * Class containing static functions to help procedurally build meshes
  40981. */
  40982. export class SphereBuilder {
  40983. /**
  40984. * Creates a sphere mesh
  40985. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40986. * * 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`)
  40987. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40988. * * 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
  40989. * * 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)
  40990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40991. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40993. * @param name defines the name of the mesh
  40994. * @param options defines the options used to create the mesh
  40995. * @param scene defines the hosting scene
  40996. * @returns the sphere mesh
  40997. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40998. */
  40999. static CreateSphere(name: string, options: {
  41000. segments?: number;
  41001. diameter?: number;
  41002. diameterX?: number;
  41003. diameterY?: number;
  41004. diameterZ?: number;
  41005. arc?: number;
  41006. slice?: number;
  41007. sideOrientation?: number;
  41008. frontUVs?: Vector4;
  41009. backUVs?: Vector4;
  41010. updatable?: boolean;
  41011. }, scene: any): Mesh;
  41012. }
  41013. }
  41014. declare module "babylonjs/Debug/physicsViewer" {
  41015. import { Nullable } from "babylonjs/types";
  41016. import { Scene } from "babylonjs/scene";
  41017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41018. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  41019. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  41020. /**
  41021. * Used to show the physics impostor around the specific mesh
  41022. */
  41023. export class PhysicsViewer {
  41024. /** @hidden */
  41025. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  41026. /** @hidden */
  41027. protected _meshes: Array<Nullable<AbstractMesh>>;
  41028. /** @hidden */
  41029. protected _scene: Nullable<Scene>;
  41030. /** @hidden */
  41031. protected _numMeshes: number;
  41032. /** @hidden */
  41033. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  41034. private _renderFunction;
  41035. private _utilityLayer;
  41036. private _debugBoxMesh;
  41037. private _debugSphereMesh;
  41038. private _debugMaterial;
  41039. /**
  41040. * Creates a new PhysicsViewer
  41041. * @param scene defines the hosting scene
  41042. */
  41043. constructor(scene: Scene);
  41044. /** @hidden */
  41045. protected _updateDebugMeshes(): void;
  41046. /**
  41047. * Renders a specified physic impostor
  41048. * @param impostor defines the impostor to render
  41049. * @returns the new debug mesh used to render the impostor
  41050. */
  41051. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  41052. /**
  41053. * Hides a specified physic impostor
  41054. * @param impostor defines the impostor to hide
  41055. */
  41056. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  41057. private _getDebugMaterial;
  41058. private _getDebugBoxMesh;
  41059. private _getDebugSphereMesh;
  41060. private _getDebugMesh;
  41061. /** Releases all resources */
  41062. dispose(): void;
  41063. }
  41064. }
  41065. declare module "babylonjs/Debug/rayHelper" {
  41066. import { Nullable } from "babylonjs/types";
  41067. import { Ray } from "babylonjs/Culling/ray";
  41068. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41069. import { Scene } from "babylonjs/scene";
  41070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41071. import "babylonjs/Meshes/Builders/linesBuilder";
  41072. /**
  41073. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41074. * in order to better appreciate the issue one might have.
  41075. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41076. */
  41077. export class RayHelper {
  41078. /**
  41079. * Defines the ray we are currently tryin to visualize.
  41080. */
  41081. ray: Nullable<Ray>;
  41082. private _renderPoints;
  41083. private _renderLine;
  41084. private _renderFunction;
  41085. private _scene;
  41086. private _updateToMeshFunction;
  41087. private _attachedToMesh;
  41088. private _meshSpaceDirection;
  41089. private _meshSpaceOrigin;
  41090. /**
  41091. * Helper function to create a colored helper in a scene in one line.
  41092. * @param ray Defines the ray we are currently tryin to visualize
  41093. * @param scene Defines the scene the ray is used in
  41094. * @param color Defines the color we want to see the ray in
  41095. * @returns The newly created ray helper.
  41096. */
  41097. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  41098. /**
  41099. * Instantiate a new ray helper.
  41100. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  41101. * in order to better appreciate the issue one might have.
  41102. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  41103. * @param ray Defines the ray we are currently tryin to visualize
  41104. */
  41105. constructor(ray: Ray);
  41106. /**
  41107. * Shows the ray we are willing to debug.
  41108. * @param scene Defines the scene the ray needs to be rendered in
  41109. * @param color Defines the color the ray needs to be rendered in
  41110. */
  41111. show(scene: Scene, color?: Color3): void;
  41112. /**
  41113. * Hides the ray we are debugging.
  41114. */
  41115. hide(): void;
  41116. private _render;
  41117. /**
  41118. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  41119. * @param mesh Defines the mesh we want the helper attached to
  41120. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  41121. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  41122. * @param length Defines the length of the ray
  41123. */
  41124. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  41125. /**
  41126. * Detach the ray helper from the mesh it has previously been attached to.
  41127. */
  41128. detachFromMesh(): void;
  41129. private _updateToMesh;
  41130. /**
  41131. * Dispose the helper and release its associated resources.
  41132. */
  41133. dispose(): void;
  41134. }
  41135. }
  41136. declare module "babylonjs/Debug/skeletonViewer" {
  41137. import { Color3 } from "babylonjs/Maths/math";
  41138. import { Scene } from "babylonjs/scene";
  41139. import { Nullable } from "babylonjs/types";
  41140. import { Skeleton } from "babylonjs/Bones/skeleton";
  41141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41142. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  41143. /**
  41144. * Class used to render a debug view of a given skeleton
  41145. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  41146. */
  41147. export class SkeletonViewer {
  41148. /** defines the skeleton to render */
  41149. skeleton: Skeleton;
  41150. /** defines the mesh attached to the skeleton */
  41151. mesh: AbstractMesh;
  41152. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41153. autoUpdateBonesMatrices: boolean;
  41154. /** defines the rendering group id to use with the viewer */
  41155. renderingGroupId: number;
  41156. /** Gets or sets the color used to render the skeleton */
  41157. color: Color3;
  41158. private _scene;
  41159. private _debugLines;
  41160. private _debugMesh;
  41161. private _isEnabled;
  41162. private _renderFunction;
  41163. private _utilityLayer;
  41164. /**
  41165. * Returns the mesh used to render the bones
  41166. */
  41167. readonly debugMesh: Nullable<LinesMesh>;
  41168. /**
  41169. * Creates a new SkeletonViewer
  41170. * @param skeleton defines the skeleton to render
  41171. * @param mesh defines the mesh attached to the skeleton
  41172. * @param scene defines the hosting scene
  41173. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  41174. * @param renderingGroupId defines the rendering group id to use with the viewer
  41175. */
  41176. constructor(
  41177. /** defines the skeleton to render */
  41178. skeleton: Skeleton,
  41179. /** defines the mesh attached to the skeleton */
  41180. mesh: AbstractMesh, scene: Scene,
  41181. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  41182. autoUpdateBonesMatrices?: boolean,
  41183. /** defines the rendering group id to use with the viewer */
  41184. renderingGroupId?: number);
  41185. /** Gets or sets a boolean indicating if the viewer is enabled */
  41186. isEnabled: boolean;
  41187. private _getBonePosition;
  41188. private _getLinesForBonesWithLength;
  41189. private _getLinesForBonesNoLength;
  41190. /** Update the viewer to sync with current skeleton state */
  41191. update(): void;
  41192. /** Release associated resources */
  41193. dispose(): void;
  41194. }
  41195. }
  41196. declare module "babylonjs/Debug/index" {
  41197. export * from "babylonjs/Debug/axesViewer";
  41198. export * from "babylonjs/Debug/boneAxesViewer";
  41199. export * from "babylonjs/Debug/debugLayer";
  41200. export * from "babylonjs/Debug/physicsViewer";
  41201. export * from "babylonjs/Debug/rayHelper";
  41202. export * from "babylonjs/Debug/skeletonViewer";
  41203. }
  41204. declare module "babylonjs/Engines/nullEngine" {
  41205. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  41206. import { Scene } from "babylonjs/scene";
  41207. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  41208. import { Engine } from "babylonjs/Engines/engine";
  41209. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  41210. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  41211. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  41212. import { Effect } from "babylonjs/Materials/effect";
  41213. /**
  41214. * Options to create the null engine
  41215. */
  41216. export class NullEngineOptions {
  41217. /**
  41218. * Render width (Default: 512)
  41219. */
  41220. renderWidth: number;
  41221. /**
  41222. * Render height (Default: 256)
  41223. */
  41224. renderHeight: number;
  41225. /**
  41226. * Texture size (Default: 512)
  41227. */
  41228. textureSize: number;
  41229. /**
  41230. * If delta time between frames should be constant
  41231. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41232. */
  41233. deterministicLockstep: boolean;
  41234. /**
  41235. * Maximum about of steps between frames (Default: 4)
  41236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41237. */
  41238. lockstepMaxSteps: number;
  41239. }
  41240. /**
  41241. * The null engine class provides support for headless version of babylon.js.
  41242. * This can be used in server side scenario or for testing purposes
  41243. */
  41244. export class NullEngine extends Engine {
  41245. private _options;
  41246. /**
  41247. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41248. */
  41249. isDeterministicLockStep(): boolean;
  41250. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  41251. getLockstepMaxSteps(): number;
  41252. /**
  41253. * Sets hardware scaling, used to save performance if needed
  41254. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  41255. */
  41256. getHardwareScalingLevel(): number;
  41257. constructor(options?: NullEngineOptions);
  41258. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41259. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  41260. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  41261. getRenderWidth(useScreen?: boolean): number;
  41262. getRenderHeight(useScreen?: boolean): number;
  41263. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  41264. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  41265. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  41266. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  41267. bindSamplers(effect: Effect): void;
  41268. enableEffect(effect: Effect): void;
  41269. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  41270. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  41271. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  41272. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  41273. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  41274. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  41275. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  41276. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  41277. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  41278. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  41279. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  41280. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  41281. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  41282. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  41283. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  41284. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41285. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  41286. setFloat(uniform: WebGLUniformLocation, value: number): void;
  41287. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  41288. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  41289. setBool(uniform: WebGLUniformLocation, bool: number): void;
  41290. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  41291. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  41292. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  41293. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  41294. bindBuffers(vertexBuffers: {
  41295. [key: string]: VertexBuffer;
  41296. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  41297. wipeCaches(bruteForce?: boolean): void;
  41298. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  41299. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  41300. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  41301. /** @hidden */
  41302. _createTexture(): WebGLTexture;
  41303. /** @hidden */
  41304. _releaseTexture(texture: InternalTexture): void;
  41305. 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;
  41306. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  41307. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  41308. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  41309. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  41310. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  41311. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  41312. areAllEffectsReady(): boolean;
  41313. /**
  41314. * @hidden
  41315. * Get the current error code of the webGL context
  41316. * @returns the error code
  41317. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41318. */
  41319. getError(): number;
  41320. /** @hidden */
  41321. _getUnpackAlignement(): number;
  41322. /** @hidden */
  41323. _unpackFlipY(value: boolean): void;
  41324. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  41325. /**
  41326. * Updates a dynamic vertex buffer.
  41327. * @param vertexBuffer the vertex buffer to update
  41328. * @param data the data used to update the vertex buffer
  41329. * @param byteOffset the byte offset of the data (optional)
  41330. * @param byteLength the byte length of the data (optional)
  41331. */
  41332. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  41333. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  41334. /** @hidden */
  41335. _bindTexture(channel: number, texture: InternalTexture): void;
  41336. /** @hidden */
  41337. _releaseBuffer(buffer: WebGLBuffer): boolean;
  41338. releaseEffects(): void;
  41339. displayLoadingUI(): void;
  41340. hideLoadingUI(): void;
  41341. /** @hidden */
  41342. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41343. /** @hidden */
  41344. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41345. /** @hidden */
  41346. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41347. /** @hidden */
  41348. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  41349. }
  41350. }
  41351. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  41352. import { Nullable, int } from "babylonjs/types";
  41353. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  41354. /** @hidden */
  41355. export class _OcclusionDataStorage {
  41356. /** @hidden */
  41357. occlusionInternalRetryCounter: number;
  41358. /** @hidden */
  41359. isOcclusionQueryInProgress: boolean;
  41360. /** @hidden */
  41361. isOccluded: boolean;
  41362. /** @hidden */
  41363. occlusionRetryCount: number;
  41364. /** @hidden */
  41365. occlusionType: number;
  41366. /** @hidden */
  41367. occlusionQueryAlgorithmType: number;
  41368. }
  41369. module "babylonjs/Engines/engine" {
  41370. interface Engine {
  41371. /**
  41372. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  41373. * @return the new query
  41374. */
  41375. createQuery(): WebGLQuery;
  41376. /**
  41377. * Delete and release a webGL query
  41378. * @param query defines the query to delete
  41379. * @return the current engine
  41380. */
  41381. deleteQuery(query: WebGLQuery): Engine;
  41382. /**
  41383. * Check if a given query has resolved and got its value
  41384. * @param query defines the query to check
  41385. * @returns true if the query got its value
  41386. */
  41387. isQueryResultAvailable(query: WebGLQuery): boolean;
  41388. /**
  41389. * Gets the value of a given query
  41390. * @param query defines the query to check
  41391. * @returns the value of the query
  41392. */
  41393. getQueryResult(query: WebGLQuery): number;
  41394. /**
  41395. * Initiates an occlusion query
  41396. * @param algorithmType defines the algorithm to use
  41397. * @param query defines the query to use
  41398. * @returns the current engine
  41399. * @see http://doc.babylonjs.com/features/occlusionquery
  41400. */
  41401. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  41402. /**
  41403. * Ends an occlusion query
  41404. * @see http://doc.babylonjs.com/features/occlusionquery
  41405. * @param algorithmType defines the algorithm to use
  41406. * @returns the current engine
  41407. */
  41408. endOcclusionQuery(algorithmType: number): Engine;
  41409. /**
  41410. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  41411. * Please note that only one query can be issued at a time
  41412. * @returns a time token used to track the time span
  41413. */
  41414. startTimeQuery(): Nullable<_TimeToken>;
  41415. /**
  41416. * Ends a time query
  41417. * @param token defines the token used to measure the time span
  41418. * @returns the time spent (in ns)
  41419. */
  41420. endTimeQuery(token: _TimeToken): int;
  41421. /** @hidden */
  41422. _currentNonTimestampToken: Nullable<_TimeToken>;
  41423. /** @hidden */
  41424. _createTimeQuery(): WebGLQuery;
  41425. /** @hidden */
  41426. _deleteTimeQuery(query: WebGLQuery): void;
  41427. /** @hidden */
  41428. _getGlAlgorithmType(algorithmType: number): number;
  41429. /** @hidden */
  41430. _getTimeQueryResult(query: WebGLQuery): any;
  41431. /** @hidden */
  41432. _getTimeQueryAvailability(query: WebGLQuery): any;
  41433. }
  41434. }
  41435. module "babylonjs/Meshes/abstractMesh" {
  41436. interface AbstractMesh {
  41437. /**
  41438. * Backing filed
  41439. * @hidden
  41440. */
  41441. __occlusionDataStorage: _OcclusionDataStorage;
  41442. /**
  41443. * Access property
  41444. * @hidden
  41445. */
  41446. _occlusionDataStorage: _OcclusionDataStorage;
  41447. /**
  41448. * 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.
  41449. * The default value is -1 which means don't break the query and wait till the result
  41450. * @see http://doc.babylonjs.com/features/occlusionquery
  41451. */
  41452. occlusionRetryCount: number;
  41453. /**
  41454. * 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:
  41455. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  41456. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  41457. * * 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.
  41458. * @see http://doc.babylonjs.com/features/occlusionquery
  41459. */
  41460. occlusionType: number;
  41461. /**
  41462. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  41463. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  41464. * * 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.
  41465. * @see http://doc.babylonjs.com/features/occlusionquery
  41466. */
  41467. occlusionQueryAlgorithmType: number;
  41468. /**
  41469. * 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
  41470. * @see http://doc.babylonjs.com/features/occlusionquery
  41471. */
  41472. isOccluded: boolean;
  41473. /**
  41474. * Flag to check the progress status of the query
  41475. * @see http://doc.babylonjs.com/features/occlusionquery
  41476. */
  41477. isOcclusionQueryInProgress: boolean;
  41478. }
  41479. }
  41480. }
  41481. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  41482. import { Nullable } from "babylonjs/types";
  41483. /** @hidden */
  41484. export var _forceTransformFeedbackToBundle: boolean;
  41485. module "babylonjs/Engines/engine" {
  41486. interface Engine {
  41487. /**
  41488. * Creates a webGL transform feedback object
  41489. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  41490. * @returns the webGL transform feedback object
  41491. */
  41492. createTransformFeedback(): WebGLTransformFeedback;
  41493. /**
  41494. * Delete a webGL transform feedback object
  41495. * @param value defines the webGL transform feedback object to delete
  41496. */
  41497. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  41498. /**
  41499. * Bind a webGL transform feedback object to the webgl context
  41500. * @param value defines the webGL transform feedback object to bind
  41501. */
  41502. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  41503. /**
  41504. * Begins a transform feedback operation
  41505. * @param usePoints defines if points or triangles must be used
  41506. */
  41507. beginTransformFeedback(usePoints: boolean): void;
  41508. /**
  41509. * Ends a transform feedback operation
  41510. */
  41511. endTransformFeedback(): void;
  41512. /**
  41513. * Specify the varyings to use with transform feedback
  41514. * @param program defines the associated webGL program
  41515. * @param value defines the list of strings representing the varying names
  41516. */
  41517. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  41518. /**
  41519. * Bind a webGL buffer for a transform feedback operation
  41520. * @param value defines the webGL buffer to bind
  41521. */
  41522. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  41523. }
  41524. }
  41525. }
  41526. declare module "babylonjs/Engines/Extensions/index" {
  41527. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  41528. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  41529. }
  41530. declare module "babylonjs/Engines/index" {
  41531. export * from "babylonjs/Engines/constants";
  41532. export * from "babylonjs/Engines/engine";
  41533. export * from "babylonjs/Engines/engineStore";
  41534. export * from "babylonjs/Engines/nullEngine";
  41535. export * from "babylonjs/Engines/Extensions/index";
  41536. }
  41537. declare module "babylonjs/Events/clipboardEvents" {
  41538. /**
  41539. * Gather the list of clipboard event types as constants.
  41540. */
  41541. export class ClipboardEventTypes {
  41542. /**
  41543. * The clipboard event is fired when a copy command is active (pressed).
  41544. */
  41545. static readonly COPY: number;
  41546. /**
  41547. * The clipboard event is fired when a cut command is active (pressed).
  41548. */
  41549. static readonly CUT: number;
  41550. /**
  41551. * The clipboard event is fired when a paste command is active (pressed).
  41552. */
  41553. static readonly PASTE: number;
  41554. }
  41555. /**
  41556. * This class is used to store clipboard related info for the onClipboardObservable event.
  41557. */
  41558. export class ClipboardInfo {
  41559. /**
  41560. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41561. */
  41562. type: number;
  41563. /**
  41564. * Defines the related dom event
  41565. */
  41566. event: ClipboardEvent;
  41567. /**
  41568. *Creates an instance of ClipboardInfo.
  41569. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41570. * @param event Defines the related dom event
  41571. */
  41572. constructor(
  41573. /**
  41574. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41575. */
  41576. type: number,
  41577. /**
  41578. * Defines the related dom event
  41579. */
  41580. event: ClipboardEvent);
  41581. /**
  41582. * Get the clipboard event's type from the keycode.
  41583. * @param keyCode Defines the keyCode for the current keyboard event.
  41584. * @return {number}
  41585. */
  41586. static GetTypeFromCharacter(keyCode: number): number;
  41587. }
  41588. }
  41589. declare module "babylonjs/Events/index" {
  41590. export * from "babylonjs/Events/keyboardEvents";
  41591. export * from "babylonjs/Events/pointerEvents";
  41592. export * from "babylonjs/Events/clipboardEvents";
  41593. }
  41594. declare module "babylonjs/Loading/sceneLoader" {
  41595. import { Observable } from "babylonjs/Misc/observable";
  41596. import { Nullable } from "babylonjs/types";
  41597. import { Scene } from "babylonjs/scene";
  41598. import { Engine } from "babylonjs/Engines/engine";
  41599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41600. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41601. import { AssetContainer } from "babylonjs/assetContainer";
  41602. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41603. import { Skeleton } from "babylonjs/Bones/skeleton";
  41604. /**
  41605. * Class used to represent data loading progression
  41606. */
  41607. export class SceneLoaderProgressEvent {
  41608. /** defines if data length to load can be evaluated */
  41609. readonly lengthComputable: boolean;
  41610. /** defines the loaded data length */
  41611. readonly loaded: number;
  41612. /** defines the data length to load */
  41613. readonly total: number;
  41614. /**
  41615. * Create a new progress event
  41616. * @param lengthComputable defines if data length to load can be evaluated
  41617. * @param loaded defines the loaded data length
  41618. * @param total defines the data length to load
  41619. */
  41620. constructor(
  41621. /** defines if data length to load can be evaluated */
  41622. lengthComputable: boolean,
  41623. /** defines the loaded data length */
  41624. loaded: number,
  41625. /** defines the data length to load */
  41626. total: number);
  41627. /**
  41628. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41629. * @param event defines the source event
  41630. * @returns a new SceneLoaderProgressEvent
  41631. */
  41632. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41633. }
  41634. /**
  41635. * Interface used by SceneLoader plugins to define supported file extensions
  41636. */
  41637. export interface ISceneLoaderPluginExtensions {
  41638. /**
  41639. * Defines the list of supported extensions
  41640. */
  41641. [extension: string]: {
  41642. isBinary: boolean;
  41643. };
  41644. }
  41645. /**
  41646. * Interface used by SceneLoader plugin factory
  41647. */
  41648. export interface ISceneLoaderPluginFactory {
  41649. /**
  41650. * Defines the name of the factory
  41651. */
  41652. name: string;
  41653. /**
  41654. * Function called to create a new plugin
  41655. * @return the new plugin
  41656. */
  41657. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41658. /**
  41659. * Boolean indicating if the plugin can direct load specific data
  41660. */
  41661. canDirectLoad?: (data: string) => boolean;
  41662. }
  41663. /**
  41664. * Interface used to define a SceneLoader plugin
  41665. */
  41666. export interface ISceneLoaderPlugin {
  41667. /**
  41668. * The friendly name of this plugin.
  41669. */
  41670. name: string;
  41671. /**
  41672. * The file extensions supported by this plugin.
  41673. */
  41674. extensions: string | ISceneLoaderPluginExtensions;
  41675. /**
  41676. * Import meshes into a scene.
  41677. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41678. * @param scene The scene to import into
  41679. * @param data The data to import
  41680. * @param rootUrl The root url for scene and resources
  41681. * @param meshes The meshes array to import into
  41682. * @param particleSystems The particle systems array to import into
  41683. * @param skeletons The skeletons array to import into
  41684. * @param onError The callback when import fails
  41685. * @returns True if successful or false otherwise
  41686. */
  41687. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41688. /**
  41689. * Load into a scene.
  41690. * @param scene The scene to load into
  41691. * @param data The data to import
  41692. * @param rootUrl The root url for scene and resources
  41693. * @param onError The callback when import fails
  41694. * @returns true if successful or false otherwise
  41695. */
  41696. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41697. /**
  41698. * The callback that returns true if the data can be directly loaded.
  41699. */
  41700. canDirectLoad?: (data: string) => boolean;
  41701. /**
  41702. * The callback that allows custom handling of the root url based on the response url.
  41703. */
  41704. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41705. /**
  41706. * Load into an asset container.
  41707. * @param scene The scene to load into
  41708. * @param data The data to import
  41709. * @param rootUrl The root url for scene and resources
  41710. * @param onError The callback when import fails
  41711. * @returns The loaded asset container
  41712. */
  41713. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41714. }
  41715. /**
  41716. * Interface used to define an async SceneLoader plugin
  41717. */
  41718. export interface ISceneLoaderPluginAsync {
  41719. /**
  41720. * The friendly name of this plugin.
  41721. */
  41722. name: string;
  41723. /**
  41724. * The file extensions supported by this plugin.
  41725. */
  41726. extensions: string | ISceneLoaderPluginExtensions;
  41727. /**
  41728. * Import meshes into a scene.
  41729. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41730. * @param scene The scene to import into
  41731. * @param data The data to import
  41732. * @param rootUrl The root url for scene and resources
  41733. * @param onProgress The callback when the load progresses
  41734. * @param fileName Defines the name of the file to load
  41735. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41736. */
  41737. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41738. meshes: AbstractMesh[];
  41739. particleSystems: IParticleSystem[];
  41740. skeletons: Skeleton[];
  41741. animationGroups: AnimationGroup[];
  41742. }>;
  41743. /**
  41744. * Load into a scene.
  41745. * @param scene The scene to load into
  41746. * @param data The data to import
  41747. * @param rootUrl The root url for scene and resources
  41748. * @param onProgress The callback when the load progresses
  41749. * @param fileName Defines the name of the file to load
  41750. * @returns Nothing
  41751. */
  41752. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41753. /**
  41754. * The callback that returns true if the data can be directly loaded.
  41755. */
  41756. canDirectLoad?: (data: string) => boolean;
  41757. /**
  41758. * The callback that allows custom handling of the root url based on the response url.
  41759. */
  41760. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41761. /**
  41762. * Load into an asset container.
  41763. * @param scene The scene to load into
  41764. * @param data The data to import
  41765. * @param rootUrl The root url for scene and resources
  41766. * @param onProgress The callback when the load progresses
  41767. * @param fileName Defines the name of the file to load
  41768. * @returns The loaded asset container
  41769. */
  41770. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41771. }
  41772. /**
  41773. * Class used to load scene from various file formats using registered plugins
  41774. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41775. */
  41776. export class SceneLoader {
  41777. /**
  41778. * No logging while loading
  41779. */
  41780. static readonly NO_LOGGING: number;
  41781. /**
  41782. * Minimal logging while loading
  41783. */
  41784. static readonly MINIMAL_LOGGING: number;
  41785. /**
  41786. * Summary logging while loading
  41787. */
  41788. static readonly SUMMARY_LOGGING: number;
  41789. /**
  41790. * Detailled logging while loading
  41791. */
  41792. static readonly DETAILED_LOGGING: number;
  41793. /**
  41794. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41795. */
  41796. static ForceFullSceneLoadingForIncremental: boolean;
  41797. /**
  41798. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41799. */
  41800. static ShowLoadingScreen: boolean;
  41801. /**
  41802. * Defines the current logging level (while loading the scene)
  41803. * @ignorenaming
  41804. */
  41805. static loggingLevel: number;
  41806. /**
  41807. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41808. */
  41809. static CleanBoneMatrixWeights: boolean;
  41810. /**
  41811. * Event raised when a plugin is used to load a scene
  41812. */
  41813. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41814. private static _registeredPlugins;
  41815. private static _getDefaultPlugin;
  41816. private static _getPluginForExtension;
  41817. private static _getPluginForDirectLoad;
  41818. private static _getPluginForFilename;
  41819. private static _getDirectLoad;
  41820. private static _loadData;
  41821. private static _getFileInfo;
  41822. /**
  41823. * Gets a plugin that can load the given extension
  41824. * @param extension defines the extension to load
  41825. * @returns a plugin or null if none works
  41826. */
  41827. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41828. /**
  41829. * Gets a boolean indicating that the given extension can be loaded
  41830. * @param extension defines the extension to load
  41831. * @returns true if the extension is supported
  41832. */
  41833. static IsPluginForExtensionAvailable(extension: string): boolean;
  41834. /**
  41835. * Adds a new plugin to the list of registered plugins
  41836. * @param plugin defines the plugin to add
  41837. */
  41838. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41839. /**
  41840. * Import meshes into a scene
  41841. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41842. * @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)
  41843. * @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)
  41844. * @param scene the instance of BABYLON.Scene to append to
  41845. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41846. * @param onProgress a callback with a progress event for each file being loaded
  41847. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41848. * @param pluginExtension the extension used to determine the plugin
  41849. * @returns The loaded plugin
  41850. */
  41851. 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>;
  41852. /**
  41853. * Import meshes into a scene
  41854. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41855. * @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)
  41856. * @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)
  41857. * @param scene the instance of BABYLON.Scene to append to
  41858. * @param onProgress a callback with a progress event for each file being loaded
  41859. * @param pluginExtension the extension used to determine the plugin
  41860. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41861. */
  41862. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41863. meshes: AbstractMesh[];
  41864. particleSystems: IParticleSystem[];
  41865. skeletons: Skeleton[];
  41866. animationGroups: AnimationGroup[];
  41867. }>;
  41868. /**
  41869. * Load a scene
  41870. * @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)
  41871. * @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)
  41872. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41873. * @param onSuccess a callback with the scene when import succeeds
  41874. * @param onProgress a callback with a progress event for each file being loaded
  41875. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41876. * @param pluginExtension the extension used to determine the plugin
  41877. * @returns The loaded plugin
  41878. */
  41879. 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>;
  41880. /**
  41881. * Load a scene
  41882. * @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)
  41883. * @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)
  41884. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41885. * @param onProgress a callback with a progress event for each file being loaded
  41886. * @param pluginExtension the extension used to determine the plugin
  41887. * @returns The loaded scene
  41888. */
  41889. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41890. /**
  41891. * Append a scene
  41892. * @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)
  41893. * @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)
  41894. * @param scene is the instance of BABYLON.Scene to append to
  41895. * @param onSuccess a callback with the scene when import succeeds
  41896. * @param onProgress a callback with a progress event for each file being loaded
  41897. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41898. * @param pluginExtension the extension used to determine the plugin
  41899. * @returns The loaded plugin
  41900. */
  41901. 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>;
  41902. /**
  41903. * Append a scene
  41904. * @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)
  41905. * @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)
  41906. * @param scene is the instance of BABYLON.Scene to append to
  41907. * @param onProgress a callback with a progress event for each file being loaded
  41908. * @param pluginExtension the extension used to determine the plugin
  41909. * @returns The given scene
  41910. */
  41911. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41912. /**
  41913. * Load a scene into an asset container
  41914. * @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)
  41915. * @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)
  41916. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41917. * @param onSuccess a callback with the scene when import succeeds
  41918. * @param onProgress a callback with a progress event for each file being loaded
  41919. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41920. * @param pluginExtension the extension used to determine the plugin
  41921. * @returns The loaded plugin
  41922. */
  41923. 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>;
  41924. /**
  41925. * Load a scene into an asset container
  41926. * @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)
  41927. * @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)
  41928. * @param scene is the instance of Scene to append to
  41929. * @param onProgress a callback with a progress event for each file being loaded
  41930. * @param pluginExtension the extension used to determine the plugin
  41931. * @returns The loaded asset container
  41932. */
  41933. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41934. }
  41935. }
  41936. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  41937. import { Scene } from "babylonjs/scene";
  41938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41939. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  41940. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41941. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  41942. /**
  41943. * Google Daydream controller
  41944. */
  41945. export class DaydreamController extends WebVRController {
  41946. /**
  41947. * Base Url for the controller model.
  41948. */
  41949. static MODEL_BASE_URL: string;
  41950. /**
  41951. * File name for the controller model.
  41952. */
  41953. static MODEL_FILENAME: string;
  41954. /**
  41955. * Gamepad Id prefix used to identify Daydream Controller.
  41956. */
  41957. static readonly GAMEPAD_ID_PREFIX: string;
  41958. /**
  41959. * Creates a new DaydreamController from a gamepad
  41960. * @param vrGamepad the gamepad that the controller should be created from
  41961. */
  41962. constructor(vrGamepad: any);
  41963. /**
  41964. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41965. * @param scene scene in which to add meshes
  41966. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41967. */
  41968. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41969. /**
  41970. * Called once for each button that changed state since the last frame
  41971. * @param buttonIdx Which button index changed
  41972. * @param state New state of the button
  41973. * @param changes Which properties on the state changed since last frame
  41974. */
  41975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41976. }
  41977. }
  41978. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  41979. import { Scene } from "babylonjs/scene";
  41980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41981. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  41982. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41983. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  41984. /**
  41985. * Gear VR Controller
  41986. */
  41987. export class GearVRController extends WebVRController {
  41988. /**
  41989. * Base Url for the controller model.
  41990. */
  41991. static MODEL_BASE_URL: string;
  41992. /**
  41993. * File name for the controller model.
  41994. */
  41995. static MODEL_FILENAME: string;
  41996. /**
  41997. * Gamepad Id prefix used to identify this controller.
  41998. */
  41999. static readonly GAMEPAD_ID_PREFIX: string;
  42000. private readonly _buttonIndexToObservableNameMap;
  42001. /**
  42002. * Creates a new GearVRController from a gamepad
  42003. * @param vrGamepad the gamepad that the controller should be created from
  42004. */
  42005. constructor(vrGamepad: any);
  42006. /**
  42007. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42008. * @param scene scene in which to add meshes
  42009. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42010. */
  42011. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42012. /**
  42013. * Called once for each button that changed state since the last frame
  42014. * @param buttonIdx Which button index changed
  42015. * @param state New state of the button
  42016. * @param changes Which properties on the state changed since last frame
  42017. */
  42018. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42019. }
  42020. }
  42021. declare module "babylonjs/Gamepads/Controllers/genericController" {
  42022. import { Scene } from "babylonjs/scene";
  42023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42024. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42025. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42026. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42027. /**
  42028. * Generic Controller
  42029. */
  42030. export class GenericController extends WebVRController {
  42031. /**
  42032. * Base Url for the controller model.
  42033. */
  42034. static readonly MODEL_BASE_URL: string;
  42035. /**
  42036. * File name for the controller model.
  42037. */
  42038. static readonly MODEL_FILENAME: string;
  42039. /**
  42040. * Creates a new GenericController from a gamepad
  42041. * @param vrGamepad the gamepad that the controller should be created from
  42042. */
  42043. constructor(vrGamepad: any);
  42044. /**
  42045. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42046. * @param scene scene in which to add meshes
  42047. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42048. */
  42049. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42050. /**
  42051. * Called once for each button that changed state since the last frame
  42052. * @param buttonIdx Which button index changed
  42053. * @param state New state of the button
  42054. * @param changes Which properties on the state changed since last frame
  42055. */
  42056. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42057. }
  42058. }
  42059. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  42060. import { Observable } from "babylonjs/Misc/observable";
  42061. import { Scene } from "babylonjs/scene";
  42062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42063. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42064. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42065. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42066. /**
  42067. * Oculus Touch Controller
  42068. */
  42069. export class OculusTouchController extends WebVRController {
  42070. /**
  42071. * Base Url for the controller model.
  42072. */
  42073. static MODEL_BASE_URL: string;
  42074. /**
  42075. * File name for the left controller model.
  42076. */
  42077. static MODEL_LEFT_FILENAME: string;
  42078. /**
  42079. * File name for the right controller model.
  42080. */
  42081. static MODEL_RIGHT_FILENAME: string;
  42082. /**
  42083. * Fired when the secondary trigger on this controller is modified
  42084. */
  42085. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  42086. /**
  42087. * Fired when the thumb rest on this controller is modified
  42088. */
  42089. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  42090. /**
  42091. * Creates a new OculusTouchController from a gamepad
  42092. * @param vrGamepad the gamepad that the controller should be created from
  42093. */
  42094. constructor(vrGamepad: any);
  42095. /**
  42096. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42097. * @param scene scene in which to add meshes
  42098. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42099. */
  42100. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42101. /**
  42102. * Fired when the A button on this controller is modified
  42103. */
  42104. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42105. /**
  42106. * Fired when the B button on this controller is modified
  42107. */
  42108. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42109. /**
  42110. * Fired when the X button on this controller is modified
  42111. */
  42112. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42113. /**
  42114. * Fired when the Y button on this controller is modified
  42115. */
  42116. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42117. /**
  42118. * Called once for each button that changed state since the last frame
  42119. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  42120. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  42121. * 2) secondary trigger (same)
  42122. * 3) A (right) X (left), touch, pressed = value
  42123. * 4) B / Y
  42124. * 5) thumb rest
  42125. * @param buttonIdx Which button index changed
  42126. * @param state New state of the button
  42127. * @param changes Which properties on the state changed since last frame
  42128. */
  42129. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42130. }
  42131. }
  42132. declare module "babylonjs/Gamepads/Controllers/viveController" {
  42133. import { Scene } from "babylonjs/scene";
  42134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42135. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42136. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42137. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42138. import { Observable } from "babylonjs/Misc/observable";
  42139. /**
  42140. * Vive Controller
  42141. */
  42142. export class ViveController extends WebVRController {
  42143. /**
  42144. * Base Url for the controller model.
  42145. */
  42146. static MODEL_BASE_URL: string;
  42147. /**
  42148. * File name for the controller model.
  42149. */
  42150. static MODEL_FILENAME: string;
  42151. /**
  42152. * Creates a new ViveController from a gamepad
  42153. * @param vrGamepad the gamepad that the controller should be created from
  42154. */
  42155. constructor(vrGamepad: any);
  42156. /**
  42157. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42158. * @param scene scene in which to add meshes
  42159. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42160. */
  42161. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  42162. /**
  42163. * Fired when the left button on this controller is modified
  42164. */
  42165. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42166. /**
  42167. * Fired when the right button on this controller is modified
  42168. */
  42169. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42170. /**
  42171. * Fired when the menu button on this controller is modified
  42172. */
  42173. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42174. /**
  42175. * Called once for each button that changed state since the last frame
  42176. * Vive mapping:
  42177. * 0: touchpad
  42178. * 1: trigger
  42179. * 2: left AND right buttons
  42180. * 3: menu button
  42181. * @param buttonIdx Which button index changed
  42182. * @param state New state of the button
  42183. * @param changes Which properties on the state changed since last frame
  42184. */
  42185. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42186. }
  42187. }
  42188. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  42189. import { Observable } from "babylonjs/Misc/observable";
  42190. import { Scene } from "babylonjs/scene";
  42191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42192. import { Ray } from "babylonjs/Culling/ray";
  42193. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42194. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42195. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  42196. /**
  42197. * Defines the WindowsMotionController object that the state of the windows motion controller
  42198. */
  42199. export class WindowsMotionController extends WebVRController {
  42200. /**
  42201. * The base url used to load the left and right controller models
  42202. */
  42203. static MODEL_BASE_URL: string;
  42204. /**
  42205. * The name of the left controller model file
  42206. */
  42207. static MODEL_LEFT_FILENAME: string;
  42208. /**
  42209. * The name of the right controller model file
  42210. */
  42211. static MODEL_RIGHT_FILENAME: string;
  42212. /**
  42213. * The controller name prefix for this controller type
  42214. */
  42215. static readonly GAMEPAD_ID_PREFIX: string;
  42216. /**
  42217. * The controller id pattern for this controller type
  42218. */
  42219. private static readonly GAMEPAD_ID_PATTERN;
  42220. private _loadedMeshInfo;
  42221. private readonly _mapping;
  42222. /**
  42223. * Fired when the trackpad on this controller is clicked
  42224. */
  42225. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  42226. /**
  42227. * Fired when the trackpad on this controller is modified
  42228. */
  42229. onTrackpadValuesChangedObservable: Observable<StickValues>;
  42230. /**
  42231. * The current x and y values of this controller's trackpad
  42232. */
  42233. trackpad: StickValues;
  42234. /**
  42235. * Creates a new WindowsMotionController from a gamepad
  42236. * @param vrGamepad the gamepad that the controller should be created from
  42237. */
  42238. constructor(vrGamepad: any);
  42239. /**
  42240. * Fired when the trigger on this controller is modified
  42241. */
  42242. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42243. /**
  42244. * Fired when the menu button on this controller is modified
  42245. */
  42246. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42247. /**
  42248. * Fired when the grip button on this controller is modified
  42249. */
  42250. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42251. /**
  42252. * Fired when the thumbstick button on this controller is modified
  42253. */
  42254. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42255. /**
  42256. * Fired when the touchpad button on this controller is modified
  42257. */
  42258. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  42259. /**
  42260. * Fired when the touchpad values on this controller are modified
  42261. */
  42262. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  42263. private _updateTrackpad;
  42264. /**
  42265. * Called once per frame by the engine.
  42266. */
  42267. update(): void;
  42268. /**
  42269. * Called once for each button that changed state since the last frame
  42270. * @param buttonIdx Which button index changed
  42271. * @param state New state of the button
  42272. * @param changes Which properties on the state changed since last frame
  42273. */
  42274. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  42275. /**
  42276. * Moves the buttons on the controller mesh based on their current state
  42277. * @param buttonName the name of the button to move
  42278. * @param buttonValue the value of the button which determines the buttons new position
  42279. */
  42280. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  42281. /**
  42282. * Moves the axis on the controller mesh based on its current state
  42283. * @param axis the index of the axis
  42284. * @param axisValue the value of the axis which determines the meshes new position
  42285. * @hidden
  42286. */
  42287. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  42288. /**
  42289. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  42290. * @param scene scene in which to add meshes
  42291. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  42292. */
  42293. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  42294. /**
  42295. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  42296. * can be transformed by button presses and axes values, based on this._mapping.
  42297. *
  42298. * @param scene scene in which the meshes exist
  42299. * @param meshes list of meshes that make up the controller model to process
  42300. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  42301. */
  42302. private processModel;
  42303. private createMeshInfo;
  42304. /**
  42305. * Gets the ray of the controller in the direction the controller is pointing
  42306. * @param length the length the resulting ray should be
  42307. * @returns a ray in the direction the controller is pointing
  42308. */
  42309. getForwardRay(length?: number): Ray;
  42310. /**
  42311. * Disposes of the controller
  42312. */
  42313. dispose(): void;
  42314. }
  42315. }
  42316. declare module "babylonjs/Gamepads/Controllers/index" {
  42317. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  42318. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  42319. export * from "babylonjs/Gamepads/Controllers/genericController";
  42320. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  42321. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  42322. export * from "babylonjs/Gamepads/Controllers/viveController";
  42323. export * from "babylonjs/Gamepads/Controllers/webVRController";
  42324. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  42325. }
  42326. declare module "babylonjs/Gamepads/gamepadManager" {
  42327. import { Observable } from "babylonjs/Misc/observable";
  42328. import { Nullable } from "babylonjs/types";
  42329. import { Scene } from "babylonjs/scene";
  42330. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42331. /**
  42332. * Manager for handling gamepads
  42333. */
  42334. export class GamepadManager {
  42335. private _scene?;
  42336. private _babylonGamepads;
  42337. private _oneGamepadConnected;
  42338. /** @hidden */
  42339. _isMonitoring: boolean;
  42340. private _gamepadEventSupported;
  42341. private _gamepadSupport;
  42342. /**
  42343. * observable to be triggered when the gamepad controller has been connected
  42344. */
  42345. onGamepadConnectedObservable: Observable<Gamepad>;
  42346. /**
  42347. * observable to be triggered when the gamepad controller has been disconnected
  42348. */
  42349. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42350. private _onGamepadConnectedEvent;
  42351. private _onGamepadDisconnectedEvent;
  42352. /**
  42353. * Initializes the gamepad manager
  42354. * @param _scene BabylonJS scene
  42355. */
  42356. constructor(_scene?: Scene | undefined);
  42357. /**
  42358. * The gamepads in the game pad manager
  42359. */
  42360. readonly gamepads: Gamepad[];
  42361. /**
  42362. * Get the gamepad controllers based on type
  42363. * @param type The type of gamepad controller
  42364. * @returns Nullable gamepad
  42365. */
  42366. getGamepadByType(type?: number): Nullable<Gamepad>;
  42367. /**
  42368. * Disposes the gamepad manager
  42369. */
  42370. dispose(): void;
  42371. private _addNewGamepad;
  42372. private _startMonitoringGamepads;
  42373. private _stopMonitoringGamepads;
  42374. /** @hidden */
  42375. _checkGamepadsStatus(): void;
  42376. private _updateGamepadObjects;
  42377. }
  42378. }
  42379. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42380. import { Nullable } from "babylonjs/types";
  42381. import { Scene } from "babylonjs/scene";
  42382. import { ISceneComponent } from "babylonjs/sceneComponent";
  42383. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42384. module "babylonjs/scene" {
  42385. interface Scene {
  42386. /** @hidden */
  42387. _gamepadManager: Nullable<GamepadManager>;
  42388. /**
  42389. * Gets the gamepad manager associated with the scene
  42390. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42391. */
  42392. gamepadManager: GamepadManager;
  42393. }
  42394. }
  42395. module "babylonjs/Cameras/freeCameraInputsManager" {
  42396. /**
  42397. * Interface representing a free camera inputs manager
  42398. */
  42399. interface FreeCameraInputsManager {
  42400. /**
  42401. * Adds gamepad input support to the FreeCameraInputsManager.
  42402. * @returns the FreeCameraInputsManager
  42403. */
  42404. addGamepad(): FreeCameraInputsManager;
  42405. }
  42406. }
  42407. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42408. /**
  42409. * Interface representing an arc rotate camera inputs manager
  42410. */
  42411. interface ArcRotateCameraInputsManager {
  42412. /**
  42413. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42414. * @returns the camera inputs manager
  42415. */
  42416. addGamepad(): ArcRotateCameraInputsManager;
  42417. }
  42418. }
  42419. /**
  42420. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42421. */
  42422. export class GamepadSystemSceneComponent implements ISceneComponent {
  42423. /**
  42424. * The component name helpfull to identify the component in the list of scene components.
  42425. */
  42426. readonly name: string;
  42427. /**
  42428. * The scene the component belongs to.
  42429. */
  42430. scene: Scene;
  42431. /**
  42432. * Creates a new instance of the component for the given scene
  42433. * @param scene Defines the scene to register the component in
  42434. */
  42435. constructor(scene: Scene);
  42436. /**
  42437. * Registers the component in a given scene
  42438. */
  42439. register(): void;
  42440. /**
  42441. * Rebuilds the elements related to this component in case of
  42442. * context lost for instance.
  42443. */
  42444. rebuild(): void;
  42445. /**
  42446. * Disposes the component and the associated ressources
  42447. */
  42448. dispose(): void;
  42449. private _beforeCameraUpdate;
  42450. }
  42451. }
  42452. declare module "babylonjs/Gamepads/index" {
  42453. export * from "babylonjs/Gamepads/Controllers/index";
  42454. export * from "babylonjs/Gamepads/gamepad";
  42455. export * from "babylonjs/Gamepads/gamepadManager";
  42456. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  42457. export * from "babylonjs/Gamepads/xboxGamepad";
  42458. }
  42459. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  42460. import { Observable } from "babylonjs/Misc/observable";
  42461. import { Nullable } from "babylonjs/types";
  42462. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42463. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42464. import { Mesh } from "babylonjs/Meshes/mesh";
  42465. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42466. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42467. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42468. /**
  42469. * Single axis scale gizmo
  42470. */
  42471. export class AxisScaleGizmo extends Gizmo {
  42472. private _coloredMaterial;
  42473. /**
  42474. * Drag behavior responsible for the gizmos dragging interactions
  42475. */
  42476. dragBehavior: PointerDragBehavior;
  42477. private _pointerObserver;
  42478. /**
  42479. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42480. */
  42481. snapDistance: number;
  42482. /**
  42483. * Event that fires each time the gizmo snaps to a new location.
  42484. * * snapDistance is the the change in distance
  42485. */
  42486. onSnapObservable: Observable<{
  42487. snapDistance: number;
  42488. }>;
  42489. /**
  42490. * If the scaling operation should be done on all axis (default: false)
  42491. */
  42492. uniformScaling: boolean;
  42493. /**
  42494. * Creates an AxisScaleGizmo
  42495. * @param gizmoLayer The utility layer the gizmo will be added to
  42496. * @param dragAxis The axis which the gizmo will be able to scale on
  42497. * @param color The color of the gizmo
  42498. */
  42499. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42500. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42501. /**
  42502. * Disposes of the gizmo
  42503. */
  42504. dispose(): void;
  42505. /**
  42506. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42507. * @param mesh The mesh to replace the default mesh of the gizmo
  42508. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  42509. */
  42510. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  42511. }
  42512. }
  42513. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  42514. import { Observable } from "babylonjs/Misc/observable";
  42515. import { Nullable } from "babylonjs/types";
  42516. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42518. import { Mesh } from "babylonjs/Meshes/mesh";
  42519. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42520. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42521. import "babylonjs/Meshes/Builders/boxBuilder";
  42522. /**
  42523. * Bounding box gizmo
  42524. */
  42525. export class BoundingBoxGizmo extends Gizmo {
  42526. private _lineBoundingBox;
  42527. private _rotateSpheresParent;
  42528. private _scaleBoxesParent;
  42529. private _boundingDimensions;
  42530. private _renderObserver;
  42531. private _pointerObserver;
  42532. private _scaleDragSpeed;
  42533. private _tmpQuaternion;
  42534. private _tmpVector;
  42535. private _tmpRotationMatrix;
  42536. /**
  42537. * 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)
  42538. */
  42539. ignoreChildren: boolean;
  42540. /**
  42541. * 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)
  42542. */
  42543. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  42544. /**
  42545. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  42546. */
  42547. rotationSphereSize: number;
  42548. /**
  42549. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  42550. */
  42551. scaleBoxSize: number;
  42552. /**
  42553. * 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)
  42554. */
  42555. fixedDragMeshScreenSize: boolean;
  42556. /**
  42557. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  42558. */
  42559. fixedDragMeshScreenSizeDistanceFactor: number;
  42560. /**
  42561. * Fired when a rotation sphere or scale box is dragged
  42562. */
  42563. onDragStartObservable: Observable<{}>;
  42564. /**
  42565. * Fired when a scale box is dragged
  42566. */
  42567. onScaleBoxDragObservable: Observable<{}>;
  42568. /**
  42569. * Fired when a scale box drag is ended
  42570. */
  42571. onScaleBoxDragEndObservable: Observable<{}>;
  42572. /**
  42573. * Fired when a rotation sphere is dragged
  42574. */
  42575. onRotationSphereDragObservable: Observable<{}>;
  42576. /**
  42577. * Fired when a rotation sphere drag is ended
  42578. */
  42579. onRotationSphereDragEndObservable: Observable<{}>;
  42580. /**
  42581. * 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)
  42582. */
  42583. scalePivot: Nullable<Vector3>;
  42584. private _anchorMesh;
  42585. private _existingMeshScale;
  42586. private _dragMesh;
  42587. private pointerDragBehavior;
  42588. /**
  42589. * Creates an BoundingBoxGizmo
  42590. * @param gizmoLayer The utility layer the gizmo will be added to
  42591. * @param color The color of the gizmo
  42592. */
  42593. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42594. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42595. private _selectNode;
  42596. /**
  42597. * Updates the bounding box information for the Gizmo
  42598. */
  42599. updateBoundingBox(): void;
  42600. private _updateRotationSpheres;
  42601. private _updateScaleBoxes;
  42602. /**
  42603. * Enables rotation on the specified axis and disables rotation on the others
  42604. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  42605. */
  42606. setEnabledRotationAxis(axis: string): void;
  42607. /**
  42608. * Enables/disables scaling
  42609. * @param enable if scaling should be enabled
  42610. */
  42611. setEnabledScaling(enable: boolean): void;
  42612. private _updateDummy;
  42613. /**
  42614. * Enables a pointer drag behavior on the bounding box of the gizmo
  42615. */
  42616. enableDragBehavior(): void;
  42617. /**
  42618. * Disposes of the gizmo
  42619. */
  42620. dispose(): void;
  42621. /**
  42622. * 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)
  42623. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  42624. * @returns the bounding box mesh with the passed in mesh as a child
  42625. */
  42626. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  42627. /**
  42628. * CustomMeshes are not supported by this gizmo
  42629. * @param mesh The mesh to replace the default mesh of the gizmo
  42630. */
  42631. setCustomMesh(mesh: Mesh): void;
  42632. }
  42633. }
  42634. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  42635. import { Observable } from "babylonjs/Misc/observable";
  42636. import { Nullable } from "babylonjs/types";
  42637. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42639. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42640. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42641. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42642. import "babylonjs/Meshes/Builders/linesBuilder";
  42643. /**
  42644. * Single plane rotation gizmo
  42645. */
  42646. export class PlaneRotationGizmo extends Gizmo {
  42647. /**
  42648. * Drag behavior responsible for the gizmos dragging interactions
  42649. */
  42650. dragBehavior: PointerDragBehavior;
  42651. private _pointerObserver;
  42652. /**
  42653. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42654. */
  42655. snapDistance: number;
  42656. /**
  42657. * Event that fires each time the gizmo snaps to a new location.
  42658. * * snapDistance is the the change in distance
  42659. */
  42660. onSnapObservable: Observable<{
  42661. snapDistance: number;
  42662. }>;
  42663. /**
  42664. * Creates a PlaneRotationGizmo
  42665. * @param gizmoLayer The utility layer the gizmo will be added to
  42666. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42667. * @param color The color of the gizmo
  42668. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42669. */
  42670. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42671. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42672. /**
  42673. * Disposes of the gizmo
  42674. */
  42675. dispose(): void;
  42676. }
  42677. }
  42678. declare module "babylonjs/Gizmos/rotationGizmo" {
  42679. import { Observable } from "babylonjs/Misc/observable";
  42680. import { Nullable } from "babylonjs/types";
  42681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42682. import { Mesh } from "babylonjs/Meshes/mesh";
  42683. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42684. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  42685. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42686. /**
  42687. * Gizmo that enables rotating a mesh along 3 axis
  42688. */
  42689. export class RotationGizmo extends Gizmo {
  42690. /**
  42691. * Internal gizmo used for interactions on the x axis
  42692. */
  42693. xGizmo: PlaneRotationGizmo;
  42694. /**
  42695. * Internal gizmo used for interactions on the y axis
  42696. */
  42697. yGizmo: PlaneRotationGizmo;
  42698. /**
  42699. * Internal gizmo used for interactions on the z axis
  42700. */
  42701. zGizmo: PlaneRotationGizmo;
  42702. /** Fires an event when any of it's sub gizmos are dragged */
  42703. onDragStartObservable: Observable<{}>;
  42704. /** Fires an event when any of it's sub gizmos are released from dragging */
  42705. onDragEndObservable: Observable<{}>;
  42706. attachedMesh: Nullable<AbstractMesh>;
  42707. /**
  42708. * Creates a RotationGizmo
  42709. * @param gizmoLayer The utility layer the gizmo will be added to
  42710. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42711. */
  42712. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42713. updateGizmoRotationToMatchAttachedMesh: boolean;
  42714. /**
  42715. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42716. */
  42717. snapDistance: number;
  42718. /**
  42719. * Ratio for the scale of the gizmo (Default: 1)
  42720. */
  42721. scaleRatio: number;
  42722. /**
  42723. * Disposes of the gizmo
  42724. */
  42725. dispose(): void;
  42726. /**
  42727. * CustomMeshes are not supported by this gizmo
  42728. * @param mesh The mesh to replace the default mesh of the gizmo
  42729. */
  42730. setCustomMesh(mesh: Mesh): void;
  42731. }
  42732. }
  42733. declare module "babylonjs/Gizmos/positionGizmo" {
  42734. import { Observable } from "babylonjs/Misc/observable";
  42735. import { Nullable } from "babylonjs/types";
  42736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42737. import { Mesh } from "babylonjs/Meshes/mesh";
  42738. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42739. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42740. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42741. /**
  42742. * Gizmo that enables dragging a mesh along 3 axis
  42743. */
  42744. export class PositionGizmo extends Gizmo {
  42745. /**
  42746. * Internal gizmo used for interactions on the x axis
  42747. */
  42748. xGizmo: AxisDragGizmo;
  42749. /**
  42750. * Internal gizmo used for interactions on the y axis
  42751. */
  42752. yGizmo: AxisDragGizmo;
  42753. /**
  42754. * Internal gizmo used for interactions on the z axis
  42755. */
  42756. zGizmo: AxisDragGizmo;
  42757. /** Fires an event when any of it's sub gizmos are dragged */
  42758. onDragStartObservable: Observable<{}>;
  42759. /** Fires an event when any of it's sub gizmos are released from dragging */
  42760. onDragEndObservable: Observable<{}>;
  42761. attachedMesh: Nullable<AbstractMesh>;
  42762. /**
  42763. * Creates a PositionGizmo
  42764. * @param gizmoLayer The utility layer the gizmo will be added to
  42765. */
  42766. constructor(gizmoLayer?: UtilityLayerRenderer);
  42767. updateGizmoRotationToMatchAttachedMesh: boolean;
  42768. /**
  42769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42770. */
  42771. snapDistance: number;
  42772. /**
  42773. * Ratio for the scale of the gizmo (Default: 1)
  42774. */
  42775. scaleRatio: number;
  42776. /**
  42777. * Disposes of the gizmo
  42778. */
  42779. dispose(): void;
  42780. /**
  42781. * CustomMeshes are not supported by this gizmo
  42782. * @param mesh The mesh to replace the default mesh of the gizmo
  42783. */
  42784. setCustomMesh(mesh: Mesh): void;
  42785. }
  42786. }
  42787. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  42788. import { Scene } from "babylonjs/scene";
  42789. import { Color4, Vector4 } from "babylonjs/Maths/math";
  42790. import { Mesh } from "babylonjs/Meshes/mesh";
  42791. /**
  42792. * Class containing static functions to help procedurally build meshes
  42793. */
  42794. export class PolyhedronBuilder {
  42795. /**
  42796. * Creates a polyhedron mesh
  42797. * * 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
  42798. * * The parameter `size` (positive float, default 1) sets the polygon size
  42799. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42800. * * 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`
  42801. * * 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
  42802. * * 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)`)
  42803. * * 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
  42804. * * 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
  42805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42808. * @param name defines the name of the mesh
  42809. * @param options defines the options used to create the mesh
  42810. * @param scene defines the hosting scene
  42811. * @returns the polyhedron mesh
  42812. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42813. */
  42814. static CreatePolyhedron(name: string, options: {
  42815. type?: number;
  42816. size?: number;
  42817. sizeX?: number;
  42818. sizeY?: number;
  42819. sizeZ?: number;
  42820. custom?: any;
  42821. faceUV?: Vector4[];
  42822. faceColors?: Color4[];
  42823. flat?: boolean;
  42824. updatable?: boolean;
  42825. sideOrientation?: number;
  42826. frontUVs?: Vector4;
  42827. backUVs?: Vector4;
  42828. }, scene: Scene): Mesh;
  42829. }
  42830. }
  42831. declare module "babylonjs/Gizmos/scaleGizmo" {
  42832. import { Observable } from "babylonjs/Misc/observable";
  42833. import { Nullable } from "babylonjs/types";
  42834. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42835. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42836. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  42837. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42838. /**
  42839. * Gizmo that enables scaling a mesh along 3 axis
  42840. */
  42841. export class ScaleGizmo extends Gizmo {
  42842. /**
  42843. * Internal gizmo used for interactions on the x axis
  42844. */
  42845. xGizmo: AxisScaleGizmo;
  42846. /**
  42847. * Internal gizmo used for interactions on the y axis
  42848. */
  42849. yGizmo: AxisScaleGizmo;
  42850. /**
  42851. * Internal gizmo used for interactions on the z axis
  42852. */
  42853. zGizmo: AxisScaleGizmo;
  42854. /**
  42855. * Internal gizmo used to scale all axis equally
  42856. */
  42857. uniformScaleGizmo: AxisScaleGizmo;
  42858. /** Fires an event when any of it's sub gizmos are dragged */
  42859. onDragStartObservable: Observable<{}>;
  42860. /** Fires an event when any of it's sub gizmos are released from dragging */
  42861. onDragEndObservable: Observable<{}>;
  42862. attachedMesh: Nullable<AbstractMesh>;
  42863. /**
  42864. * Creates a ScaleGizmo
  42865. * @param gizmoLayer The utility layer the gizmo will be added to
  42866. */
  42867. constructor(gizmoLayer?: UtilityLayerRenderer);
  42868. updateGizmoRotationToMatchAttachedMesh: boolean;
  42869. /**
  42870. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42871. */
  42872. snapDistance: number;
  42873. /**
  42874. * Ratio for the scale of the gizmo (Default: 1)
  42875. */
  42876. scaleRatio: number;
  42877. /**
  42878. * Disposes of the gizmo
  42879. */
  42880. dispose(): void;
  42881. }
  42882. }
  42883. declare module "babylonjs/Gizmos/gizmoManager" {
  42884. import { Observable } from "babylonjs/Misc/observable";
  42885. import { Nullable } from "babylonjs/types";
  42886. import { Scene, IDisposable } from "babylonjs/scene";
  42887. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42888. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  42889. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  42890. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42891. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  42892. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  42893. /**
  42894. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42895. */
  42896. export class GizmoManager implements IDisposable {
  42897. private scene;
  42898. /**
  42899. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42900. */
  42901. gizmos: {
  42902. positionGizmo: Nullable<PositionGizmo>;
  42903. rotationGizmo: Nullable<RotationGizmo>;
  42904. scaleGizmo: Nullable<ScaleGizmo>;
  42905. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42906. };
  42907. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42908. clearGizmoOnEmptyPointerEvent: boolean;
  42909. /** Fires an event when the manager is attached to a mesh */
  42910. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42911. private _gizmosEnabled;
  42912. private _pointerObserver;
  42913. private _attachedMesh;
  42914. private _boundingBoxColor;
  42915. private _defaultUtilityLayer;
  42916. private _defaultKeepDepthUtilityLayer;
  42917. /**
  42918. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42919. */
  42920. boundingBoxDragBehavior: SixDofDragBehavior;
  42921. /**
  42922. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42923. */
  42924. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42925. /**
  42926. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42927. */
  42928. usePointerToAttachGizmos: boolean;
  42929. /**
  42930. * Instatiates a gizmo manager
  42931. * @param scene the scene to overlay the gizmos on top of
  42932. */
  42933. constructor(scene: Scene);
  42934. /**
  42935. * Attaches a set of gizmos to the specified mesh
  42936. * @param mesh The mesh the gizmo's should be attached to
  42937. */
  42938. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42939. /**
  42940. * If the position gizmo is enabled
  42941. */
  42942. positionGizmoEnabled: boolean;
  42943. /**
  42944. * If the rotation gizmo is enabled
  42945. */
  42946. rotationGizmoEnabled: boolean;
  42947. /**
  42948. * If the scale gizmo is enabled
  42949. */
  42950. scaleGizmoEnabled: boolean;
  42951. /**
  42952. * If the boundingBox gizmo is enabled
  42953. */
  42954. boundingBoxGizmoEnabled: boolean;
  42955. /**
  42956. * Disposes of the gizmo manager
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module "babylonjs/Gizmos/index" {
  42962. export * from "babylonjs/Gizmos/axisDragGizmo";
  42963. export * from "babylonjs/Gizmos/axisScaleGizmo";
  42964. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  42965. export * from "babylonjs/Gizmos/gizmo";
  42966. export * from "babylonjs/Gizmos/gizmoManager";
  42967. export * from "babylonjs/Gizmos/planeRotationGizmo";
  42968. export * from "babylonjs/Gizmos/positionGizmo";
  42969. export * from "babylonjs/Gizmos/rotationGizmo";
  42970. export * from "babylonjs/Gizmos/scaleGizmo";
  42971. }
  42972. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  42973. /** @hidden */
  42974. export var backgroundFragmentDeclaration: {
  42975. name: string;
  42976. shader: string;
  42977. };
  42978. }
  42979. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  42980. /** @hidden */
  42981. export var backgroundUboDeclaration: {
  42982. name: string;
  42983. shader: string;
  42984. };
  42985. }
  42986. declare module "babylonjs/Shaders/background.fragment" {
  42987. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  42988. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  42989. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  42990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42991. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  42992. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  42993. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42994. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  42995. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  42996. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42997. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  42998. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  42999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43000. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43001. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43002. /** @hidden */
  43003. export var backgroundPixelShader: {
  43004. name: string;
  43005. shader: string;
  43006. };
  43007. }
  43008. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  43009. /** @hidden */
  43010. export var backgroundVertexDeclaration: {
  43011. name: string;
  43012. shader: string;
  43013. };
  43014. }
  43015. declare module "babylonjs/Shaders/background.vertex" {
  43016. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  43017. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  43018. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43019. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43020. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43021. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43022. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43023. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43024. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43025. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43026. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43027. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43028. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43029. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43030. /** @hidden */
  43031. export var backgroundVertexShader: {
  43032. name: string;
  43033. shader: string;
  43034. };
  43035. }
  43036. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  43037. import { Nullable, int, float } from "babylonjs/types";
  43038. import { Scene } from "babylonjs/scene";
  43039. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  43040. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43042. import { Mesh } from "babylonjs/Meshes/mesh";
  43043. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43044. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43045. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43046. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43047. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  43048. import "babylonjs/Shaders/background.fragment";
  43049. import "babylonjs/Shaders/background.vertex";
  43050. /**
  43051. * Background material used to create an efficient environement around your scene.
  43052. */
  43053. export class BackgroundMaterial extends PushMaterial {
  43054. /**
  43055. * Standard reflectance value at parallel view angle.
  43056. */
  43057. static StandardReflectance0: number;
  43058. /**
  43059. * Standard reflectance value at grazing angle.
  43060. */
  43061. static StandardReflectance90: number;
  43062. protected _primaryColor: Color3;
  43063. /**
  43064. * Key light Color (multiply against the environement texture)
  43065. */
  43066. primaryColor: Color3;
  43067. protected __perceptualColor: Nullable<Color3>;
  43068. /**
  43069. * Experimental Internal Use Only.
  43070. *
  43071. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43072. * This acts as a helper to set the primary color to a more "human friendly" value.
  43073. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43074. * output color as close as possible from the chosen value.
  43075. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43076. * part of lighting setup.)
  43077. */
  43078. _perceptualColor: Nullable<Color3>;
  43079. protected _primaryColorShadowLevel: float;
  43080. /**
  43081. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43082. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43083. */
  43084. primaryColorShadowLevel: float;
  43085. protected _primaryColorHighlightLevel: float;
  43086. /**
  43087. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43088. * The primary color is used at the level chosen to define what the white area would look.
  43089. */
  43090. primaryColorHighlightLevel: float;
  43091. protected _reflectionTexture: Nullable<BaseTexture>;
  43092. /**
  43093. * Reflection Texture used in the material.
  43094. * Should be author in a specific way for the best result (refer to the documentation).
  43095. */
  43096. reflectionTexture: Nullable<BaseTexture>;
  43097. protected _reflectionBlur: float;
  43098. /**
  43099. * Reflection Texture level of blur.
  43100. *
  43101. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43102. * texture twice.
  43103. */
  43104. reflectionBlur: float;
  43105. protected _diffuseTexture: Nullable<BaseTexture>;
  43106. /**
  43107. * Diffuse Texture used in the material.
  43108. * Should be author in a specific way for the best result (refer to the documentation).
  43109. */
  43110. diffuseTexture: Nullable<BaseTexture>;
  43111. protected _shadowLights: Nullable<IShadowLight[]>;
  43112. /**
  43113. * Specify the list of lights casting shadow on the material.
  43114. * All scene shadow lights will be included if null.
  43115. */
  43116. shadowLights: Nullable<IShadowLight[]>;
  43117. protected _shadowLevel: float;
  43118. /**
  43119. * Helps adjusting the shadow to a softer level if required.
  43120. * 0 means black shadows and 1 means no shadows.
  43121. */
  43122. shadowLevel: float;
  43123. protected _sceneCenter: Vector3;
  43124. /**
  43125. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43126. * It is usually zero but might be interesting to modify according to your setup.
  43127. */
  43128. sceneCenter: Vector3;
  43129. protected _opacityFresnel: boolean;
  43130. /**
  43131. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43132. * This helps ensuring a nice transition when the camera goes under the ground.
  43133. */
  43134. opacityFresnel: boolean;
  43135. protected _reflectionFresnel: boolean;
  43136. /**
  43137. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  43138. * This helps adding a mirror texture on the ground.
  43139. */
  43140. reflectionFresnel: boolean;
  43141. protected _reflectionFalloffDistance: number;
  43142. /**
  43143. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  43144. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  43145. */
  43146. reflectionFalloffDistance: number;
  43147. protected _reflectionAmount: number;
  43148. /**
  43149. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  43150. */
  43151. reflectionAmount: number;
  43152. protected _reflectionReflectance0: number;
  43153. /**
  43154. * This specifies the weight of the reflection at grazing angle.
  43155. */
  43156. reflectionReflectance0: number;
  43157. protected _reflectionReflectance90: number;
  43158. /**
  43159. * This specifies the weight of the reflection at a perpendicular point of view.
  43160. */
  43161. reflectionReflectance90: number;
  43162. /**
  43163. * Sets the reflection reflectance fresnel values according to the default standard
  43164. * empirically know to work well :-)
  43165. */
  43166. reflectionStandardFresnelWeight: number;
  43167. protected _useRGBColor: boolean;
  43168. /**
  43169. * Helps to directly use the maps channels instead of their level.
  43170. */
  43171. useRGBColor: boolean;
  43172. protected _enableNoise: boolean;
  43173. /**
  43174. * This helps reducing the banding effect that could occur on the background.
  43175. */
  43176. enableNoise: boolean;
  43177. /**
  43178. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43179. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  43180. * Recommended to be keep at 1.0 except for special cases.
  43181. */
  43182. fovMultiplier: number;
  43183. private _fovMultiplier;
  43184. /**
  43185. * Enable the FOV adjustment feature controlled by fovMultiplier.
  43186. */
  43187. useEquirectangularFOV: boolean;
  43188. private _maxSimultaneousLights;
  43189. /**
  43190. * Number of Simultaneous lights allowed on the material.
  43191. */
  43192. maxSimultaneousLights: int;
  43193. /**
  43194. * Default configuration related to image processing available in the Background Material.
  43195. */
  43196. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43197. /**
  43198. * Keep track of the image processing observer to allow dispose and replace.
  43199. */
  43200. private _imageProcessingObserver;
  43201. /**
  43202. * Attaches a new image processing configuration to the PBR Material.
  43203. * @param configuration (if null the scene configuration will be use)
  43204. */
  43205. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  43206. /**
  43207. * Gets the image processing configuration used either in this material.
  43208. */
  43209. /**
  43210. * Sets the Default image processing configuration used either in the this material.
  43211. *
  43212. * If sets to null, the scene one is in use.
  43213. */
  43214. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  43215. /**
  43216. * Gets wether the color curves effect is enabled.
  43217. */
  43218. /**
  43219. * Sets wether the color curves effect is enabled.
  43220. */
  43221. cameraColorCurvesEnabled: boolean;
  43222. /**
  43223. * Gets wether the color grading effect is enabled.
  43224. */
  43225. /**
  43226. * Gets wether the color grading effect is enabled.
  43227. */
  43228. cameraColorGradingEnabled: boolean;
  43229. /**
  43230. * Gets wether tonemapping is enabled or not.
  43231. */
  43232. /**
  43233. * Sets wether tonemapping is enabled or not
  43234. */
  43235. cameraToneMappingEnabled: boolean;
  43236. /**
  43237. * The camera exposure used on this material.
  43238. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43239. * This corresponds to a photographic exposure.
  43240. */
  43241. /**
  43242. * The camera exposure used on this material.
  43243. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  43244. * This corresponds to a photographic exposure.
  43245. */
  43246. cameraExposure: float;
  43247. /**
  43248. * Gets The camera contrast used on this material.
  43249. */
  43250. /**
  43251. * Sets The camera contrast used on this material.
  43252. */
  43253. cameraContrast: float;
  43254. /**
  43255. * Gets the Color Grading 2D Lookup Texture.
  43256. */
  43257. /**
  43258. * Sets the Color Grading 2D Lookup Texture.
  43259. */
  43260. cameraColorGradingTexture: Nullable<BaseTexture>;
  43261. /**
  43262. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43263. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43264. * 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;
  43265. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43266. */
  43267. /**
  43268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  43269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  43270. * 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;
  43271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  43272. */
  43273. cameraColorCurves: Nullable<ColorCurves>;
  43274. /**
  43275. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  43276. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  43277. */
  43278. switchToBGR: boolean;
  43279. private _renderTargets;
  43280. private _reflectionControls;
  43281. private _white;
  43282. private _primaryShadowColor;
  43283. private _primaryHighlightColor;
  43284. /**
  43285. * Instantiates a Background Material in the given scene
  43286. * @param name The friendly name of the material
  43287. * @param scene The scene to add the material to
  43288. */
  43289. constructor(name: string, scene: Scene);
  43290. /**
  43291. * Gets a boolean indicating that current material needs to register RTT
  43292. */
  43293. readonly hasRenderTargetTextures: boolean;
  43294. /**
  43295. * The entire material has been created in order to prevent overdraw.
  43296. * @returns false
  43297. */
  43298. needAlphaTesting(): boolean;
  43299. /**
  43300. * The entire material has been created in order to prevent overdraw.
  43301. * @returns true if blending is enable
  43302. */
  43303. needAlphaBlending(): boolean;
  43304. /**
  43305. * Checks wether the material is ready to be rendered for a given mesh.
  43306. * @param mesh The mesh to render
  43307. * @param subMesh The submesh to check against
  43308. * @param useInstances Specify wether or not the material is used with instances
  43309. * @returns true if all the dependencies are ready (Textures, Effects...)
  43310. */
  43311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  43312. /**
  43313. * Compute the primary color according to the chosen perceptual color.
  43314. */
  43315. private _computePrimaryColorFromPerceptualColor;
  43316. /**
  43317. * Compute the highlights and shadow colors according to their chosen levels.
  43318. */
  43319. private _computePrimaryColors;
  43320. /**
  43321. * Build the uniform buffer used in the material.
  43322. */
  43323. buildUniformLayout(): void;
  43324. /**
  43325. * Unbind the material.
  43326. */
  43327. unbind(): void;
  43328. /**
  43329. * Bind only the world matrix to the material.
  43330. * @param world The world matrix to bind.
  43331. */
  43332. bindOnlyWorldMatrix(world: Matrix): void;
  43333. /**
  43334. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  43335. * @param world The world matrix to bind.
  43336. * @param subMesh The submesh to bind for.
  43337. */
  43338. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  43339. /**
  43340. * Dispose the material.
  43341. * @param forceDisposeEffect Force disposal of the associated effect.
  43342. * @param forceDisposeTextures Force disposal of the associated textures.
  43343. */
  43344. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  43345. /**
  43346. * Clones the material.
  43347. * @param name The cloned name.
  43348. * @returns The cloned material.
  43349. */
  43350. clone(name: string): BackgroundMaterial;
  43351. /**
  43352. * Serializes the current material to its JSON representation.
  43353. * @returns The JSON representation.
  43354. */
  43355. serialize(): any;
  43356. /**
  43357. * Gets the class name of the material
  43358. * @returns "BackgroundMaterial"
  43359. */
  43360. getClassName(): string;
  43361. /**
  43362. * Parse a JSON input to create back a background material.
  43363. * @param source The JSON data to parse
  43364. * @param scene The scene to create the parsed material in
  43365. * @param rootUrl The root url of the assets the material depends upon
  43366. * @returns the instantiated BackgroundMaterial.
  43367. */
  43368. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  43369. }
  43370. }
  43371. declare module "babylonjs/Helpers/environmentHelper" {
  43372. import { Observable } from "babylonjs/Misc/observable";
  43373. import { Nullable } from "babylonjs/types";
  43374. import { Scene } from "babylonjs/scene";
  43375. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43377. import { Mesh } from "babylonjs/Meshes/mesh";
  43378. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43379. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  43380. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43381. import "babylonjs/Meshes/Builders/planeBuilder";
  43382. import "babylonjs/Meshes/Builders/boxBuilder";
  43383. /**
  43384. * Represents the different options available during the creation of
  43385. * a Environment helper.
  43386. *
  43387. * This can control the default ground, skybox and image processing setup of your scene.
  43388. */
  43389. export interface IEnvironmentHelperOptions {
  43390. /**
  43391. * Specifies wether or not to create a ground.
  43392. * True by default.
  43393. */
  43394. createGround: boolean;
  43395. /**
  43396. * Specifies the ground size.
  43397. * 15 by default.
  43398. */
  43399. groundSize: number;
  43400. /**
  43401. * The texture used on the ground for the main color.
  43402. * Comes from the BabylonJS CDN by default.
  43403. *
  43404. * Remarks: Can be either a texture or a url.
  43405. */
  43406. groundTexture: string | BaseTexture;
  43407. /**
  43408. * The color mixed in the ground texture by default.
  43409. * BabylonJS clearColor by default.
  43410. */
  43411. groundColor: Color3;
  43412. /**
  43413. * Specifies the ground opacity.
  43414. * 1 by default.
  43415. */
  43416. groundOpacity: number;
  43417. /**
  43418. * Enables the ground to receive shadows.
  43419. * True by default.
  43420. */
  43421. enableGroundShadow: boolean;
  43422. /**
  43423. * Helps preventing the shadow to be fully black on the ground.
  43424. * 0.5 by default.
  43425. */
  43426. groundShadowLevel: number;
  43427. /**
  43428. * Creates a mirror texture attach to the ground.
  43429. * false by default.
  43430. */
  43431. enableGroundMirror: boolean;
  43432. /**
  43433. * Specifies the ground mirror size ratio.
  43434. * 0.3 by default as the default kernel is 64.
  43435. */
  43436. groundMirrorSizeRatio: number;
  43437. /**
  43438. * Specifies the ground mirror blur kernel size.
  43439. * 64 by default.
  43440. */
  43441. groundMirrorBlurKernel: number;
  43442. /**
  43443. * Specifies the ground mirror visibility amount.
  43444. * 1 by default
  43445. */
  43446. groundMirrorAmount: number;
  43447. /**
  43448. * Specifies the ground mirror reflectance weight.
  43449. * This uses the standard weight of the background material to setup the fresnel effect
  43450. * of the mirror.
  43451. * 1 by default.
  43452. */
  43453. groundMirrorFresnelWeight: number;
  43454. /**
  43455. * Specifies the ground mirror Falloff distance.
  43456. * This can helps reducing the size of the reflection.
  43457. * 0 by Default.
  43458. */
  43459. groundMirrorFallOffDistance: number;
  43460. /**
  43461. * Specifies the ground mirror texture type.
  43462. * Unsigned Int by Default.
  43463. */
  43464. groundMirrorTextureType: number;
  43465. /**
  43466. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43467. * the shown objects.
  43468. */
  43469. groundYBias: number;
  43470. /**
  43471. * Specifies wether or not to create a skybox.
  43472. * True by default.
  43473. */
  43474. createSkybox: boolean;
  43475. /**
  43476. * Specifies the skybox size.
  43477. * 20 by default.
  43478. */
  43479. skyboxSize: number;
  43480. /**
  43481. * The texture used on the skybox for the main color.
  43482. * Comes from the BabylonJS CDN by default.
  43483. *
  43484. * Remarks: Can be either a texture or a url.
  43485. */
  43486. skyboxTexture: string | BaseTexture;
  43487. /**
  43488. * The color mixed in the skybox texture by default.
  43489. * BabylonJS clearColor by default.
  43490. */
  43491. skyboxColor: Color3;
  43492. /**
  43493. * The background rotation around the Y axis of the scene.
  43494. * This helps aligning the key lights of your scene with the background.
  43495. * 0 by default.
  43496. */
  43497. backgroundYRotation: number;
  43498. /**
  43499. * Compute automatically the size of the elements to best fit with the scene.
  43500. */
  43501. sizeAuto: boolean;
  43502. /**
  43503. * Default position of the rootMesh if autoSize is not true.
  43504. */
  43505. rootPosition: Vector3;
  43506. /**
  43507. * Sets up the image processing in the scene.
  43508. * true by default.
  43509. */
  43510. setupImageProcessing: boolean;
  43511. /**
  43512. * The texture used as your environment texture in the scene.
  43513. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43514. *
  43515. * Remarks: Can be either a texture or a url.
  43516. */
  43517. environmentTexture: string | BaseTexture;
  43518. /**
  43519. * The value of the exposure to apply to the scene.
  43520. * 0.6 by default if setupImageProcessing is true.
  43521. */
  43522. cameraExposure: number;
  43523. /**
  43524. * The value of the contrast to apply to the scene.
  43525. * 1.6 by default if setupImageProcessing is true.
  43526. */
  43527. cameraContrast: number;
  43528. /**
  43529. * Specifies wether or not tonemapping should be enabled in the scene.
  43530. * true by default if setupImageProcessing is true.
  43531. */
  43532. toneMappingEnabled: boolean;
  43533. }
  43534. /**
  43535. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43536. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43537. * It also helps with the default setup of your imageProcessing configuration.
  43538. */
  43539. export class EnvironmentHelper {
  43540. /**
  43541. * Default ground texture URL.
  43542. */
  43543. private static _groundTextureCDNUrl;
  43544. /**
  43545. * Default skybox texture URL.
  43546. */
  43547. private static _skyboxTextureCDNUrl;
  43548. /**
  43549. * Default environment texture URL.
  43550. */
  43551. private static _environmentTextureCDNUrl;
  43552. /**
  43553. * Creates the default options for the helper.
  43554. */
  43555. private static _getDefaultOptions;
  43556. private _rootMesh;
  43557. /**
  43558. * Gets the root mesh created by the helper.
  43559. */
  43560. readonly rootMesh: Mesh;
  43561. private _skybox;
  43562. /**
  43563. * Gets the skybox created by the helper.
  43564. */
  43565. readonly skybox: Nullable<Mesh>;
  43566. private _skyboxTexture;
  43567. /**
  43568. * Gets the skybox texture created by the helper.
  43569. */
  43570. readonly skyboxTexture: Nullable<BaseTexture>;
  43571. private _skyboxMaterial;
  43572. /**
  43573. * Gets the skybox material created by the helper.
  43574. */
  43575. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43576. private _ground;
  43577. /**
  43578. * Gets the ground mesh created by the helper.
  43579. */
  43580. readonly ground: Nullable<Mesh>;
  43581. private _groundTexture;
  43582. /**
  43583. * Gets the ground texture created by the helper.
  43584. */
  43585. readonly groundTexture: Nullable<BaseTexture>;
  43586. private _groundMirror;
  43587. /**
  43588. * Gets the ground mirror created by the helper.
  43589. */
  43590. readonly groundMirror: Nullable<MirrorTexture>;
  43591. /**
  43592. * Gets the ground mirror render list to helps pushing the meshes
  43593. * you wish in the ground reflection.
  43594. */
  43595. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43596. private _groundMaterial;
  43597. /**
  43598. * Gets the ground material created by the helper.
  43599. */
  43600. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43601. /**
  43602. * Stores the creation options.
  43603. */
  43604. private readonly _scene;
  43605. private _options;
  43606. /**
  43607. * This observable will be notified with any error during the creation of the environment,
  43608. * mainly texture creation errors.
  43609. */
  43610. onErrorObservable: Observable<{
  43611. message?: string;
  43612. exception?: any;
  43613. }>;
  43614. /**
  43615. * constructor
  43616. * @param options Defines the options we want to customize the helper
  43617. * @param scene The scene to add the material to
  43618. */
  43619. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43620. /**
  43621. * Updates the background according to the new options
  43622. * @param options
  43623. */
  43624. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43625. /**
  43626. * Sets the primary color of all the available elements.
  43627. * @param color the main color to affect to the ground and the background
  43628. */
  43629. setMainColor(color: Color3): void;
  43630. /**
  43631. * Setup the image processing according to the specified options.
  43632. */
  43633. private _setupImageProcessing;
  43634. /**
  43635. * Setup the environment texture according to the specified options.
  43636. */
  43637. private _setupEnvironmentTexture;
  43638. /**
  43639. * Setup the background according to the specified options.
  43640. */
  43641. private _setupBackground;
  43642. /**
  43643. * Get the scene sizes according to the setup.
  43644. */
  43645. private _getSceneSize;
  43646. /**
  43647. * Setup the ground according to the specified options.
  43648. */
  43649. private _setupGround;
  43650. /**
  43651. * Setup the ground material according to the specified options.
  43652. */
  43653. private _setupGroundMaterial;
  43654. /**
  43655. * Setup the ground diffuse texture according to the specified options.
  43656. */
  43657. private _setupGroundDiffuseTexture;
  43658. /**
  43659. * Setup the ground mirror texture according to the specified options.
  43660. */
  43661. private _setupGroundMirrorTexture;
  43662. /**
  43663. * Setup the ground to receive the mirror texture.
  43664. */
  43665. private _setupMirrorInGroundMaterial;
  43666. /**
  43667. * Setup the skybox according to the specified options.
  43668. */
  43669. private _setupSkybox;
  43670. /**
  43671. * Setup the skybox material according to the specified options.
  43672. */
  43673. private _setupSkyboxMaterial;
  43674. /**
  43675. * Setup the skybox reflection texture according to the specified options.
  43676. */
  43677. private _setupSkyboxReflectionTexture;
  43678. private _errorHandler;
  43679. /**
  43680. * Dispose all the elements created by the Helper.
  43681. */
  43682. dispose(): void;
  43683. }
  43684. }
  43685. declare module "babylonjs/Helpers/photoDome" {
  43686. import { Observable } from "babylonjs/Misc/observable";
  43687. import { Nullable } from "babylonjs/types";
  43688. import { Scene } from "babylonjs/scene";
  43689. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43690. import { Mesh } from "babylonjs/Meshes/mesh";
  43691. import { Texture } from "babylonjs/Materials/Textures/texture";
  43692. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  43693. import "babylonjs/Meshes/Builders/sphereBuilder";
  43694. /**
  43695. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43696. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43697. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43698. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43699. */
  43700. export class PhotoDome extends TransformNode {
  43701. private _useDirectMapping;
  43702. /**
  43703. * The texture being displayed on the sphere
  43704. */
  43705. protected _photoTexture: Texture;
  43706. /**
  43707. * Gets or sets the texture being displayed on the sphere
  43708. */
  43709. photoTexture: Texture;
  43710. /**
  43711. * Observable raised when an error occured while loading the 360 image
  43712. */
  43713. onLoadErrorObservable: Observable<string>;
  43714. /**
  43715. * The skybox material
  43716. */
  43717. protected _material: BackgroundMaterial;
  43718. /**
  43719. * The surface used for the skybox
  43720. */
  43721. protected _mesh: Mesh;
  43722. /**
  43723. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43724. * Also see the options.resolution property.
  43725. */
  43726. fovMultiplier: number;
  43727. /**
  43728. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43729. * @param name Element's name, child elements will append suffixes for their own names.
  43730. * @param urlsOfPhoto defines the url of the photo to display
  43731. * @param options defines an object containing optional or exposed sub element properties
  43732. * @param onError defines a callback called when an error occured while loading the texture
  43733. */
  43734. constructor(name: string, urlOfPhoto: string, options: {
  43735. resolution?: number;
  43736. size?: number;
  43737. useDirectMapping?: boolean;
  43738. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43739. /**
  43740. * Releases resources associated with this node.
  43741. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43742. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43743. */
  43744. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43745. }
  43746. }
  43747. declare module "babylonjs/Misc/textureTools" {
  43748. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43749. import { Texture } from "babylonjs/Materials/Textures/texture";
  43750. import { Scene } from "babylonjs/scene";
  43751. /**
  43752. * Class used to host texture specific utilities
  43753. */
  43754. export class TextureTools {
  43755. /**
  43756. * Uses the GPU to create a copy texture rescaled at a given size
  43757. * @param texture Texture to copy from
  43758. * @param width defines the desired width
  43759. * @param height defines the desired height
  43760. * @param useBilinearMode defines if bilinear mode has to be used
  43761. * @return the generated texture
  43762. */
  43763. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  43764. /**
  43765. * Gets an environment BRDF texture for a given scene
  43766. * @param scene defines the hosting scene
  43767. * @returns the environment BRDF texture
  43768. */
  43769. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43770. private static _environmentBRDFBase64Texture;
  43771. }
  43772. }
  43773. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  43774. /** @hidden */
  43775. export var pbrFragmentDeclaration: {
  43776. name: string;
  43777. shader: string;
  43778. };
  43779. }
  43780. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  43781. /** @hidden */
  43782. export var pbrUboDeclaration: {
  43783. name: string;
  43784. shader: string;
  43785. };
  43786. }
  43787. declare module "babylonjs/Shaders/ShadersInclude/pbrFunctions" {
  43788. /** @hidden */
  43789. export var pbrFunctions: {
  43790. name: string;
  43791. shader: string;
  43792. };
  43793. }
  43794. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  43795. /** @hidden */
  43796. export var harmonicsFunctions: {
  43797. name: string;
  43798. shader: string;
  43799. };
  43800. }
  43801. declare module "babylonjs/Shaders/ShadersInclude/pbrLightFunctions" {
  43802. /** @hidden */
  43803. export var pbrLightFunctions: {
  43804. name: string;
  43805. shader: string;
  43806. };
  43807. }
  43808. declare module "babylonjs/Shaders/pbr.fragment" {
  43809. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  43810. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43811. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43812. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43813. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  43814. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43815. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43816. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43817. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  43818. import "babylonjs/Shaders/ShadersInclude/pbrFunctions";
  43819. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43820. import "babylonjs/Shaders/ShadersInclude/pbrLightFunctions";
  43821. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  43822. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  43823. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43824. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  43825. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  43826. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  43827. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  43828. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  43829. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  43830. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  43831. /** @hidden */
  43832. export var pbrPixelShader: {
  43833. name: string;
  43834. shader: string;
  43835. };
  43836. }
  43837. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  43838. /** @hidden */
  43839. export var pbrVertexDeclaration: {
  43840. name: string;
  43841. shader: string;
  43842. };
  43843. }
  43844. declare module "babylonjs/Shaders/pbr.vertex" {
  43845. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  43846. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  43847. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43848. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  43849. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  43850. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  43851. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  43852. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  43853. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  43854. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  43855. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  43856. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  43857. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  43858. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  43859. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  43860. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  43861. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  43862. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  43863. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  43864. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  43865. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  43866. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  43867. /** @hidden */
  43868. export var pbrVertexShader: {
  43869. name: string;
  43870. shader: string;
  43871. };
  43872. }
  43873. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  43874. import { IAnimatable } from "babylonjs/Misc/tools";
  43875. import { Nullable } from "babylonjs/types";
  43876. import { Scene } from "babylonjs/scene";
  43877. import { Matrix, Color3 } from "babylonjs/Maths/math";
  43878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  43879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43880. import { Mesh } from "babylonjs/Meshes/mesh";
  43881. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43882. import { Material } from "babylonjs/Materials/material";
  43883. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  43884. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43885. import "babylonjs/Shaders/pbr.fragment";
  43886. import "babylonjs/Shaders/pbr.vertex";
  43887. /**
  43888. * The Physically based material base class of BJS.
  43889. *
  43890. * This offers the main features of a standard PBR material.
  43891. * For more information, please refer to the documentation :
  43892. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43893. */
  43894. export abstract class PBRBaseMaterial extends PushMaterial {
  43895. /**
  43896. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43897. */
  43898. static readonly PBRMATERIAL_OPAQUE: number;
  43899. /**
  43900. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43901. */
  43902. static readonly PBRMATERIAL_ALPHATEST: number;
  43903. /**
  43904. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43905. */
  43906. static readonly PBRMATERIAL_ALPHABLEND: number;
  43907. /**
  43908. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43909. * They are also discarded below the alpha cutoff threshold to improve performances.
  43910. */
  43911. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43912. /**
  43913. * Defines the default value of how much AO map is occluding the analytical lights
  43914. * (point spot...).
  43915. */
  43916. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43917. /**
  43918. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43919. */
  43920. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43921. /**
  43922. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43923. * to enhance interoperability with other engines.
  43924. */
  43925. static readonly LIGHTFALLOFF_GLTF: number;
  43926. /**
  43927. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43928. * to enhance interoperability with other materials.
  43929. */
  43930. static readonly LIGHTFALLOFF_STANDARD: number;
  43931. /**
  43932. * Intensity of the direct lights e.g. the four lights available in your scene.
  43933. * This impacts both the direct diffuse and specular highlights.
  43934. */
  43935. protected _directIntensity: number;
  43936. /**
  43937. * Intensity of the emissive part of the material.
  43938. * This helps controlling the emissive effect without modifying the emissive color.
  43939. */
  43940. protected _emissiveIntensity: number;
  43941. /**
  43942. * Intensity of the environment e.g. how much the environment will light the object
  43943. * either through harmonics for rough material or through the refelction for shiny ones.
  43944. */
  43945. protected _environmentIntensity: number;
  43946. /**
  43947. * This is a special control allowing the reduction of the specular highlights coming from the
  43948. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43949. */
  43950. protected _specularIntensity: number;
  43951. /**
  43952. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43953. */
  43954. private _lightingInfos;
  43955. /**
  43956. * Debug Control allowing disabling the bump map on this material.
  43957. */
  43958. protected _disableBumpMap: boolean;
  43959. /**
  43960. * AKA Diffuse Texture in standard nomenclature.
  43961. */
  43962. protected _albedoTexture: BaseTexture;
  43963. /**
  43964. * AKA Occlusion Texture in other nomenclature.
  43965. */
  43966. protected _ambientTexture: BaseTexture;
  43967. /**
  43968. * AKA Occlusion Texture Intensity in other nomenclature.
  43969. */
  43970. protected _ambientTextureStrength: number;
  43971. /**
  43972. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43973. * 1 means it completely occludes it
  43974. * 0 mean it has no impact
  43975. */
  43976. protected _ambientTextureImpactOnAnalyticalLights: number;
  43977. /**
  43978. * Stores the alpha values in a texture.
  43979. */
  43980. protected _opacityTexture: BaseTexture;
  43981. /**
  43982. * Stores the reflection values in a texture.
  43983. */
  43984. protected _reflectionTexture: BaseTexture;
  43985. /**
  43986. * Stores the refraction values in a texture.
  43987. */
  43988. protected _refractionTexture: BaseTexture;
  43989. /**
  43990. * Stores the emissive values in a texture.
  43991. */
  43992. protected _emissiveTexture: BaseTexture;
  43993. /**
  43994. * AKA Specular texture in other nomenclature.
  43995. */
  43996. protected _reflectivityTexture: BaseTexture;
  43997. /**
  43998. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43999. */
  44000. protected _metallicTexture: BaseTexture;
  44001. /**
  44002. * Specifies the metallic scalar of the metallic/roughness workflow.
  44003. * Can also be used to scale the metalness values of the metallic texture.
  44004. */
  44005. protected _metallic: Nullable<number>;
  44006. /**
  44007. * Specifies the roughness scalar of the metallic/roughness workflow.
  44008. * Can also be used to scale the roughness values of the metallic texture.
  44009. */
  44010. protected _roughness: Nullable<number>;
  44011. /**
  44012. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44013. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44014. */
  44015. protected _microSurfaceTexture: BaseTexture;
  44016. /**
  44017. * Stores surface normal data used to displace a mesh in a texture.
  44018. */
  44019. protected _bumpTexture: BaseTexture;
  44020. /**
  44021. * Stores the pre-calculated light information of a mesh in a texture.
  44022. */
  44023. protected _lightmapTexture: BaseTexture;
  44024. /**
  44025. * The color of a material in ambient lighting.
  44026. */
  44027. protected _ambientColor: Color3;
  44028. /**
  44029. * AKA Diffuse Color in other nomenclature.
  44030. */
  44031. protected _albedoColor: Color3;
  44032. /**
  44033. * AKA Specular Color in other nomenclature.
  44034. */
  44035. protected _reflectivityColor: Color3;
  44036. /**
  44037. * The color applied when light is reflected from a material.
  44038. */
  44039. protected _reflectionColor: Color3;
  44040. /**
  44041. * The color applied when light is emitted from a material.
  44042. */
  44043. protected _emissiveColor: Color3;
  44044. /**
  44045. * AKA Glossiness in other nomenclature.
  44046. */
  44047. protected _microSurface: number;
  44048. /**
  44049. * source material index of refraction (IOR)' / 'destination material IOR.
  44050. */
  44051. protected _indexOfRefraction: number;
  44052. /**
  44053. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44054. */
  44055. protected _invertRefractionY: boolean;
  44056. /**
  44057. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44058. * Materials half opaque for instance using refraction could benefit from this control.
  44059. */
  44060. protected _linkRefractionWithTransparency: boolean;
  44061. /**
  44062. * Specifies that the material will use the light map as a show map.
  44063. */
  44064. protected _useLightmapAsShadowmap: boolean;
  44065. /**
  44066. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44067. * makes the reflect vector face the model (under horizon).
  44068. */
  44069. protected _useHorizonOcclusion: boolean;
  44070. /**
  44071. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44072. * too much the area relying on ambient texture to define their ambient occlusion.
  44073. */
  44074. protected _useRadianceOcclusion: boolean;
  44075. /**
  44076. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44077. */
  44078. protected _useAlphaFromAlbedoTexture: boolean;
  44079. /**
  44080. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44081. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44082. */
  44083. protected _useSpecularOverAlpha: boolean;
  44084. /**
  44085. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44086. */
  44087. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44088. /**
  44089. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44090. */
  44091. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44092. /**
  44093. * Specifies if the metallic texture contains the roughness information in its green channel.
  44094. */
  44095. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44096. /**
  44097. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44098. */
  44099. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44100. /**
  44101. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44102. */
  44103. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44104. /**
  44105. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44106. */
  44107. protected _useAmbientInGrayScale: boolean;
  44108. /**
  44109. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44110. * The material will try to infer what glossiness each pixel should be.
  44111. */
  44112. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44113. /**
  44114. * Defines the falloff type used in this material.
  44115. * It by default is Physical.
  44116. */
  44117. protected _lightFalloff: number;
  44118. /**
  44119. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44120. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44121. */
  44122. protected _useRadianceOverAlpha: boolean;
  44123. /**
  44124. * Allows using an object space normal map (instead of tangent space).
  44125. */
  44126. protected _useObjectSpaceNormalMap: boolean;
  44127. /**
  44128. * Allows using the bump map in parallax mode.
  44129. */
  44130. protected _useParallax: boolean;
  44131. /**
  44132. * Allows using the bump map in parallax occlusion mode.
  44133. */
  44134. protected _useParallaxOcclusion: boolean;
  44135. /**
  44136. * Controls the scale bias of the parallax mode.
  44137. */
  44138. protected _parallaxScaleBias: number;
  44139. /**
  44140. * If sets to true, disables all the lights affecting the material.
  44141. */
  44142. protected _disableLighting: boolean;
  44143. /**
  44144. * Number of Simultaneous lights allowed on the material.
  44145. */
  44146. protected _maxSimultaneousLights: number;
  44147. /**
  44148. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44149. */
  44150. protected _invertNormalMapX: boolean;
  44151. /**
  44152. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44153. */
  44154. protected _invertNormalMapY: boolean;
  44155. /**
  44156. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44157. */
  44158. protected _twoSidedLighting: boolean;
  44159. /**
  44160. * Defines the alpha limits in alpha test mode.
  44161. */
  44162. protected _alphaCutOff: number;
  44163. /**
  44164. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44165. */
  44166. protected _forceAlphaTest: boolean;
  44167. /**
  44168. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44169. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44170. */
  44171. protected _useAlphaFresnel: boolean;
  44172. /**
  44173. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44174. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44175. */
  44176. protected _useLinearAlphaFresnel: boolean;
  44177. /**
  44178. * The transparency mode of the material.
  44179. */
  44180. protected _transparencyMode: Nullable<number>;
  44181. /**
  44182. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44183. * from cos thetav and roughness:
  44184. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44185. */
  44186. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44187. /**
  44188. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44189. */
  44190. protected _forceIrradianceInFragment: boolean;
  44191. /**
  44192. * Force normal to face away from face.
  44193. */
  44194. protected _forceNormalForward: boolean;
  44195. /**
  44196. * Enables specular anti aliasing in the PBR shader.
  44197. * It will both interacts on the Geometry for analytical and IBL lighting.
  44198. * It also prefilter the roughness map based on the bump values.
  44199. */
  44200. protected _enableSpecularAntiAliasing: boolean;
  44201. /**
  44202. * Default configuration related to image processing available in the PBR Material.
  44203. */
  44204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44205. /**
  44206. * Keep track of the image processing observer to allow dispose and replace.
  44207. */
  44208. private _imageProcessingObserver;
  44209. /**
  44210. * Attaches a new image processing configuration to the PBR Material.
  44211. * @param configuration
  44212. */
  44213. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44214. /**
  44215. * Stores the available render targets.
  44216. */
  44217. private _renderTargets;
  44218. /**
  44219. * Sets the global ambient color for the material used in lighting calculations.
  44220. */
  44221. private _globalAmbientColor;
  44222. /**
  44223. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44224. */
  44225. private _useLogarithmicDepth;
  44226. /**
  44227. * If set to true, no lighting calculations will be applied.
  44228. */
  44229. private _unlit;
  44230. /**
  44231. * Instantiates a new PBRMaterial instance.
  44232. *
  44233. * @param name The material name
  44234. * @param scene The scene the material will be use in.
  44235. */
  44236. constructor(name: string, scene: Scene);
  44237. /**
  44238. * Gets a boolean indicating that current material needs to register RTT
  44239. */
  44240. readonly hasRenderTargetTextures: boolean;
  44241. /**
  44242. * Gets the name of the material class.
  44243. */
  44244. getClassName(): string;
  44245. /**
  44246. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44247. */
  44248. /**
  44249. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44250. */
  44251. useLogarithmicDepth: boolean;
  44252. /**
  44253. * Gets the current transparency mode.
  44254. */
  44255. /**
  44256. * Sets the transparency mode of the material.
  44257. *
  44258. * | Value | Type | Description |
  44259. * | ----- | ----------------------------------- | ----------- |
  44260. * | 0 | OPAQUE | |
  44261. * | 1 | ALPHATEST | |
  44262. * | 2 | ALPHABLEND | |
  44263. * | 3 | ALPHATESTANDBLEND | |
  44264. *
  44265. */
  44266. transparencyMode: Nullable<number>;
  44267. /**
  44268. * Returns true if alpha blending should be disabled.
  44269. */
  44270. private readonly _disableAlphaBlending;
  44271. /**
  44272. * Specifies whether or not this material should be rendered in alpha blend mode.
  44273. */
  44274. needAlphaBlending(): boolean;
  44275. /**
  44276. * Specifies if the mesh will require alpha blending.
  44277. * @param mesh - BJS mesh.
  44278. */
  44279. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44280. /**
  44281. * Specifies whether or not this material should be rendered in alpha test mode.
  44282. */
  44283. needAlphaTesting(): boolean;
  44284. /**
  44285. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44286. */
  44287. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44288. /**
  44289. * Gets the texture used for the alpha test.
  44290. */
  44291. getAlphaTestTexture(): BaseTexture;
  44292. /**
  44293. * Specifies that the submesh is ready to be used.
  44294. * @param mesh - BJS mesh.
  44295. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44296. * @param useInstances - Specifies that instances should be used.
  44297. * @returns - boolean indicating that the submesh is ready or not.
  44298. */
  44299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44300. /**
  44301. * Specifies if the material uses metallic roughness workflow.
  44302. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44303. */
  44304. isMetallicWorkflow(): boolean;
  44305. private _prepareEffect;
  44306. private _prepareDefines;
  44307. /**
  44308. * Force shader compilation
  44309. */
  44310. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44311. clipPlane: boolean;
  44312. }>): void;
  44313. /**
  44314. * Initializes the uniform buffer layout for the shader.
  44315. */
  44316. buildUniformLayout(): void;
  44317. /**
  44318. * Unbinds the textures.
  44319. */
  44320. unbind(): void;
  44321. /**
  44322. * Binds the submesh data.
  44323. * @param world - The world matrix.
  44324. * @param mesh - The BJS mesh.
  44325. * @param subMesh - A submesh of the BJS mesh.
  44326. */
  44327. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44328. /**
  44329. * Returns the animatable textures.
  44330. * @returns - Array of animatable textures.
  44331. */
  44332. getAnimatables(): IAnimatable[];
  44333. /**
  44334. * Returns the texture used for reflections.
  44335. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44336. */
  44337. private _getReflectionTexture;
  44338. /**
  44339. * Returns the texture used for refraction or null if none is used.
  44340. * @returns - Refection texture if present. If no refraction texture and refraction
  44341. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44342. */
  44343. private _getRefractionTexture;
  44344. /**
  44345. * Disposes the resources of the material.
  44346. * @param forceDisposeEffect - Forces the disposal of effects.
  44347. * @param forceDisposeTextures - Forces the disposal of all textures.
  44348. */
  44349. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44350. }
  44351. }
  44352. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  44353. import { Nullable } from "babylonjs/types";
  44354. import { Scene } from "babylonjs/scene";
  44355. import { Color3 } from "babylonjs/Maths/math";
  44356. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44357. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44358. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44359. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  44360. /**
  44361. * The Physically based material of BJS.
  44362. *
  44363. * This offers the main features of a standard PBR material.
  44364. * For more information, please refer to the documentation :
  44365. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44366. */
  44367. export class PBRMaterial extends PBRBaseMaterial {
  44368. /**
  44369. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44370. */
  44371. static readonly PBRMATERIAL_OPAQUE: number;
  44372. /**
  44373. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44374. */
  44375. static readonly PBRMATERIAL_ALPHATEST: number;
  44376. /**
  44377. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44378. */
  44379. static readonly PBRMATERIAL_ALPHABLEND: number;
  44380. /**
  44381. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44382. * They are also discarded below the alpha cutoff threshold to improve performances.
  44383. */
  44384. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44385. /**
  44386. * Defines the default value of how much AO map is occluding the analytical lights
  44387. * (point spot...).
  44388. */
  44389. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44390. /**
  44391. * Intensity of the direct lights e.g. the four lights available in your scene.
  44392. * This impacts both the direct diffuse and specular highlights.
  44393. */
  44394. directIntensity: number;
  44395. /**
  44396. * Intensity of the emissive part of the material.
  44397. * This helps controlling the emissive effect without modifying the emissive color.
  44398. */
  44399. emissiveIntensity: number;
  44400. /**
  44401. * Intensity of the environment e.g. how much the environment will light the object
  44402. * either through harmonics for rough material or through the refelction for shiny ones.
  44403. */
  44404. environmentIntensity: number;
  44405. /**
  44406. * This is a special control allowing the reduction of the specular highlights coming from the
  44407. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44408. */
  44409. specularIntensity: number;
  44410. /**
  44411. * Debug Control allowing disabling the bump map on this material.
  44412. */
  44413. disableBumpMap: boolean;
  44414. /**
  44415. * AKA Diffuse Texture in standard nomenclature.
  44416. */
  44417. albedoTexture: BaseTexture;
  44418. /**
  44419. * AKA Occlusion Texture in other nomenclature.
  44420. */
  44421. ambientTexture: BaseTexture;
  44422. /**
  44423. * AKA Occlusion Texture Intensity in other nomenclature.
  44424. */
  44425. ambientTextureStrength: number;
  44426. /**
  44427. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44428. * 1 means it completely occludes it
  44429. * 0 mean it has no impact
  44430. */
  44431. ambientTextureImpactOnAnalyticalLights: number;
  44432. /**
  44433. * Stores the alpha values in a texture.
  44434. */
  44435. opacityTexture: BaseTexture;
  44436. /**
  44437. * Stores the reflection values in a texture.
  44438. */
  44439. reflectionTexture: Nullable<BaseTexture>;
  44440. /**
  44441. * Stores the emissive values in a texture.
  44442. */
  44443. emissiveTexture: BaseTexture;
  44444. /**
  44445. * AKA Specular texture in other nomenclature.
  44446. */
  44447. reflectivityTexture: BaseTexture;
  44448. /**
  44449. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44450. */
  44451. metallicTexture: BaseTexture;
  44452. /**
  44453. * Specifies the metallic scalar of the metallic/roughness workflow.
  44454. * Can also be used to scale the metalness values of the metallic texture.
  44455. */
  44456. metallic: Nullable<number>;
  44457. /**
  44458. * Specifies the roughness scalar of the metallic/roughness workflow.
  44459. * Can also be used to scale the roughness values of the metallic texture.
  44460. */
  44461. roughness: Nullable<number>;
  44462. /**
  44463. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44464. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44465. */
  44466. microSurfaceTexture: BaseTexture;
  44467. /**
  44468. * Stores surface normal data used to displace a mesh in a texture.
  44469. */
  44470. bumpTexture: BaseTexture;
  44471. /**
  44472. * Stores the pre-calculated light information of a mesh in a texture.
  44473. */
  44474. lightmapTexture: BaseTexture;
  44475. /**
  44476. * Stores the refracted light information in a texture.
  44477. */
  44478. refractionTexture: BaseTexture;
  44479. /**
  44480. * The color of a material in ambient lighting.
  44481. */
  44482. ambientColor: Color3;
  44483. /**
  44484. * AKA Diffuse Color in other nomenclature.
  44485. */
  44486. albedoColor: Color3;
  44487. /**
  44488. * AKA Specular Color in other nomenclature.
  44489. */
  44490. reflectivityColor: Color3;
  44491. /**
  44492. * The color reflected from the material.
  44493. */
  44494. reflectionColor: Color3;
  44495. /**
  44496. * The color emitted from the material.
  44497. */
  44498. emissiveColor: Color3;
  44499. /**
  44500. * AKA Glossiness in other nomenclature.
  44501. */
  44502. microSurface: number;
  44503. /**
  44504. * source material index of refraction (IOR)' / 'destination material IOR.
  44505. */
  44506. indexOfRefraction: number;
  44507. /**
  44508. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44509. */
  44510. invertRefractionY: boolean;
  44511. /**
  44512. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44513. * Materials half opaque for instance using refraction could benefit from this control.
  44514. */
  44515. linkRefractionWithTransparency: boolean;
  44516. /**
  44517. * If true, the light map contains occlusion information instead of lighting info.
  44518. */
  44519. useLightmapAsShadowmap: boolean;
  44520. /**
  44521. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44522. */
  44523. useAlphaFromAlbedoTexture: boolean;
  44524. /**
  44525. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44526. */
  44527. forceAlphaTest: boolean;
  44528. /**
  44529. * Defines the alpha limits in alpha test mode.
  44530. */
  44531. alphaCutOff: number;
  44532. /**
  44533. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44534. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44535. */
  44536. useSpecularOverAlpha: boolean;
  44537. /**
  44538. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44539. */
  44540. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44541. /**
  44542. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44543. */
  44544. useRoughnessFromMetallicTextureAlpha: boolean;
  44545. /**
  44546. * Specifies if the metallic texture contains the roughness information in its green channel.
  44547. */
  44548. useRoughnessFromMetallicTextureGreen: boolean;
  44549. /**
  44550. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44551. */
  44552. useMetallnessFromMetallicTextureBlue: boolean;
  44553. /**
  44554. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44555. */
  44556. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44557. /**
  44558. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44559. */
  44560. useAmbientInGrayScale: boolean;
  44561. /**
  44562. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44563. * The material will try to infer what glossiness each pixel should be.
  44564. */
  44565. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44566. /**
  44567. * BJS is using an harcoded light falloff based on a manually sets up range.
  44568. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44569. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44570. */
  44571. /**
  44572. * BJS is using an harcoded light falloff based on a manually sets up range.
  44573. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44574. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44575. */
  44576. usePhysicalLightFalloff: boolean;
  44577. /**
  44578. * In order to support the falloff compatibility with gltf, a special mode has been added
  44579. * to reproduce the gltf light falloff.
  44580. */
  44581. /**
  44582. * In order to support the falloff compatibility with gltf, a special mode has been added
  44583. * to reproduce the gltf light falloff.
  44584. */
  44585. useGLTFLightFalloff: boolean;
  44586. /**
  44587. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44588. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44589. */
  44590. useRadianceOverAlpha: boolean;
  44591. /**
  44592. * Allows using an object space normal map (instead of tangent space).
  44593. */
  44594. useObjectSpaceNormalMap: boolean;
  44595. /**
  44596. * Allows using the bump map in parallax mode.
  44597. */
  44598. useParallax: boolean;
  44599. /**
  44600. * Allows using the bump map in parallax occlusion mode.
  44601. */
  44602. useParallaxOcclusion: boolean;
  44603. /**
  44604. * Controls the scale bias of the parallax mode.
  44605. */
  44606. parallaxScaleBias: number;
  44607. /**
  44608. * If sets to true, disables all the lights affecting the material.
  44609. */
  44610. disableLighting: boolean;
  44611. /**
  44612. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44613. */
  44614. forceIrradianceInFragment: boolean;
  44615. /**
  44616. * Number of Simultaneous lights allowed on the material.
  44617. */
  44618. maxSimultaneousLights: number;
  44619. /**
  44620. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44621. */
  44622. invertNormalMapX: boolean;
  44623. /**
  44624. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44625. */
  44626. invertNormalMapY: boolean;
  44627. /**
  44628. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44629. */
  44630. twoSidedLighting: boolean;
  44631. /**
  44632. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44633. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44634. */
  44635. useAlphaFresnel: boolean;
  44636. /**
  44637. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44638. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44639. */
  44640. useLinearAlphaFresnel: boolean;
  44641. /**
  44642. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44643. * And/Or occlude the blended part.
  44644. */
  44645. environmentBRDFTexture: Nullable<BaseTexture>;
  44646. /**
  44647. * Force normal to face away from face.
  44648. */
  44649. forceNormalForward: boolean;
  44650. /**
  44651. * Enables specular anti aliasing in the PBR shader.
  44652. * It will both interacts on the Geometry for analytical and IBL lighting.
  44653. * It also prefilter the roughness map based on the bump values.
  44654. */
  44655. enableSpecularAntiAliasing: boolean;
  44656. /**
  44657. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44658. * makes the reflect vector face the model (under horizon).
  44659. */
  44660. useHorizonOcclusion: boolean;
  44661. /**
  44662. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44663. * too much the area relying on ambient texture to define their ambient occlusion.
  44664. */
  44665. useRadianceOcclusion: boolean;
  44666. /**
  44667. * If set to true, no lighting calculations will be applied.
  44668. */
  44669. unlit: boolean;
  44670. /**
  44671. * Gets the image processing configuration used either in this material.
  44672. */
  44673. /**
  44674. * Sets the Default image processing configuration used either in the this material.
  44675. *
  44676. * If sets to null, the scene one is in use.
  44677. */
  44678. imageProcessingConfiguration: ImageProcessingConfiguration;
  44679. /**
  44680. * Gets wether the color curves effect is enabled.
  44681. */
  44682. /**
  44683. * Sets wether the color curves effect is enabled.
  44684. */
  44685. cameraColorCurvesEnabled: boolean;
  44686. /**
  44687. * Gets wether the color grading effect is enabled.
  44688. */
  44689. /**
  44690. * Gets wether the color grading effect is enabled.
  44691. */
  44692. cameraColorGradingEnabled: boolean;
  44693. /**
  44694. * Gets wether tonemapping is enabled or not.
  44695. */
  44696. /**
  44697. * Sets wether tonemapping is enabled or not
  44698. */
  44699. cameraToneMappingEnabled: boolean;
  44700. /**
  44701. * The camera exposure used on this material.
  44702. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44703. * This corresponds to a photographic exposure.
  44704. */
  44705. /**
  44706. * The camera exposure used on this material.
  44707. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44708. * This corresponds to a photographic exposure.
  44709. */
  44710. cameraExposure: number;
  44711. /**
  44712. * Gets The camera contrast used on this material.
  44713. */
  44714. /**
  44715. * Sets The camera contrast used on this material.
  44716. */
  44717. cameraContrast: number;
  44718. /**
  44719. * Gets the Color Grading 2D Lookup Texture.
  44720. */
  44721. /**
  44722. * Sets the Color Grading 2D Lookup Texture.
  44723. */
  44724. cameraColorGradingTexture: Nullable<BaseTexture>;
  44725. /**
  44726. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44727. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44728. * 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;
  44729. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44730. */
  44731. /**
  44732. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44733. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44734. * 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;
  44735. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44736. */
  44737. cameraColorCurves: Nullable<ColorCurves>;
  44738. /**
  44739. * Instantiates a new PBRMaterial instance.
  44740. *
  44741. * @param name The material name
  44742. * @param scene The scene the material will be use in.
  44743. */
  44744. constructor(name: string, scene: Scene);
  44745. /**
  44746. * Returns the name of this material class.
  44747. */
  44748. getClassName(): string;
  44749. /**
  44750. * Returns an array of the actively used textures.
  44751. * @returns - Array of BaseTextures
  44752. */
  44753. getActiveTextures(): BaseTexture[];
  44754. /**
  44755. * Checks to see if a texture is used in the material.
  44756. * @param texture - Base texture to use.
  44757. * @returns - Boolean specifying if a texture is used in the material.
  44758. */
  44759. hasTexture(texture: BaseTexture): boolean;
  44760. /**
  44761. * Makes a duplicate of the current material.
  44762. * @param name - name to use for the new material.
  44763. */
  44764. clone(name: string): PBRMaterial;
  44765. /**
  44766. * Serializes this PBR Material.
  44767. * @returns - An object with the serialized material.
  44768. */
  44769. serialize(): any;
  44770. /**
  44771. * Parses a PBR Material from a serialized object.
  44772. * @param source - Serialized object.
  44773. * @param scene - BJS scene instance.
  44774. * @param rootUrl - url for the scene object
  44775. * @returns - PBRMaterial
  44776. */
  44777. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44778. }
  44779. }
  44780. declare module "babylonjs/Helpers/sceneHelpers" {
  44781. import { Nullable } from "babylonjs/types";
  44782. import { Mesh } from "babylonjs/Meshes/mesh";
  44783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44784. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  44785. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44786. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  44787. import "babylonjs/Meshes/Builders/boxBuilder";
  44788. /** @hidden */
  44789. export var _forceSceneHelpersToBundle: boolean;
  44790. module "babylonjs/scene" {
  44791. interface Scene {
  44792. /**
  44793. * Creates a default light for the scene.
  44794. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  44795. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  44796. */
  44797. createDefaultLight(replace?: boolean): void;
  44798. /**
  44799. * Creates a default camera for the scene.
  44800. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  44801. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44802. * @param replace has default false, when true replaces the active camera in the scene
  44803. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  44804. */
  44805. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44806. /**
  44807. * Creates a default camera and a default light.
  44808. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  44809. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  44810. * @param replace has the default false, when true replaces the active camera/light in the scene
  44811. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  44812. */
  44813. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  44814. /**
  44815. * Creates a new sky box
  44816. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  44817. * @param environmentTexture defines the texture to use as environment texture
  44818. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  44819. * @param scale defines the overall scale of the skybox
  44820. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  44821. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  44822. * @returns a new mesh holding the sky box
  44823. */
  44824. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  44825. /**
  44826. * Creates a new environment
  44827. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  44828. * @param options defines the options you can use to configure the environment
  44829. * @returns the new EnvironmentHelper
  44830. */
  44831. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  44832. /**
  44833. * Creates a new VREXperienceHelper
  44834. * @see http://doc.babylonjs.com/how_to/webvr_helper
  44835. * @param webVROptions defines the options used to create the new VREXperienceHelper
  44836. * @returns a new VREXperienceHelper
  44837. */
  44838. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  44839. /**
  44840. * Creates a new XREXperienceHelper
  44841. * @see http://doc.babylonjs.com/how_to/webxr
  44842. * @returns a promise for a new XREXperienceHelper
  44843. */
  44844. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  44845. }
  44846. }
  44847. }
  44848. declare module "babylonjs/Helpers/videoDome" {
  44849. import { Scene } from "babylonjs/scene";
  44850. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44851. import { Mesh } from "babylonjs/Meshes/mesh";
  44852. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  44853. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44854. import "babylonjs/Meshes/Builders/sphereBuilder";
  44855. /**
  44856. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  44857. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  44858. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  44859. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44860. */
  44861. export class VideoDome extends TransformNode {
  44862. private _useDirectMapping;
  44863. /**
  44864. * The video texture being displayed on the sphere
  44865. */
  44866. protected _videoTexture: VideoTexture;
  44867. /**
  44868. * Gets the video texture being displayed on the sphere
  44869. */
  44870. readonly videoTexture: VideoTexture;
  44871. /**
  44872. * The skybox material
  44873. */
  44874. protected _material: BackgroundMaterial;
  44875. /**
  44876. * The surface used for the skybox
  44877. */
  44878. protected _mesh: Mesh;
  44879. /**
  44880. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44881. * Also see the options.resolution property.
  44882. */
  44883. fovMultiplier: number;
  44884. /**
  44885. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  44886. * @param name Element's name, child elements will append suffixes for their own names.
  44887. * @param urlsOrVideo defines the url(s) or the video element to use
  44888. * @param options An object containing optional or exposed sub element properties
  44889. */
  44890. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  44891. resolution?: number;
  44892. clickToPlay?: boolean;
  44893. autoPlay?: boolean;
  44894. loop?: boolean;
  44895. size?: number;
  44896. poster?: string;
  44897. useDirectMapping?: boolean;
  44898. }, scene: Scene);
  44899. /**
  44900. * Releases resources associated with this node.
  44901. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44902. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44903. */
  44904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44905. }
  44906. }
  44907. declare module "babylonjs/Helpers/index" {
  44908. export * from "babylonjs/Helpers/environmentHelper";
  44909. export * from "babylonjs/Helpers/photoDome";
  44910. export * from "babylonjs/Helpers/sceneHelpers";
  44911. export * from "babylonjs/Helpers/videoDome";
  44912. }
  44913. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  44914. import { PerfCounter } from "babylonjs/Misc/tools";
  44915. import { IDisposable } from "babylonjs/scene";
  44916. import { Engine } from "babylonjs/Engines/engine";
  44917. /**
  44918. * This class can be used to get instrumentation data from a Babylon engine
  44919. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44920. */
  44921. export class EngineInstrumentation implements IDisposable {
  44922. /**
  44923. * Define the instrumented engine.
  44924. */
  44925. engine: Engine;
  44926. private _captureGPUFrameTime;
  44927. private _gpuFrameTimeToken;
  44928. private _gpuFrameTime;
  44929. private _captureShaderCompilationTime;
  44930. private _shaderCompilationTime;
  44931. private _onBeginFrameObserver;
  44932. private _onEndFrameObserver;
  44933. private _onBeforeShaderCompilationObserver;
  44934. private _onAfterShaderCompilationObserver;
  44935. /**
  44936. * Gets the perf counter used for GPU frame time
  44937. */
  44938. readonly gpuFrameTimeCounter: PerfCounter;
  44939. /**
  44940. * Gets the GPU frame time capture status
  44941. */
  44942. /**
  44943. * Enable or disable the GPU frame time capture
  44944. */
  44945. captureGPUFrameTime: boolean;
  44946. /**
  44947. * Gets the perf counter used for shader compilation time
  44948. */
  44949. readonly shaderCompilationTimeCounter: PerfCounter;
  44950. /**
  44951. * Gets the shader compilation time capture status
  44952. */
  44953. /**
  44954. * Enable or disable the shader compilation time capture
  44955. */
  44956. captureShaderCompilationTime: boolean;
  44957. /**
  44958. * Instantiates a new engine instrumentation.
  44959. * This class can be used to get instrumentation data from a Babylon engine
  44960. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  44961. * @param engine Defines the engine to instrument
  44962. */
  44963. constructor(
  44964. /**
  44965. * Define the instrumented engine.
  44966. */
  44967. engine: Engine);
  44968. /**
  44969. * Dispose and release associated resources.
  44970. */
  44971. dispose(): void;
  44972. }
  44973. }
  44974. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  44975. import { PerfCounter } from "babylonjs/Misc/tools";
  44976. import { Scene, IDisposable } from "babylonjs/scene";
  44977. /**
  44978. * This class can be used to get instrumentation data from a Babylon engine
  44979. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  44980. */
  44981. export class SceneInstrumentation implements IDisposable {
  44982. /**
  44983. * Defines the scene to instrument
  44984. */
  44985. scene: Scene;
  44986. private _captureActiveMeshesEvaluationTime;
  44987. private _activeMeshesEvaluationTime;
  44988. private _captureRenderTargetsRenderTime;
  44989. private _renderTargetsRenderTime;
  44990. private _captureFrameTime;
  44991. private _frameTime;
  44992. private _captureRenderTime;
  44993. private _renderTime;
  44994. private _captureInterFrameTime;
  44995. private _interFrameTime;
  44996. private _captureParticlesRenderTime;
  44997. private _particlesRenderTime;
  44998. private _captureSpritesRenderTime;
  44999. private _spritesRenderTime;
  45000. private _capturePhysicsTime;
  45001. private _physicsTime;
  45002. private _captureAnimationsTime;
  45003. private _animationsTime;
  45004. private _captureCameraRenderTime;
  45005. private _cameraRenderTime;
  45006. private _onBeforeActiveMeshesEvaluationObserver;
  45007. private _onAfterActiveMeshesEvaluationObserver;
  45008. private _onBeforeRenderTargetsRenderObserver;
  45009. private _onAfterRenderTargetsRenderObserver;
  45010. private _onAfterRenderObserver;
  45011. private _onBeforeDrawPhaseObserver;
  45012. private _onAfterDrawPhaseObserver;
  45013. private _onBeforeAnimationsObserver;
  45014. private _onBeforeParticlesRenderingObserver;
  45015. private _onAfterParticlesRenderingObserver;
  45016. private _onBeforeSpritesRenderingObserver;
  45017. private _onAfterSpritesRenderingObserver;
  45018. private _onBeforePhysicsObserver;
  45019. private _onAfterPhysicsObserver;
  45020. private _onAfterAnimationsObserver;
  45021. private _onBeforeCameraRenderObserver;
  45022. private _onAfterCameraRenderObserver;
  45023. /**
  45024. * Gets the perf counter used for active meshes evaluation time
  45025. */
  45026. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45027. /**
  45028. * Gets the active meshes evaluation time capture status
  45029. */
  45030. /**
  45031. * Enable or disable the active meshes evaluation time capture
  45032. */
  45033. captureActiveMeshesEvaluationTime: boolean;
  45034. /**
  45035. * Gets the perf counter used for render targets render time
  45036. */
  45037. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45038. /**
  45039. * Gets the render targets render time capture status
  45040. */
  45041. /**
  45042. * Enable or disable the render targets render time capture
  45043. */
  45044. captureRenderTargetsRenderTime: boolean;
  45045. /**
  45046. * Gets the perf counter used for particles render time
  45047. */
  45048. readonly particlesRenderTimeCounter: PerfCounter;
  45049. /**
  45050. * Gets the particles render time capture status
  45051. */
  45052. /**
  45053. * Enable or disable the particles render time capture
  45054. */
  45055. captureParticlesRenderTime: boolean;
  45056. /**
  45057. * Gets the perf counter used for sprites render time
  45058. */
  45059. readonly spritesRenderTimeCounter: PerfCounter;
  45060. /**
  45061. * Gets the sprites render time capture status
  45062. */
  45063. /**
  45064. * Enable or disable the sprites render time capture
  45065. */
  45066. captureSpritesRenderTime: boolean;
  45067. /**
  45068. * Gets the perf counter used for physics time
  45069. */
  45070. readonly physicsTimeCounter: PerfCounter;
  45071. /**
  45072. * Gets the physics time capture status
  45073. */
  45074. /**
  45075. * Enable or disable the physics time capture
  45076. */
  45077. capturePhysicsTime: boolean;
  45078. /**
  45079. * Gets the perf counter used for animations time
  45080. */
  45081. readonly animationsTimeCounter: PerfCounter;
  45082. /**
  45083. * Gets the animations time capture status
  45084. */
  45085. /**
  45086. * Enable or disable the animations time capture
  45087. */
  45088. captureAnimationsTime: boolean;
  45089. /**
  45090. * Gets the perf counter used for frame time capture
  45091. */
  45092. readonly frameTimeCounter: PerfCounter;
  45093. /**
  45094. * Gets the frame time capture status
  45095. */
  45096. /**
  45097. * Enable or disable the frame time capture
  45098. */
  45099. captureFrameTime: boolean;
  45100. /**
  45101. * Gets the perf counter used for inter-frames time capture
  45102. */
  45103. readonly interFrameTimeCounter: PerfCounter;
  45104. /**
  45105. * Gets the inter-frames time capture status
  45106. */
  45107. /**
  45108. * Enable or disable the inter-frames time capture
  45109. */
  45110. captureInterFrameTime: boolean;
  45111. /**
  45112. * Gets the perf counter used for render time capture
  45113. */
  45114. readonly renderTimeCounter: PerfCounter;
  45115. /**
  45116. * Gets the render time capture status
  45117. */
  45118. /**
  45119. * Enable or disable the render time capture
  45120. */
  45121. captureRenderTime: boolean;
  45122. /**
  45123. * Gets the perf counter used for camera render time capture
  45124. */
  45125. readonly cameraRenderTimeCounter: PerfCounter;
  45126. /**
  45127. * Gets the camera render time capture status
  45128. */
  45129. /**
  45130. * Enable or disable the camera render time capture
  45131. */
  45132. captureCameraRenderTime: boolean;
  45133. /**
  45134. * Gets the perf counter used for draw calls
  45135. */
  45136. readonly drawCallsCounter: PerfCounter;
  45137. /**
  45138. * Gets the perf counter used for texture collisions
  45139. */
  45140. readonly textureCollisionsCounter: PerfCounter;
  45141. /**
  45142. * Instantiates a new scene instrumentation.
  45143. * This class can be used to get instrumentation data from a Babylon engine
  45144. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45145. * @param scene Defines the scene to instrument
  45146. */
  45147. constructor(
  45148. /**
  45149. * Defines the scene to instrument
  45150. */
  45151. scene: Scene);
  45152. /**
  45153. * Dispose and release associated resources.
  45154. */
  45155. dispose(): void;
  45156. }
  45157. }
  45158. declare module "babylonjs/Instrumentation/index" {
  45159. export * from "babylonjs/Instrumentation/engineInstrumentation";
  45160. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  45161. export * from "babylonjs/Instrumentation/timeToken";
  45162. }
  45163. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  45164. /** @hidden */
  45165. export var glowMapGenerationPixelShader: {
  45166. name: string;
  45167. shader: string;
  45168. };
  45169. }
  45170. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  45171. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45172. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  45173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  45174. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45175. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  45176. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45177. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45178. /** @hidden */
  45179. export var glowMapGenerationVertexShader: {
  45180. name: string;
  45181. shader: string;
  45182. };
  45183. }
  45184. declare module "babylonjs/Layers/effectLayer" {
  45185. import { Observable } from "babylonjs/Misc/observable";
  45186. import { Nullable } from "babylonjs/types";
  45187. import { Camera } from "babylonjs/Cameras/camera";
  45188. import { Scene } from "babylonjs/scene";
  45189. import { Color4, ISize } from "babylonjs/Maths/math";
  45190. import { Engine } from "babylonjs/Engines/engine";
  45191. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45192. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45193. import { Mesh } from "babylonjs/Meshes/mesh";
  45194. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  45195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45196. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45197. import { Effect } from "babylonjs/Materials/effect";
  45198. import { Material } from "babylonjs/Materials/material";
  45199. import "babylonjs/Shaders/glowMapGeneration.fragment";
  45200. import "babylonjs/Shaders/glowMapGeneration.vertex";
  45201. /**
  45202. * Effect layer options. This helps customizing the behaviour
  45203. * of the effect layer.
  45204. */
  45205. export interface IEffectLayerOptions {
  45206. /**
  45207. * Multiplication factor apply to the canvas size to compute the render target size
  45208. * used to generated the objects (the smaller the faster).
  45209. */
  45210. mainTextureRatio: number;
  45211. /**
  45212. * Enforces a fixed size texture to ensure effect stability across devices.
  45213. */
  45214. mainTextureFixedSize?: number;
  45215. /**
  45216. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45217. */
  45218. alphaBlendingMode: number;
  45219. /**
  45220. * The camera attached to the layer.
  45221. */
  45222. camera: Nullable<Camera>;
  45223. /**
  45224. * The rendering group to draw the layer in.
  45225. */
  45226. renderingGroupId: number;
  45227. }
  45228. /**
  45229. * The effect layer Helps adding post process effect blended with the main pass.
  45230. *
  45231. * This can be for instance use to generate glow or higlight effects on the scene.
  45232. *
  45233. * The effect layer class can not be used directly and is intented to inherited from to be
  45234. * customized per effects.
  45235. */
  45236. export abstract class EffectLayer {
  45237. private _vertexBuffers;
  45238. private _indexBuffer;
  45239. private _cachedDefines;
  45240. private _effectLayerMapGenerationEffect;
  45241. private _effectLayerOptions;
  45242. private _mergeEffect;
  45243. protected _scene: Scene;
  45244. protected _engine: Engine;
  45245. protected _maxSize: number;
  45246. protected _mainTextureDesiredSize: ISize;
  45247. protected _mainTexture: RenderTargetTexture;
  45248. protected _shouldRender: boolean;
  45249. protected _postProcesses: PostProcess[];
  45250. protected _textures: BaseTexture[];
  45251. protected _emissiveTextureAndColor: {
  45252. texture: Nullable<BaseTexture>;
  45253. color: Color4;
  45254. };
  45255. /**
  45256. * The name of the layer
  45257. */
  45258. name: string;
  45259. /**
  45260. * The clear color of the texture used to generate the glow map.
  45261. */
  45262. neutralColor: Color4;
  45263. /**
  45264. * Specifies wether the highlight layer is enabled or not.
  45265. */
  45266. isEnabled: boolean;
  45267. /**
  45268. * Gets the camera attached to the layer.
  45269. */
  45270. readonly camera: Nullable<Camera>;
  45271. /**
  45272. * Gets the rendering group id the layer should render in.
  45273. */
  45274. readonly renderingGroupId: number;
  45275. /**
  45276. * An event triggered when the effect layer has been disposed.
  45277. */
  45278. onDisposeObservable: Observable<EffectLayer>;
  45279. /**
  45280. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45281. */
  45282. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45283. /**
  45284. * An event triggered when the generated texture is being merged in the scene.
  45285. */
  45286. onBeforeComposeObservable: Observable<EffectLayer>;
  45287. /**
  45288. * An event triggered when the generated texture has been merged in the scene.
  45289. */
  45290. onAfterComposeObservable: Observable<EffectLayer>;
  45291. /**
  45292. * An event triggered when the efffect layer changes its size.
  45293. */
  45294. onSizeChangedObservable: Observable<EffectLayer>;
  45295. /** @hidden */
  45296. static _SceneComponentInitialization: (scene: Scene) => void;
  45297. /**
  45298. * Instantiates a new effect Layer and references it in the scene.
  45299. * @param name The name of the layer
  45300. * @param scene The scene to use the layer in
  45301. */
  45302. constructor(
  45303. /** The Friendly of the effect in the scene */
  45304. name: string, scene: Scene);
  45305. /**
  45306. * Get the effect name of the layer.
  45307. * @return The effect name
  45308. */
  45309. abstract getEffectName(): string;
  45310. /**
  45311. * Checks for the readiness of the element composing the layer.
  45312. * @param subMesh the mesh to check for
  45313. * @param useInstances specify wether or not to use instances to render the mesh
  45314. * @return true if ready otherwise, false
  45315. */
  45316. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45317. /**
  45318. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45319. * @returns true if the effect requires stencil during the main canvas render pass.
  45320. */
  45321. abstract needStencil(): boolean;
  45322. /**
  45323. * Create the merge effect. This is the shader use to blit the information back
  45324. * to the main canvas at the end of the scene rendering.
  45325. * @returns The effect containing the shader used to merge the effect on the main canvas
  45326. */
  45327. protected abstract _createMergeEffect(): Effect;
  45328. /**
  45329. * Creates the render target textures and post processes used in the effect layer.
  45330. */
  45331. protected abstract _createTextureAndPostProcesses(): void;
  45332. /**
  45333. * Implementation specific of rendering the generating effect on the main canvas.
  45334. * @param effect The effect used to render through
  45335. */
  45336. protected abstract _internalRender(effect: Effect): void;
  45337. /**
  45338. * Sets the required values for both the emissive texture and and the main color.
  45339. */
  45340. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45341. /**
  45342. * Free any resources and references associated to a mesh.
  45343. * Internal use
  45344. * @param mesh The mesh to free.
  45345. */
  45346. abstract _disposeMesh(mesh: Mesh): void;
  45347. /**
  45348. * Serializes this layer (Glow or Highlight for example)
  45349. * @returns a serialized layer object
  45350. */
  45351. abstract serialize?(): any;
  45352. /**
  45353. * Initializes the effect layer with the required options.
  45354. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45355. */
  45356. protected _init(options: Partial<IEffectLayerOptions>): void;
  45357. /**
  45358. * Generates the index buffer of the full screen quad blending to the main canvas.
  45359. */
  45360. private _generateIndexBuffer;
  45361. /**
  45362. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45363. */
  45364. private _genrateVertexBuffer;
  45365. /**
  45366. * Sets the main texture desired size which is the closest power of two
  45367. * of the engine canvas size.
  45368. */
  45369. private _setMainTextureSize;
  45370. /**
  45371. * Creates the main texture for the effect layer.
  45372. */
  45373. protected _createMainTexture(): void;
  45374. /**
  45375. * Adds specific effects defines.
  45376. * @param defines The defines to add specifics to.
  45377. */
  45378. protected _addCustomEffectDefines(defines: string[]): void;
  45379. /**
  45380. * Checks for the readiness of the element composing the layer.
  45381. * @param subMesh the mesh to check for
  45382. * @param useInstances specify wether or not to use instances to render the mesh
  45383. * @param emissiveTexture the associated emissive texture used to generate the glow
  45384. * @return true if ready otherwise, false
  45385. */
  45386. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45387. /**
  45388. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45389. */
  45390. render(): void;
  45391. /**
  45392. * Determine if a given mesh will be used in the current effect.
  45393. * @param mesh mesh to test
  45394. * @returns true if the mesh will be used
  45395. */
  45396. hasMesh(mesh: AbstractMesh): boolean;
  45397. /**
  45398. * Returns true if the layer contains information to display, otherwise false.
  45399. * @returns true if the glow layer should be rendered
  45400. */
  45401. shouldRender(): boolean;
  45402. /**
  45403. * Returns true if the mesh should render, otherwise false.
  45404. * @param mesh The mesh to render
  45405. * @returns true if it should render otherwise false
  45406. */
  45407. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45408. /**
  45409. * Returns true if the mesh can be rendered, otherwise false.
  45410. * @param mesh The mesh to render
  45411. * @param material The material used on the mesh
  45412. * @returns true if it can be rendered otherwise false
  45413. */
  45414. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45415. /**
  45416. * Returns true if the mesh should render, otherwise false.
  45417. * @param mesh The mesh to render
  45418. * @returns true if it should render otherwise false
  45419. */
  45420. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45421. /**
  45422. * Renders the submesh passed in parameter to the generation map.
  45423. */
  45424. protected _renderSubMesh(subMesh: SubMesh): void;
  45425. /**
  45426. * Rebuild the required buffers.
  45427. * @hidden Internal use only.
  45428. */
  45429. _rebuild(): void;
  45430. /**
  45431. * Dispose only the render target textures and post process.
  45432. */
  45433. private _disposeTextureAndPostProcesses;
  45434. /**
  45435. * Dispose the highlight layer and free resources.
  45436. */
  45437. dispose(): void;
  45438. /**
  45439. * Gets the class name of the effect layer
  45440. * @returns the string with the class name of the effect layer
  45441. */
  45442. getClassName(): string;
  45443. /**
  45444. * Creates an effect layer from parsed effect layer data
  45445. * @param parsedEffectLayer defines effect layer data
  45446. * @param scene defines the current scene
  45447. * @param rootUrl defines the root URL containing the effect layer information
  45448. * @returns a parsed effect Layer
  45449. */
  45450. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45451. }
  45452. }
  45453. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  45454. import { Scene } from "babylonjs/scene";
  45455. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  45456. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45457. import { AbstractScene } from "babylonjs/abstractScene";
  45458. module "babylonjs/abstractScene" {
  45459. interface AbstractScene {
  45460. /**
  45461. * The list of effect layers (highlights/glow) added to the scene
  45462. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45463. * @see http://doc.babylonjs.com/how_to/glow_layer
  45464. */
  45465. effectLayers: Array<EffectLayer>;
  45466. /**
  45467. * Removes the given effect layer from this scene.
  45468. * @param toRemove defines the effect layer to remove
  45469. * @returns the index of the removed effect layer
  45470. */
  45471. removeEffectLayer(toRemove: EffectLayer): number;
  45472. /**
  45473. * Adds the given effect layer to this scene
  45474. * @param newEffectLayer defines the effect layer to add
  45475. */
  45476. addEffectLayer(newEffectLayer: EffectLayer): void;
  45477. }
  45478. }
  45479. /**
  45480. * Defines the layer scene component responsible to manage any effect layers
  45481. * in a given scene.
  45482. */
  45483. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45484. /**
  45485. * The component name helpfull to identify the component in the list of scene components.
  45486. */
  45487. readonly name: string;
  45488. /**
  45489. * The scene the component belongs to.
  45490. */
  45491. scene: Scene;
  45492. private _engine;
  45493. private _renderEffects;
  45494. private _needStencil;
  45495. private _previousStencilState;
  45496. /**
  45497. * Creates a new instance of the component for the given scene
  45498. * @param scene Defines the scene to register the component in
  45499. */
  45500. constructor(scene: Scene);
  45501. /**
  45502. * Registers the component in a given scene
  45503. */
  45504. register(): void;
  45505. /**
  45506. * Rebuilds the elements related to this component in case of
  45507. * context lost for instance.
  45508. */
  45509. rebuild(): void;
  45510. /**
  45511. * Serializes the component data to the specified json object
  45512. * @param serializationObject The object to serialize to
  45513. */
  45514. serialize(serializationObject: any): void;
  45515. /**
  45516. * Adds all the element from the container to the scene
  45517. * @param container the container holding the elements
  45518. */
  45519. addFromContainer(container: AbstractScene): void;
  45520. /**
  45521. * Removes all the elements in the container from the scene
  45522. * @param container contains the elements to remove
  45523. */
  45524. removeFromContainer(container: AbstractScene): void;
  45525. /**
  45526. * Disposes the component and the associated ressources.
  45527. */
  45528. dispose(): void;
  45529. private _isReadyForMesh;
  45530. private _renderMainTexture;
  45531. private _setStencil;
  45532. private _setStencilBack;
  45533. private _draw;
  45534. private _drawCamera;
  45535. private _drawRenderingGroup;
  45536. }
  45537. }
  45538. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  45539. /** @hidden */
  45540. export var glowMapMergePixelShader: {
  45541. name: string;
  45542. shader: string;
  45543. };
  45544. }
  45545. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  45546. /** @hidden */
  45547. export var glowMapMergeVertexShader: {
  45548. name: string;
  45549. shader: string;
  45550. };
  45551. }
  45552. declare module "babylonjs/Layers/glowLayer" {
  45553. import { Nullable } from "babylonjs/types";
  45554. import { Camera } from "babylonjs/Cameras/camera";
  45555. import { Scene } from "babylonjs/scene";
  45556. import { Color4 } from "babylonjs/Maths/math";
  45557. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45559. import { Mesh } from "babylonjs/Meshes/mesh";
  45560. import { Texture } from "babylonjs/Materials/Textures/texture";
  45561. import { Effect } from "babylonjs/Materials/effect";
  45562. import { Material } from "babylonjs/Materials/material";
  45563. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45564. import "babylonjs/Shaders/glowMapMerge.fragment";
  45565. import "babylonjs/Shaders/glowMapMerge.vertex";
  45566. module "babylonjs/abstractScene" {
  45567. interface AbstractScene {
  45568. /**
  45569. * Return a the first highlight layer of the scene with a given name.
  45570. * @param name The name of the highlight layer to look for.
  45571. * @return The highlight layer if found otherwise null.
  45572. */
  45573. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45574. }
  45575. }
  45576. /**
  45577. * Glow layer options. This helps customizing the behaviour
  45578. * of the glow layer.
  45579. */
  45580. export interface IGlowLayerOptions {
  45581. /**
  45582. * Multiplication factor apply to the canvas size to compute the render target size
  45583. * used to generated the glowing objects (the smaller the faster).
  45584. */
  45585. mainTextureRatio: number;
  45586. /**
  45587. * Enforces a fixed size texture to ensure resize independant blur.
  45588. */
  45589. mainTextureFixedSize?: number;
  45590. /**
  45591. * How big is the kernel of the blur texture.
  45592. */
  45593. blurKernelSize: number;
  45594. /**
  45595. * The camera attached to the layer.
  45596. */
  45597. camera: Nullable<Camera>;
  45598. /**
  45599. * Enable MSAA by chosing the number of samples.
  45600. */
  45601. mainTextureSamples?: number;
  45602. /**
  45603. * The rendering group to draw the layer in.
  45604. */
  45605. renderingGroupId: number;
  45606. }
  45607. /**
  45608. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45609. *
  45610. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45611. * glowy meshes to your scene.
  45612. *
  45613. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45614. */
  45615. export class GlowLayer extends EffectLayer {
  45616. /**
  45617. * Effect Name of the layer.
  45618. */
  45619. static readonly EffectName: string;
  45620. /**
  45621. * The default blur kernel size used for the glow.
  45622. */
  45623. static DefaultBlurKernelSize: number;
  45624. /**
  45625. * The default texture size ratio used for the glow.
  45626. */
  45627. static DefaultTextureRatio: number;
  45628. /**
  45629. * Sets the kernel size of the blur.
  45630. */
  45631. /**
  45632. * Gets the kernel size of the blur.
  45633. */
  45634. blurKernelSize: number;
  45635. /**
  45636. * Sets the glow intensity.
  45637. */
  45638. /**
  45639. * Gets the glow intensity.
  45640. */
  45641. intensity: number;
  45642. private _options;
  45643. private _intensity;
  45644. private _horizontalBlurPostprocess1;
  45645. private _verticalBlurPostprocess1;
  45646. private _horizontalBlurPostprocess2;
  45647. private _verticalBlurPostprocess2;
  45648. private _blurTexture1;
  45649. private _blurTexture2;
  45650. private _postProcesses1;
  45651. private _postProcesses2;
  45652. private _includedOnlyMeshes;
  45653. private _excludedMeshes;
  45654. /**
  45655. * Callback used to let the user override the color selection on a per mesh basis
  45656. */
  45657. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45658. /**
  45659. * Callback used to let the user override the texture selection on a per mesh basis
  45660. */
  45661. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45662. /**
  45663. * Instantiates a new glow Layer and references it to the scene.
  45664. * @param name The name of the layer
  45665. * @param scene The scene to use the layer in
  45666. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45667. */
  45668. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45669. /**
  45670. * Get the effect name of the layer.
  45671. * @return The effect name
  45672. */
  45673. getEffectName(): string;
  45674. /**
  45675. * Create the merge effect. This is the shader use to blit the information back
  45676. * to the main canvas at the end of the scene rendering.
  45677. */
  45678. protected _createMergeEffect(): Effect;
  45679. /**
  45680. * Creates the render target textures and post processes used in the glow layer.
  45681. */
  45682. protected _createTextureAndPostProcesses(): void;
  45683. /**
  45684. * Checks for the readiness of the element composing the layer.
  45685. * @param subMesh the mesh to check for
  45686. * @param useInstances specify wether or not to use instances to render the mesh
  45687. * @param emissiveTexture the associated emissive texture used to generate the glow
  45688. * @return true if ready otherwise, false
  45689. */
  45690. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45691. /**
  45692. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45693. */
  45694. needStencil(): boolean;
  45695. /**
  45696. * Returns true if the mesh can be rendered, otherwise false.
  45697. * @param mesh The mesh to render
  45698. * @param material The material used on the mesh
  45699. * @returns true if it can be rendered otherwise false
  45700. */
  45701. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45702. /**
  45703. * Implementation specific of rendering the generating effect on the main canvas.
  45704. * @param effect The effect used to render through
  45705. */
  45706. protected _internalRender(effect: Effect): void;
  45707. /**
  45708. * Sets the required values for both the emissive texture and and the main color.
  45709. */
  45710. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45711. /**
  45712. * Returns true if the mesh should render, otherwise false.
  45713. * @param mesh The mesh to render
  45714. * @returns true if it should render otherwise false
  45715. */
  45716. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45717. /**
  45718. * Adds specific effects defines.
  45719. * @param defines The defines to add specifics to.
  45720. */
  45721. protected _addCustomEffectDefines(defines: string[]): void;
  45722. /**
  45723. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45724. * @param mesh The mesh to exclude from the glow layer
  45725. */
  45726. addExcludedMesh(mesh: Mesh): void;
  45727. /**
  45728. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45729. * @param mesh The mesh to remove
  45730. */
  45731. removeExcludedMesh(mesh: Mesh): void;
  45732. /**
  45733. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45734. * @param mesh The mesh to include in the glow layer
  45735. */
  45736. addIncludedOnlyMesh(mesh: Mesh): void;
  45737. /**
  45738. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45739. * @param mesh The mesh to remove
  45740. */
  45741. removeIncludedOnlyMesh(mesh: Mesh): void;
  45742. /**
  45743. * Determine if a given mesh will be used in the glow layer
  45744. * @param mesh The mesh to test
  45745. * @returns true if the mesh will be highlighted by the current glow layer
  45746. */
  45747. hasMesh(mesh: AbstractMesh): boolean;
  45748. /**
  45749. * Free any resources and references associated to a mesh.
  45750. * Internal use
  45751. * @param mesh The mesh to free.
  45752. * @hidden
  45753. */
  45754. _disposeMesh(mesh: Mesh): void;
  45755. /**
  45756. * Gets the class name of the effect layer
  45757. * @returns the string with the class name of the effect layer
  45758. */
  45759. getClassName(): string;
  45760. /**
  45761. * Serializes this glow layer
  45762. * @returns a serialized glow layer object
  45763. */
  45764. serialize(): any;
  45765. /**
  45766. * Creates a Glow Layer from parsed glow layer data
  45767. * @param parsedGlowLayer defines glow layer data
  45768. * @param scene defines the current scene
  45769. * @param rootUrl defines the root URL containing the glow layer information
  45770. * @returns a parsed Glow Layer
  45771. */
  45772. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  45773. }
  45774. }
  45775. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  45776. /** @hidden */
  45777. export var glowBlurPostProcessPixelShader: {
  45778. name: string;
  45779. shader: string;
  45780. };
  45781. }
  45782. declare module "babylonjs/Layers/highlightLayer" {
  45783. import { Observable } from "babylonjs/Misc/observable";
  45784. import { Nullable } from "babylonjs/types";
  45785. import { Camera } from "babylonjs/Cameras/camera";
  45786. import { Scene } from "babylonjs/scene";
  45787. import { Color3, Color4 } from "babylonjs/Maths/math";
  45788. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45790. import { Mesh } from "babylonjs/Meshes/mesh";
  45791. import { Effect } from "babylonjs/Materials/effect";
  45792. import { Material } from "babylonjs/Materials/material";
  45793. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  45794. import "babylonjs/Shaders/glowMapMerge.fragment";
  45795. import "babylonjs/Shaders/glowMapMerge.vertex";
  45796. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  45797. module "babylonjs/abstractScene" {
  45798. interface AbstractScene {
  45799. /**
  45800. * Return a the first highlight layer of the scene with a given name.
  45801. * @param name The name of the highlight layer to look for.
  45802. * @return The highlight layer if found otherwise null.
  45803. */
  45804. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  45805. }
  45806. }
  45807. /**
  45808. * Highlight layer options. This helps customizing the behaviour
  45809. * of the highlight layer.
  45810. */
  45811. export interface IHighlightLayerOptions {
  45812. /**
  45813. * Multiplication factor apply to the canvas size to compute the render target size
  45814. * used to generated the glowing objects (the smaller the faster).
  45815. */
  45816. mainTextureRatio: number;
  45817. /**
  45818. * Enforces a fixed size texture to ensure resize independant blur.
  45819. */
  45820. mainTextureFixedSize?: number;
  45821. /**
  45822. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  45823. * of the picture to blur (the smaller the faster).
  45824. */
  45825. blurTextureSizeRatio: number;
  45826. /**
  45827. * How big in texel of the blur texture is the vertical blur.
  45828. */
  45829. blurVerticalSize: number;
  45830. /**
  45831. * How big in texel of the blur texture is the horizontal blur.
  45832. */
  45833. blurHorizontalSize: number;
  45834. /**
  45835. * Alpha blending mode used to apply the blur. Default is combine.
  45836. */
  45837. alphaBlendingMode: number;
  45838. /**
  45839. * The camera attached to the layer.
  45840. */
  45841. camera: Nullable<Camera>;
  45842. /**
  45843. * Should we display highlight as a solid stroke?
  45844. */
  45845. isStroke?: boolean;
  45846. /**
  45847. * The rendering group to draw the layer in.
  45848. */
  45849. renderingGroupId: number;
  45850. }
  45851. /**
  45852. * The highlight layer Helps adding a glow effect around a mesh.
  45853. *
  45854. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45855. * glowy meshes to your scene.
  45856. *
  45857. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  45858. */
  45859. export class HighlightLayer extends EffectLayer {
  45860. name: string;
  45861. /**
  45862. * Effect Name of the highlight layer.
  45863. */
  45864. static readonly EffectName: string;
  45865. /**
  45866. * The neutral color used during the preparation of the glow effect.
  45867. * This is black by default as the blend operation is a blend operation.
  45868. */
  45869. static NeutralColor: Color4;
  45870. /**
  45871. * Stencil value used for glowing meshes.
  45872. */
  45873. static GlowingMeshStencilReference: number;
  45874. /**
  45875. * Stencil value used for the other meshes in the scene.
  45876. */
  45877. static NormalMeshStencilReference: number;
  45878. /**
  45879. * Specifies whether or not the inner glow is ACTIVE in the layer.
  45880. */
  45881. innerGlow: boolean;
  45882. /**
  45883. * Specifies whether or not the outer glow is ACTIVE in the layer.
  45884. */
  45885. outerGlow: boolean;
  45886. /**
  45887. * Specifies the horizontal size of the blur.
  45888. */
  45889. /**
  45890. * Gets the horizontal size of the blur.
  45891. */
  45892. blurHorizontalSize: number;
  45893. /**
  45894. * Specifies the vertical size of the blur.
  45895. */
  45896. /**
  45897. * Gets the vertical size of the blur.
  45898. */
  45899. blurVerticalSize: number;
  45900. /**
  45901. * An event triggered when the highlight layer is being blurred.
  45902. */
  45903. onBeforeBlurObservable: Observable<HighlightLayer>;
  45904. /**
  45905. * An event triggered when the highlight layer has been blurred.
  45906. */
  45907. onAfterBlurObservable: Observable<HighlightLayer>;
  45908. private _instanceGlowingMeshStencilReference;
  45909. private _options;
  45910. private _downSamplePostprocess;
  45911. private _horizontalBlurPostprocess;
  45912. private _verticalBlurPostprocess;
  45913. private _blurTexture;
  45914. private _meshes;
  45915. private _excludedMeshes;
  45916. /**
  45917. * Instantiates a new highlight Layer and references it to the scene..
  45918. * @param name The name of the layer
  45919. * @param scene The scene to use the layer in
  45920. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  45921. */
  45922. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  45923. /**
  45924. * Get the effect name of the layer.
  45925. * @return The effect name
  45926. */
  45927. getEffectName(): string;
  45928. /**
  45929. * Create the merge effect. This is the shader use to blit the information back
  45930. * to the main canvas at the end of the scene rendering.
  45931. */
  45932. protected _createMergeEffect(): Effect;
  45933. /**
  45934. * Creates the render target textures and post processes used in the highlight layer.
  45935. */
  45936. protected _createTextureAndPostProcesses(): void;
  45937. /**
  45938. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45939. */
  45940. needStencil(): boolean;
  45941. /**
  45942. * Checks for the readiness of the element composing the layer.
  45943. * @param subMesh the mesh to check for
  45944. * @param useInstances specify wether or not to use instances to render the mesh
  45945. * @param emissiveTexture the associated emissive texture used to generate the glow
  45946. * @return true if ready otherwise, false
  45947. */
  45948. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45949. /**
  45950. * Implementation specific of rendering the generating effect on the main canvas.
  45951. * @param effect The effect used to render through
  45952. */
  45953. protected _internalRender(effect: Effect): void;
  45954. /**
  45955. * Returns true if the layer contains information to display, otherwise false.
  45956. */
  45957. shouldRender(): boolean;
  45958. /**
  45959. * Returns true if the mesh should render, otherwise false.
  45960. * @param mesh The mesh to render
  45961. * @returns true if it should render otherwise false
  45962. */
  45963. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45964. /**
  45965. * Sets the required values for both the emissive texture and and the main color.
  45966. */
  45967. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45968. /**
  45969. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  45970. * @param mesh The mesh to exclude from the highlight layer
  45971. */
  45972. addExcludedMesh(mesh: Mesh): void;
  45973. /**
  45974. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  45975. * @param mesh The mesh to highlight
  45976. */
  45977. removeExcludedMesh(mesh: Mesh): void;
  45978. /**
  45979. * Determine if a given mesh will be highlighted by the current HighlightLayer
  45980. * @param mesh mesh to test
  45981. * @returns true if the mesh will be highlighted by the current HighlightLayer
  45982. */
  45983. hasMesh(mesh: AbstractMesh): boolean;
  45984. /**
  45985. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  45986. * @param mesh The mesh to highlight
  45987. * @param color The color of the highlight
  45988. * @param glowEmissiveOnly Extract the glow from the emissive texture
  45989. */
  45990. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  45991. /**
  45992. * Remove a mesh from the highlight layer in order to make it stop glowing.
  45993. * @param mesh The mesh to highlight
  45994. */
  45995. removeMesh(mesh: Mesh): void;
  45996. /**
  45997. * Force the stencil to the normal expected value for none glowing parts
  45998. */
  45999. private _defaultStencilReference;
  46000. /**
  46001. * Free any resources and references associated to a mesh.
  46002. * Internal use
  46003. * @param mesh The mesh to free.
  46004. * @hidden
  46005. */
  46006. _disposeMesh(mesh: Mesh): void;
  46007. /**
  46008. * Dispose the highlight layer and free resources.
  46009. */
  46010. dispose(): void;
  46011. /**
  46012. * Gets the class name of the effect layer
  46013. * @returns the string with the class name of the effect layer
  46014. */
  46015. getClassName(): string;
  46016. /**
  46017. * Serializes this Highlight layer
  46018. * @returns a serialized Highlight layer object
  46019. */
  46020. serialize(): any;
  46021. /**
  46022. * Creates a Highlight layer from parsed Highlight layer data
  46023. * @param parsedHightlightLayer defines the Highlight layer data
  46024. * @param scene defines the current scene
  46025. * @param rootUrl defines the root URL containing the Highlight layer information
  46026. * @returns a parsed Highlight layer
  46027. */
  46028. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46029. }
  46030. }
  46031. declare module "babylonjs/Layers/index" {
  46032. export * from "babylonjs/Layers/effectLayer";
  46033. export * from "babylonjs/Layers/effectLayerSceneComponent";
  46034. export * from "babylonjs/Layers/glowLayer";
  46035. export * from "babylonjs/Layers/highlightLayer";
  46036. export * from "babylonjs/Layers/layer";
  46037. export * from "babylonjs/Layers/layerSceneComponent";
  46038. }
  46039. declare module "babylonjs/Shaders/lensFlare.fragment" {
  46040. /** @hidden */
  46041. export var lensFlarePixelShader: {
  46042. name: string;
  46043. shader: string;
  46044. };
  46045. }
  46046. declare module "babylonjs/Shaders/lensFlare.vertex" {
  46047. /** @hidden */
  46048. export var lensFlareVertexShader: {
  46049. name: string;
  46050. shader: string;
  46051. };
  46052. }
  46053. declare module "babylonjs/LensFlares/lensFlareSystem" {
  46054. import { Scene } from "babylonjs/scene";
  46055. import { Vector3, Viewport } from "babylonjs/Maths/math";
  46056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46057. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  46058. import "babylonjs/Shaders/lensFlare.fragment";
  46059. import "babylonjs/Shaders/lensFlare.vertex";
  46060. /**
  46061. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46062. * It is usually composed of several `lensFlare`.
  46063. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46064. */
  46065. export class LensFlareSystem {
  46066. /**
  46067. * Define the name of the lens flare system
  46068. */
  46069. name: string;
  46070. /**
  46071. * List of lens flares used in this system.
  46072. */
  46073. lensFlares: LensFlare[];
  46074. /**
  46075. * Define a limit from the border the lens flare can be visible.
  46076. */
  46077. borderLimit: number;
  46078. /**
  46079. * Define a viewport border we do not want to see the lens flare in.
  46080. */
  46081. viewportBorder: number;
  46082. /**
  46083. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46084. */
  46085. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46086. /**
  46087. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46088. */
  46089. layerMask: number;
  46090. /**
  46091. * Define the id of the lens flare system in the scene.
  46092. * (equal to name by default)
  46093. */
  46094. id: string;
  46095. private _scene;
  46096. private _emitter;
  46097. private _vertexBuffers;
  46098. private _indexBuffer;
  46099. private _effect;
  46100. private _positionX;
  46101. private _positionY;
  46102. private _isEnabled;
  46103. /** @hidden */
  46104. static _SceneComponentInitialization: (scene: Scene) => void;
  46105. /**
  46106. * Instantiates a lens flare system.
  46107. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46108. * It is usually composed of several `lensFlare`.
  46109. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46110. * @param name Define the name of the lens flare system in the scene
  46111. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46112. * @param scene Define the scene the lens flare system belongs to
  46113. */
  46114. constructor(
  46115. /**
  46116. * Define the name of the lens flare system
  46117. */
  46118. name: string, emitter: any, scene: Scene);
  46119. /**
  46120. * Define if the lens flare system is enabled.
  46121. */
  46122. isEnabled: boolean;
  46123. /**
  46124. * Get the scene the effects belongs to.
  46125. * @returns the scene holding the lens flare system
  46126. */
  46127. getScene(): Scene;
  46128. /**
  46129. * Get the emitter of the lens flare system.
  46130. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46131. * @returns the emitter of the lens flare system
  46132. */
  46133. getEmitter(): any;
  46134. /**
  46135. * Set the emitter of the lens flare system.
  46136. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46137. * @param newEmitter Define the new emitter of the system
  46138. */
  46139. setEmitter(newEmitter: any): void;
  46140. /**
  46141. * Get the lens flare system emitter position.
  46142. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46143. * @returns the position
  46144. */
  46145. getEmitterPosition(): Vector3;
  46146. /**
  46147. * @hidden
  46148. */
  46149. computeEffectivePosition(globalViewport: Viewport): boolean;
  46150. /** @hidden */
  46151. _isVisible(): boolean;
  46152. /**
  46153. * @hidden
  46154. */
  46155. render(): boolean;
  46156. /**
  46157. * Dispose and release the lens flare with its associated resources.
  46158. */
  46159. dispose(): void;
  46160. /**
  46161. * Parse a lens flare system from a JSON repressentation
  46162. * @param parsedLensFlareSystem Define the JSON to parse
  46163. * @param scene Define the scene the parsed system should be instantiated in
  46164. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46165. * @returns the parsed system
  46166. */
  46167. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46168. /**
  46169. * Serialize the current Lens Flare System into a JSON representation.
  46170. * @returns the serialized JSON
  46171. */
  46172. serialize(): any;
  46173. }
  46174. }
  46175. declare module "babylonjs/LensFlares/lensFlare" {
  46176. import { Nullable } from "babylonjs/types";
  46177. import { Color3 } from "babylonjs/Maths/math";
  46178. import { Texture } from "babylonjs/Materials/Textures/texture";
  46179. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46180. /**
  46181. * This represents one of the lens effect in a `lensFlareSystem`.
  46182. * It controls one of the indiviual texture used in the effect.
  46183. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46184. */
  46185. export class LensFlare {
  46186. /**
  46187. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46188. */
  46189. size: number;
  46190. /**
  46191. * 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.
  46192. */
  46193. position: number;
  46194. /**
  46195. * Define the lens color.
  46196. */
  46197. color: Color3;
  46198. /**
  46199. * Define the lens texture.
  46200. */
  46201. texture: Nullable<Texture>;
  46202. /**
  46203. * Define the alpha mode to render this particular lens.
  46204. */
  46205. alphaMode: number;
  46206. private _system;
  46207. /**
  46208. * Creates a new Lens Flare.
  46209. * This represents one of the lens effect in a `lensFlareSystem`.
  46210. * It controls one of the indiviual texture used in the effect.
  46211. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46212. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46213. * @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.
  46214. * @param color Define the lens color
  46215. * @param imgUrl Define the lens texture url
  46216. * @param system Define the `lensFlareSystem` this flare is part of
  46217. * @returns The newly created Lens Flare
  46218. */
  46219. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46220. /**
  46221. * Instantiates a new Lens Flare.
  46222. * This represents one of the lens effect in a `lensFlareSystem`.
  46223. * It controls one of the indiviual texture used in the effect.
  46224. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46225. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46226. * @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.
  46227. * @param color Define the lens color
  46228. * @param imgUrl Define the lens texture url
  46229. * @param system Define the `lensFlareSystem` this flare is part of
  46230. */
  46231. constructor(
  46232. /**
  46233. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46234. */
  46235. size: number,
  46236. /**
  46237. * 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.
  46238. */
  46239. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46240. /**
  46241. * Dispose and release the lens flare with its associated resources.
  46242. */
  46243. dispose(): void;
  46244. }
  46245. }
  46246. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  46247. import { Nullable } from "babylonjs/types";
  46248. import { Scene } from "babylonjs/scene";
  46249. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46250. import { AbstractScene } from "babylonjs/abstractScene";
  46251. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  46252. module "babylonjs/abstractScene" {
  46253. interface AbstractScene {
  46254. /**
  46255. * The list of lens flare system added to the scene
  46256. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46257. */
  46258. lensFlareSystems: Array<LensFlareSystem>;
  46259. /**
  46260. * Removes the given lens flare system from this scene.
  46261. * @param toRemove The lens flare system to remove
  46262. * @returns The index of the removed lens flare system
  46263. */
  46264. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46265. /**
  46266. * Adds the given lens flare system to this scene
  46267. * @param newLensFlareSystem The lens flare system to add
  46268. */
  46269. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46270. /**
  46271. * Gets a lens flare system using its name
  46272. * @param name defines the name to look for
  46273. * @returns the lens flare system or null if not found
  46274. */
  46275. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46276. /**
  46277. * Gets a lens flare system using its id
  46278. * @param id defines the id to look for
  46279. * @returns the lens flare system or null if not found
  46280. */
  46281. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46282. }
  46283. }
  46284. /**
  46285. * Defines the lens flare scene component responsible to manage any lens flares
  46286. * in a given scene.
  46287. */
  46288. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46289. /**
  46290. * The component name helpfull to identify the component in the list of scene components.
  46291. */
  46292. readonly name: string;
  46293. /**
  46294. * The scene the component belongs to.
  46295. */
  46296. scene: Scene;
  46297. /**
  46298. * Creates a new instance of the component for the given scene
  46299. * @param scene Defines the scene to register the component in
  46300. */
  46301. constructor(scene: Scene);
  46302. /**
  46303. * Registers the component in a given scene
  46304. */
  46305. register(): void;
  46306. /**
  46307. * Rebuilds the elements related to this component in case of
  46308. * context lost for instance.
  46309. */
  46310. rebuild(): void;
  46311. /**
  46312. * Adds all the element from the container to the scene
  46313. * @param container the container holding the elements
  46314. */
  46315. addFromContainer(container: AbstractScene): void;
  46316. /**
  46317. * Removes all the elements in the container from the scene
  46318. * @param container contains the elements to remove
  46319. */
  46320. removeFromContainer(container: AbstractScene): void;
  46321. /**
  46322. * Serializes the component data to the specified json object
  46323. * @param serializationObject The object to serialize to
  46324. */
  46325. serialize(serializationObject: any): void;
  46326. /**
  46327. * Disposes the component and the associated ressources.
  46328. */
  46329. dispose(): void;
  46330. private _draw;
  46331. }
  46332. }
  46333. declare module "babylonjs/LensFlares/index" {
  46334. export * from "babylonjs/LensFlares/lensFlare";
  46335. export * from "babylonjs/LensFlares/lensFlareSystem";
  46336. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  46337. }
  46338. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  46339. import { Scene } from "babylonjs/scene";
  46340. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  46341. import { AbstractScene } from "babylonjs/abstractScene";
  46342. /**
  46343. * Defines the shadow generator component responsible to manage any shadow generators
  46344. * in a given scene.
  46345. */
  46346. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46347. /**
  46348. * The component name helpfull to identify the component in the list of scene components.
  46349. */
  46350. readonly name: string;
  46351. /**
  46352. * The scene the component belongs to.
  46353. */
  46354. scene: Scene;
  46355. /**
  46356. * Creates a new instance of the component for the given scene
  46357. * @param scene Defines the scene to register the component in
  46358. */
  46359. constructor(scene: Scene);
  46360. /**
  46361. * Registers the component in a given scene
  46362. */
  46363. register(): void;
  46364. /**
  46365. * Rebuilds the elements related to this component in case of
  46366. * context lost for instance.
  46367. */
  46368. rebuild(): void;
  46369. /**
  46370. * Serializes the component data to the specified json object
  46371. * @param serializationObject The object to serialize to
  46372. */
  46373. serialize(serializationObject: any): void;
  46374. /**
  46375. * Adds all the element from the container to the scene
  46376. * @param container the container holding the elements
  46377. */
  46378. addFromContainer(container: AbstractScene): void;
  46379. /**
  46380. * Removes all the elements in the container from the scene
  46381. * @param container contains the elements to remove
  46382. */
  46383. removeFromContainer(container: AbstractScene): void;
  46384. /**
  46385. * Rebuilds the elements related to this component in case of
  46386. * context lost for instance.
  46387. */
  46388. dispose(): void;
  46389. private _gatherRenderTargets;
  46390. }
  46391. }
  46392. declare module "babylonjs/Lights/Shadows/index" {
  46393. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  46394. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  46395. }
  46396. declare module "babylonjs/Lights/directionalLight" {
  46397. import { Camera } from "babylonjs/Cameras/camera";
  46398. import { Scene } from "babylonjs/scene";
  46399. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46401. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46402. import { Effect } from "babylonjs/Materials/effect";
  46403. /**
  46404. * A directional light is defined by a direction (what a surprise!).
  46405. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  46406. * 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.
  46407. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46408. */
  46409. export class DirectionalLight extends ShadowLight {
  46410. private _shadowFrustumSize;
  46411. /**
  46412. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  46413. */
  46414. /**
  46415. * Specifies a fix frustum size for the shadow generation.
  46416. */
  46417. shadowFrustumSize: number;
  46418. private _shadowOrthoScale;
  46419. /**
  46420. * Gets the shadow projection scale against the optimal computed one.
  46421. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46422. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46423. */
  46424. /**
  46425. * Sets the shadow projection scale against the optimal computed one.
  46426. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  46427. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  46428. */
  46429. shadowOrthoScale: number;
  46430. /**
  46431. * Automatically compute the projection matrix to best fit (including all the casters)
  46432. * on each frame.
  46433. */
  46434. autoUpdateExtends: boolean;
  46435. private _orthoLeft;
  46436. private _orthoRight;
  46437. private _orthoTop;
  46438. private _orthoBottom;
  46439. /**
  46440. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  46441. * The directional light is emitted from everywhere in the given direction.
  46442. * It can cast shadows.
  46443. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46444. * @param name The friendly name of the light
  46445. * @param direction The direction of the light
  46446. * @param scene The scene the light belongs to
  46447. */
  46448. constructor(name: string, direction: Vector3, scene: Scene);
  46449. /**
  46450. * Returns the string "DirectionalLight".
  46451. * @return The class name
  46452. */
  46453. getClassName(): string;
  46454. /**
  46455. * Returns the integer 1.
  46456. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46457. */
  46458. getTypeID(): number;
  46459. /**
  46460. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  46461. * Returns the DirectionalLight Shadow projection matrix.
  46462. */
  46463. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46464. /**
  46465. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  46466. * Returns the DirectionalLight Shadow projection matrix.
  46467. */
  46468. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  46469. /**
  46470. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  46471. * Returns the DirectionalLight Shadow projection matrix.
  46472. */
  46473. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46474. protected _buildUniformLayout(): void;
  46475. /**
  46476. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  46477. * @param effect The effect to update
  46478. * @param lightIndex The index of the light in the effect to update
  46479. * @returns The directional light
  46480. */
  46481. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  46482. /**
  46483. * Gets the minZ used for shadow according to both the scene and the light.
  46484. *
  46485. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46486. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46487. * @param activeCamera The camera we are returning the min for
  46488. * @returns the depth min z
  46489. */
  46490. getDepthMinZ(activeCamera: Camera): number;
  46491. /**
  46492. * Gets the maxZ used for shadow according to both the scene and the light.
  46493. *
  46494. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  46495. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  46496. * @param activeCamera The camera we are returning the max for
  46497. * @returns the depth max z
  46498. */
  46499. getDepthMaxZ(activeCamera: Camera): number;
  46500. /**
  46501. * Prepares the list of defines specific to the light type.
  46502. * @param defines the list of defines
  46503. * @param lightIndex defines the index of the light for the effect
  46504. */
  46505. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46506. }
  46507. }
  46508. declare module "babylonjs/Lights/pointLight" {
  46509. import { Scene } from "babylonjs/scene";
  46510. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46511. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46512. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46513. import { Effect } from "babylonjs/Materials/effect";
  46514. /**
  46515. * A point light is a light defined by an unique point in world space.
  46516. * The light is emitted in every direction from this point.
  46517. * A good example of a point light is a standard light bulb.
  46518. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46519. */
  46520. export class PointLight extends ShadowLight {
  46521. private _shadowAngle;
  46522. /**
  46523. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46524. * This specifies what angle the shadow will use to be created.
  46525. *
  46526. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46527. */
  46528. /**
  46529. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46530. * This specifies what angle the shadow will use to be created.
  46531. *
  46532. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46533. */
  46534. shadowAngle: number;
  46535. /**
  46536. * Gets the direction if it has been set.
  46537. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46538. */
  46539. /**
  46540. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46541. */
  46542. direction: Vector3;
  46543. /**
  46544. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46545. * A PointLight emits the light in every direction.
  46546. * It can cast shadows.
  46547. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46548. * ```javascript
  46549. * var pointLight = new PointLight("pl", camera.position, scene);
  46550. * ```
  46551. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46552. * @param name The light friendly name
  46553. * @param position The position of the point light in the scene
  46554. * @param scene The scene the lights belongs to
  46555. */
  46556. constructor(name: string, position: Vector3, scene: Scene);
  46557. /**
  46558. * Returns the string "PointLight"
  46559. * @returns the class name
  46560. */
  46561. getClassName(): string;
  46562. /**
  46563. * Returns the integer 0.
  46564. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46565. */
  46566. getTypeID(): number;
  46567. /**
  46568. * Specifies wether or not the shadowmap should be a cube texture.
  46569. * @returns true if the shadowmap needs to be a cube texture.
  46570. */
  46571. needCube(): boolean;
  46572. /**
  46573. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46574. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46575. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46576. */
  46577. getShadowDirection(faceIndex?: number): Vector3;
  46578. /**
  46579. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46580. * - fov = PI / 2
  46581. * - aspect ratio : 1.0
  46582. * - z-near and far equal to the active camera minZ and maxZ.
  46583. * Returns the PointLight.
  46584. */
  46585. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46586. protected _buildUniformLayout(): void;
  46587. /**
  46588. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46589. * @param effect The effect to update
  46590. * @param lightIndex The index of the light in the effect to update
  46591. * @returns The point light
  46592. */
  46593. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46594. /**
  46595. * Prepares the list of defines specific to the light type.
  46596. * @param defines the list of defines
  46597. * @param lightIndex defines the index of the light for the effect
  46598. */
  46599. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46600. }
  46601. }
  46602. declare module "babylonjs/Lights/spotLight" {
  46603. import { Nullable } from "babylonjs/types";
  46604. import { Scene } from "babylonjs/scene";
  46605. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46607. import { Effect } from "babylonjs/Materials/effect";
  46608. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46609. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  46610. /**
  46611. * A spot light is defined by a position, a direction, an angle, and an exponent.
  46612. * These values define a cone of light starting from the position, emitting toward the direction.
  46613. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  46614. * and the exponent defines the speed of the decay of the light with distance (reach).
  46615. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46616. */
  46617. export class SpotLight extends ShadowLight {
  46618. private _angle;
  46619. private _innerAngle;
  46620. private _cosHalfAngle;
  46621. private _lightAngleScale;
  46622. private _lightAngleOffset;
  46623. /**
  46624. * Gets the cone angle of the spot light in Radians.
  46625. */
  46626. /**
  46627. * Sets the cone angle of the spot light in Radians.
  46628. */
  46629. angle: number;
  46630. /**
  46631. * Only used in gltf falloff mode, this defines the angle where
  46632. * the directional falloff will start before cutting at angle which could be seen
  46633. * as outer angle.
  46634. */
  46635. /**
  46636. * Only used in gltf falloff mode, this defines the angle where
  46637. * the directional falloff will start before cutting at angle which could be seen
  46638. * as outer angle.
  46639. */
  46640. innerAngle: number;
  46641. private _shadowAngleScale;
  46642. /**
  46643. * Allows scaling the angle of the light for shadow generation only.
  46644. */
  46645. /**
  46646. * Allows scaling the angle of the light for shadow generation only.
  46647. */
  46648. shadowAngleScale: number;
  46649. /**
  46650. * The light decay speed with the distance from the emission spot.
  46651. */
  46652. exponent: number;
  46653. private _projectionTextureMatrix;
  46654. /**
  46655. * Allows reading the projecton texture
  46656. */
  46657. readonly projectionTextureMatrix: Matrix;
  46658. protected _projectionTextureLightNear: number;
  46659. /**
  46660. * Gets the near clip of the Spotlight for texture projection.
  46661. */
  46662. /**
  46663. * Sets the near clip of the Spotlight for texture projection.
  46664. */
  46665. projectionTextureLightNear: number;
  46666. protected _projectionTextureLightFar: number;
  46667. /**
  46668. * Gets the far clip of the Spotlight for texture projection.
  46669. */
  46670. /**
  46671. * Sets the far clip of the Spotlight for texture projection.
  46672. */
  46673. projectionTextureLightFar: number;
  46674. protected _projectionTextureUpDirection: Vector3;
  46675. /**
  46676. * Gets the Up vector of the Spotlight for texture projection.
  46677. */
  46678. /**
  46679. * Sets the Up vector of the Spotlight for texture projection.
  46680. */
  46681. projectionTextureUpDirection: Vector3;
  46682. private _projectionTexture;
  46683. /**
  46684. * Gets the projection texture of the light.
  46685. */
  46686. /**
  46687. * Sets the projection texture of the light.
  46688. */
  46689. projectionTexture: Nullable<BaseTexture>;
  46690. private _projectionTextureViewLightDirty;
  46691. private _projectionTextureProjectionLightDirty;
  46692. private _projectionTextureDirty;
  46693. private _projectionTextureViewTargetVector;
  46694. private _projectionTextureViewLightMatrix;
  46695. private _projectionTextureProjectionLightMatrix;
  46696. private _projectionTextureScalingMatrix;
  46697. /**
  46698. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  46699. * It can cast shadows.
  46700. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46701. * @param name The light friendly name
  46702. * @param position The position of the spot light in the scene
  46703. * @param direction The direction of the light in the scene
  46704. * @param angle The cone angle of the light in Radians
  46705. * @param exponent The light decay speed with the distance from the emission spot
  46706. * @param scene The scene the lights belongs to
  46707. */
  46708. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  46709. /**
  46710. * Returns the string "SpotLight".
  46711. * @returns the class name
  46712. */
  46713. getClassName(): string;
  46714. /**
  46715. * Returns the integer 2.
  46716. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46717. */
  46718. getTypeID(): number;
  46719. /**
  46720. * Overrides the direction setter to recompute the projection texture view light Matrix.
  46721. */
  46722. protected _setDirection(value: Vector3): void;
  46723. /**
  46724. * Overrides the position setter to recompute the projection texture view light Matrix.
  46725. */
  46726. protected _setPosition(value: Vector3): void;
  46727. /**
  46728. * 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.
  46729. * Returns the SpotLight.
  46730. */
  46731. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46732. protected _computeProjectionTextureViewLightMatrix(): void;
  46733. protected _computeProjectionTextureProjectionLightMatrix(): void;
  46734. /**
  46735. * Main function for light texture projection matrix computing.
  46736. */
  46737. protected _computeProjectionTextureMatrix(): void;
  46738. protected _buildUniformLayout(): void;
  46739. private _computeAngleValues;
  46740. /**
  46741. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  46742. * @param effect The effect to update
  46743. * @param lightIndex The index of the light in the effect to update
  46744. * @returns The spot light
  46745. */
  46746. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  46747. /**
  46748. * Disposes the light and the associated resources.
  46749. */
  46750. dispose(): void;
  46751. /**
  46752. * Prepares the list of defines specific to the light type.
  46753. * @param defines the list of defines
  46754. * @param lightIndex defines the index of the light for the effect
  46755. */
  46756. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46757. }
  46758. }
  46759. declare module "babylonjs/Lights/index" {
  46760. export * from "babylonjs/Lights/light";
  46761. export * from "babylonjs/Lights/shadowLight";
  46762. export * from "babylonjs/Lights/Shadows/index";
  46763. export * from "babylonjs/Lights/directionalLight";
  46764. export * from "babylonjs/Lights/hemisphericLight";
  46765. export * from "babylonjs/Lights/pointLight";
  46766. export * from "babylonjs/Lights/spotLight";
  46767. }
  46768. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  46769. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46770. /**
  46771. * Header information of HDR texture files.
  46772. */
  46773. export interface HDRInfo {
  46774. /**
  46775. * The height of the texture in pixels.
  46776. */
  46777. height: number;
  46778. /**
  46779. * The width of the texture in pixels.
  46780. */
  46781. width: number;
  46782. /**
  46783. * The index of the beginning of the data in the binary file.
  46784. */
  46785. dataPosition: number;
  46786. }
  46787. /**
  46788. * This groups tools to convert HDR texture to native colors array.
  46789. */
  46790. export class HDRTools {
  46791. private static Ldexp;
  46792. private static Rgbe2float;
  46793. private static readStringLine;
  46794. /**
  46795. * Reads header information from an RGBE texture stored in a native array.
  46796. * More information on this format are available here:
  46797. * https://en.wikipedia.org/wiki/RGBE_image_format
  46798. *
  46799. * @param uint8array The binary file stored in native array.
  46800. * @return The header information.
  46801. */
  46802. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46803. /**
  46804. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46805. * This RGBE texture needs to store the information as a panorama.
  46806. *
  46807. * More information on this format are available here:
  46808. * https://en.wikipedia.org/wiki/RGBE_image_format
  46809. *
  46810. * @param buffer The binary file stored in an array buffer.
  46811. * @param size The expected size of the extracted cubemap.
  46812. * @return The Cube Map information.
  46813. */
  46814. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46815. /**
  46816. * Returns the pixels data extracted from an RGBE texture.
  46817. * This pixels will be stored left to right up to down in the R G B order in one array.
  46818. *
  46819. * More information on this format are available here:
  46820. * https://en.wikipedia.org/wiki/RGBE_image_format
  46821. *
  46822. * @param uint8array The binary file stored in an array buffer.
  46823. * @param hdrInfo The header information of the file.
  46824. * @return The pixels data in RGB right to left up to down order.
  46825. */
  46826. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46827. private static RGBE_ReadPixels_RLE;
  46828. }
  46829. }
  46830. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  46831. import { Nullable } from "babylonjs/types";
  46832. import { Scene } from "babylonjs/scene";
  46833. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  46834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46835. /**
  46836. * This represents a texture coming from an HDR input.
  46837. *
  46838. * The only supported format is currently panorama picture stored in RGBE format.
  46839. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46840. */
  46841. export class HDRCubeTexture extends BaseTexture {
  46842. private static _facesMapping;
  46843. private _generateHarmonics;
  46844. private _noMipmap;
  46845. private _textureMatrix;
  46846. private _size;
  46847. private _onLoad;
  46848. private _onError;
  46849. /**
  46850. * The texture URL.
  46851. */
  46852. url: string;
  46853. /**
  46854. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46855. */
  46856. coordinatesMode: number;
  46857. protected _isBlocking: boolean;
  46858. /**
  46859. * Sets wether or not the texture is blocking during loading.
  46860. */
  46861. /**
  46862. * Gets wether or not the texture is blocking during loading.
  46863. */
  46864. isBlocking: boolean;
  46865. protected _rotationY: number;
  46866. /**
  46867. * Sets texture matrix rotation angle around Y axis in radians.
  46868. */
  46869. /**
  46870. * Gets texture matrix rotation angle around Y axis radians.
  46871. */
  46872. rotationY: number;
  46873. /**
  46874. * Gets or sets the center of the bounding box associated with the cube texture
  46875. * It must define where the camera used to render the texture was set
  46876. */
  46877. boundingBoxPosition: Vector3;
  46878. private _boundingBoxSize;
  46879. /**
  46880. * Gets or sets the size of the bounding box associated with the cube texture
  46881. * When defined, the cubemap will switch to local mode
  46882. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46883. * @example https://www.babylonjs-playground.com/#RNASML
  46884. */
  46885. boundingBoxSize: Vector3;
  46886. /**
  46887. * Instantiates an HDRTexture from the following parameters.
  46888. *
  46889. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46890. * @param scene The scene the texture will be used in
  46891. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46892. * @param noMipmap Forces to not generate the mipmap if true
  46893. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46894. * @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)
  46895. * @param reserved Reserved flag for internal use.
  46896. */
  46897. 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>);
  46898. /**
  46899. * Get the current class name of the texture useful for serialization or dynamic coding.
  46900. * @returns "HDRCubeTexture"
  46901. */
  46902. getClassName(): string;
  46903. /**
  46904. * Occurs when the file is raw .hdr file.
  46905. */
  46906. private loadTexture;
  46907. clone(): HDRCubeTexture;
  46908. delayLoad(): void;
  46909. /**
  46910. * Get the texture reflection matrix used to rotate/transform the reflection.
  46911. * @returns the reflection matrix
  46912. */
  46913. getReflectionTextureMatrix(): Matrix;
  46914. /**
  46915. * Set the texture reflection matrix used to rotate/transform the reflection.
  46916. * @param value Define the reflection matrix to set
  46917. */
  46918. setReflectionTextureMatrix(value: Matrix): void;
  46919. /**
  46920. * Parses a JSON representation of an HDR Texture in order to create the texture
  46921. * @param parsedTexture Define the JSON representation
  46922. * @param scene Define the scene the texture should be created in
  46923. * @param rootUrl Define the root url in case we need to load relative dependencies
  46924. * @returns the newly created texture after parsing
  46925. */
  46926. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46927. serialize(): any;
  46928. }
  46929. }
  46930. declare module "babylonjs/Physics/physicsEngine" {
  46931. import { Nullable } from "babylonjs/types";
  46932. import { Vector3 } from "babylonjs/Maths/math";
  46933. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  46934. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  46935. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  46936. /**
  46937. * Class used to control physics engine
  46938. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  46939. */
  46940. export class PhysicsEngine implements IPhysicsEngine {
  46941. private _physicsPlugin;
  46942. /**
  46943. * Global value used to control the smallest number supported by the simulation
  46944. */
  46945. static Epsilon: number;
  46946. private _impostors;
  46947. private _joints;
  46948. /**
  46949. * Gets the gravity vector used by the simulation
  46950. */
  46951. gravity: Vector3;
  46952. /**
  46953. * Factory used to create the default physics plugin.
  46954. * @returns The default physics plugin
  46955. */
  46956. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  46957. /**
  46958. * Creates a new Physics Engine
  46959. * @param gravity defines the gravity vector used by the simulation
  46960. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  46961. */
  46962. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  46963. /**
  46964. * Sets the gravity vector used by the simulation
  46965. * @param gravity defines the gravity vector to use
  46966. */
  46967. setGravity(gravity: Vector3): void;
  46968. /**
  46969. * Set the time step of the physics engine.
  46970. * Default is 1/60.
  46971. * To slow it down, enter 1/600 for example.
  46972. * To speed it up, 1/30
  46973. * @param newTimeStep defines the new timestep to apply to this world.
  46974. */
  46975. setTimeStep(newTimeStep?: number): void;
  46976. /**
  46977. * Get the time step of the physics engine.
  46978. * @returns the current time step
  46979. */
  46980. getTimeStep(): number;
  46981. /**
  46982. * Release all resources
  46983. */
  46984. dispose(): void;
  46985. /**
  46986. * Gets the name of the current physics plugin
  46987. * @returns the name of the plugin
  46988. */
  46989. getPhysicsPluginName(): string;
  46990. /**
  46991. * Adding a new impostor for the impostor tracking.
  46992. * This will be done by the impostor itself.
  46993. * @param impostor the impostor to add
  46994. */
  46995. addImpostor(impostor: PhysicsImpostor): void;
  46996. /**
  46997. * Remove an impostor from the engine.
  46998. * This impostor and its mesh will not longer be updated by the physics engine.
  46999. * @param impostor the impostor to remove
  47000. */
  47001. removeImpostor(impostor: PhysicsImpostor): void;
  47002. /**
  47003. * Add a joint to the physics engine
  47004. * @param mainImpostor defines the main impostor to which the joint is added.
  47005. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47006. * @param joint defines the joint that will connect both impostors.
  47007. */
  47008. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47009. /**
  47010. * Removes a joint from the simulation
  47011. * @param mainImpostor defines the impostor used with the joint
  47012. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47013. * @param joint defines the joint to remove
  47014. */
  47015. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47016. /**
  47017. * Called by the scene. No need to call it.
  47018. * @param delta defines the timespam between frames
  47019. */
  47020. _step(delta: number): void;
  47021. /**
  47022. * Gets the current plugin used to run the simulation
  47023. * @returns current plugin
  47024. */
  47025. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47026. /**
  47027. * Gets the list of physic impostors
  47028. * @returns an array of PhysicsImpostor
  47029. */
  47030. getImpostors(): Array<PhysicsImpostor>;
  47031. /**
  47032. * Gets the impostor for a physics enabled object
  47033. * @param object defines the object impersonated by the impostor
  47034. * @returns the PhysicsImpostor or null if not found
  47035. */
  47036. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47037. /**
  47038. * Gets the impostor for a physics body object
  47039. * @param body defines physics body used by the impostor
  47040. * @returns the PhysicsImpostor or null if not found
  47041. */
  47042. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47043. }
  47044. }
  47045. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  47046. import { Nullable } from "babylonjs/types";
  47047. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47049. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47050. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47051. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47052. /** @hidden */
  47053. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47054. private _useDeltaForWorldStep;
  47055. world: any;
  47056. name: string;
  47057. private _physicsMaterials;
  47058. private _fixedTimeStep;
  47059. BJSCANNON: any;
  47060. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47061. setGravity(gravity: Vector3): void;
  47062. setTimeStep(timeStep: number): void;
  47063. getTimeStep(): number;
  47064. executeStep(delta: number): void;
  47065. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47066. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47067. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47068. private _processChildMeshes;
  47069. removePhysicsBody(impostor: PhysicsImpostor): void;
  47070. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47071. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47072. private _addMaterial;
  47073. private _checkWithEpsilon;
  47074. private _createShape;
  47075. private _createHeightmap;
  47076. private _minus90X;
  47077. private _plus90X;
  47078. private _tmpPosition;
  47079. private _tmpDeltaPosition;
  47080. private _tmpUnityRotation;
  47081. private _updatePhysicsBodyTransformation;
  47082. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47083. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47084. isSupported(): boolean;
  47085. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47086. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47087. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47088. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47089. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47090. getBodyMass(impostor: PhysicsImpostor): number;
  47091. getBodyFriction(impostor: PhysicsImpostor): number;
  47092. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47093. getBodyRestitution(impostor: PhysicsImpostor): number;
  47094. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47095. sleepBody(impostor: PhysicsImpostor): void;
  47096. wakeUpBody(impostor: PhysicsImpostor): void;
  47097. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47098. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47099. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47100. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47101. getRadius(impostor: PhysicsImpostor): number;
  47102. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47103. dispose(): void;
  47104. private _extendNamespace;
  47105. }
  47106. }
  47107. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  47108. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  47109. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47110. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  47111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47112. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  47113. import { Nullable } from "babylonjs/types";
  47114. /** @hidden */
  47115. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47116. world: any;
  47117. name: string;
  47118. BJSOIMO: any;
  47119. constructor(iterations?: number, oimoInjection?: any);
  47120. setGravity(gravity: Vector3): void;
  47121. setTimeStep(timeStep: number): void;
  47122. getTimeStep(): number;
  47123. private _tmpImpostorsArray;
  47124. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47125. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47127. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47128. private _tmpPositionVector;
  47129. removePhysicsBody(impostor: PhysicsImpostor): void;
  47130. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47131. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47132. isSupported(): boolean;
  47133. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47134. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47135. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47136. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47137. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47138. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47139. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47140. getBodyMass(impostor: PhysicsImpostor): number;
  47141. getBodyFriction(impostor: PhysicsImpostor): number;
  47142. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47143. getBodyRestitution(impostor: PhysicsImpostor): number;
  47144. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47145. sleepBody(impostor: PhysicsImpostor): void;
  47146. wakeUpBody(impostor: PhysicsImpostor): void;
  47147. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47148. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  47149. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47150. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47151. getRadius(impostor: PhysicsImpostor): number;
  47152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47153. dispose(): void;
  47154. }
  47155. }
  47156. declare module "babylonjs/Probes/reflectionProbe" {
  47157. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47158. import { Vector3 } from "babylonjs/Maths/math";
  47159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47160. import { Nullable } from "babylonjs/types";
  47161. import { Scene } from "babylonjs/scene";
  47162. module "babylonjs/abstractScene" {
  47163. interface AbstractScene {
  47164. /**
  47165. * The list of reflection probes added to the scene
  47166. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47167. */
  47168. reflectionProbes: Array<ReflectionProbe>;
  47169. /**
  47170. * Removes the given reflection probe from this scene.
  47171. * @param toRemove The reflection probe to remove
  47172. * @returns The index of the removed reflection probe
  47173. */
  47174. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47175. /**
  47176. * Adds the given reflection probe to this scene.
  47177. * @param newReflectionProbe The reflection probe to add
  47178. */
  47179. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47180. }
  47181. }
  47182. /**
  47183. * Class used to generate realtime reflection / refraction cube textures
  47184. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47185. */
  47186. export class ReflectionProbe {
  47187. /** defines the name of the probe */
  47188. name: string;
  47189. private _scene;
  47190. private _renderTargetTexture;
  47191. private _projectionMatrix;
  47192. private _viewMatrix;
  47193. private _target;
  47194. private _add;
  47195. private _attachedMesh;
  47196. private _invertYAxis;
  47197. /** Gets or sets probe position (center of the cube map) */
  47198. position: Vector3;
  47199. /**
  47200. * Creates a new reflection probe
  47201. * @param name defines the name of the probe
  47202. * @param size defines the texture resolution (for each face)
  47203. * @param scene defines the hosting scene
  47204. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47205. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47206. */
  47207. constructor(
  47208. /** defines the name of the probe */
  47209. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47210. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47211. samples: number;
  47212. /** Gets or sets the refresh rate to use (on every frame by default) */
  47213. refreshRate: number;
  47214. /**
  47215. * Gets the hosting scene
  47216. * @returns a Scene
  47217. */
  47218. getScene(): Scene;
  47219. /** Gets the internal CubeTexture used to render to */
  47220. readonly cubeTexture: RenderTargetTexture;
  47221. /** Gets the list of meshes to render */
  47222. readonly renderList: Nullable<AbstractMesh[]>;
  47223. /**
  47224. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47225. * @param mesh defines the mesh to attach to
  47226. */
  47227. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47228. /**
  47229. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47230. * @param renderingGroupId The rendering group id corresponding to its index
  47231. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47232. */
  47233. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47234. /**
  47235. * Clean all associated resources
  47236. */
  47237. dispose(): void;
  47238. /**
  47239. * Converts the reflection probe information to a readable string for debug purpose.
  47240. * @param fullDetails Supports for multiple levels of logging within scene loading
  47241. * @returns the human readable reflection probe info
  47242. */
  47243. toString(fullDetails?: boolean): string;
  47244. /**
  47245. * Get the class name of the relfection probe.
  47246. * @returns "ReflectionProbe"
  47247. */
  47248. getClassName(): string;
  47249. /**
  47250. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47251. * @returns The JSON representation of the texture
  47252. */
  47253. serialize(): any;
  47254. /**
  47255. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47256. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47257. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47258. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47259. * @returns The parsed reflection probe if successful
  47260. */
  47261. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47262. }
  47263. }
  47264. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  47265. /** @hidden */
  47266. export var _BabylonLoaderRegistered: boolean;
  47267. }
  47268. declare module "babylonjs/Loading/Plugins/index" {
  47269. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  47270. }
  47271. declare module "babylonjs/Loading/index" {
  47272. export * from "babylonjs/Loading/loadingScreen";
  47273. export * from "babylonjs/Loading/Plugins/index";
  47274. export * from "babylonjs/Loading/sceneLoader";
  47275. export * from "babylonjs/Loading/sceneLoaderFlags";
  47276. }
  47277. declare module "babylonjs/Materials/Background/index" {
  47278. export * from "babylonjs/Materials/Background/backgroundMaterial";
  47279. }
  47280. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  47281. import { Scene } from "babylonjs/scene";
  47282. import { Color3 } from "babylonjs/Maths/math";
  47283. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47284. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47285. /**
  47286. * The Physically based simple base material of BJS.
  47287. *
  47288. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47289. * It is used as the base class for both the specGloss and metalRough conventions.
  47290. */
  47291. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47292. /**
  47293. * Number of Simultaneous lights allowed on the material.
  47294. */
  47295. maxSimultaneousLights: number;
  47296. /**
  47297. * If sets to true, disables all the lights affecting the material.
  47298. */
  47299. disableLighting: boolean;
  47300. /**
  47301. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47302. */
  47303. environmentTexture: BaseTexture;
  47304. /**
  47305. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47306. */
  47307. invertNormalMapX: boolean;
  47308. /**
  47309. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47310. */
  47311. invertNormalMapY: boolean;
  47312. /**
  47313. * Normal map used in the model.
  47314. */
  47315. normalTexture: BaseTexture;
  47316. /**
  47317. * Emissivie color used to self-illuminate the model.
  47318. */
  47319. emissiveColor: Color3;
  47320. /**
  47321. * Emissivie texture used to self-illuminate the model.
  47322. */
  47323. emissiveTexture: BaseTexture;
  47324. /**
  47325. * Occlusion Channel Strenght.
  47326. */
  47327. occlusionStrength: number;
  47328. /**
  47329. * Occlusion Texture of the material (adding extra occlusion effects).
  47330. */
  47331. occlusionTexture: BaseTexture;
  47332. /**
  47333. * Defines the alpha limits in alpha test mode.
  47334. */
  47335. alphaCutOff: number;
  47336. /**
  47337. * Gets the current double sided mode.
  47338. */
  47339. /**
  47340. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47341. */
  47342. doubleSided: boolean;
  47343. /**
  47344. * Stores the pre-calculated light information of a mesh in a texture.
  47345. */
  47346. lightmapTexture: BaseTexture;
  47347. /**
  47348. * If true, the light map contains occlusion information instead of lighting info.
  47349. */
  47350. useLightmapAsShadowmap: boolean;
  47351. /**
  47352. * Return the active textures of the material.
  47353. */
  47354. getActiveTextures(): BaseTexture[];
  47355. hasTexture(texture: BaseTexture): boolean;
  47356. /**
  47357. * Instantiates a new PBRMaterial instance.
  47358. *
  47359. * @param name The material name
  47360. * @param scene The scene the material will be use in.
  47361. */
  47362. constructor(name: string, scene: Scene);
  47363. getClassName(): string;
  47364. }
  47365. }
  47366. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  47367. import { Scene } from "babylonjs/scene";
  47368. import { Color3 } from "babylonjs/Maths/math";
  47369. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47370. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47371. /**
  47372. * The PBR material of BJS following the metal roughness convention.
  47373. *
  47374. * This fits to the PBR convention in the GLTF definition:
  47375. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47376. */
  47377. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47378. /**
  47379. * The base color has two different interpretations depending on the value of metalness.
  47380. * When the material is a metal, the base color is the specific measured reflectance value
  47381. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47382. * of the material.
  47383. */
  47384. baseColor: Color3;
  47385. /**
  47386. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47387. * well as opacity information in the alpha channel.
  47388. */
  47389. baseTexture: BaseTexture;
  47390. /**
  47391. * Specifies the metallic scalar value of the material.
  47392. * Can also be used to scale the metalness values of the metallic texture.
  47393. */
  47394. metallic: number;
  47395. /**
  47396. * Specifies the roughness scalar value of the material.
  47397. * Can also be used to scale the roughness values of the metallic texture.
  47398. */
  47399. roughness: number;
  47400. /**
  47401. * Texture containing both the metallic value in the B channel and the
  47402. * roughness value in the G channel to keep better precision.
  47403. */
  47404. metallicRoughnessTexture: BaseTexture;
  47405. /**
  47406. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47407. *
  47408. * @param name The material name
  47409. * @param scene The scene the material will be use in.
  47410. */
  47411. constructor(name: string, scene: Scene);
  47412. /**
  47413. * Return the currrent class name of the material.
  47414. */
  47415. getClassName(): string;
  47416. /**
  47417. * Return the active textures of the material.
  47418. */
  47419. getActiveTextures(): BaseTexture[];
  47420. /**
  47421. * Checks to see if a texture is used in the material.
  47422. * @param texture - Base texture to use.
  47423. * @returns - Boolean specifying if a texture is used in the material.
  47424. */
  47425. hasTexture(texture: BaseTexture): boolean;
  47426. /**
  47427. * Makes a duplicate of the current material.
  47428. * @param name - name to use for the new material.
  47429. */
  47430. clone(name: string): PBRMetallicRoughnessMaterial;
  47431. /**
  47432. * Serialize the material to a parsable JSON object.
  47433. */
  47434. serialize(): any;
  47435. /**
  47436. * Parses a JSON object correponding to the serialize function.
  47437. */
  47438. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47439. }
  47440. }
  47441. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  47442. import { Scene } from "babylonjs/scene";
  47443. import { Color3 } from "babylonjs/Maths/math";
  47444. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47445. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47446. /**
  47447. * The PBR material of BJS following the specular glossiness convention.
  47448. *
  47449. * This fits to the PBR convention in the GLTF definition:
  47450. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47451. */
  47452. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47453. /**
  47454. * Specifies the diffuse color of the material.
  47455. */
  47456. diffuseColor: Color3;
  47457. /**
  47458. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47459. * channel.
  47460. */
  47461. diffuseTexture: BaseTexture;
  47462. /**
  47463. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47464. */
  47465. specularColor: Color3;
  47466. /**
  47467. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47468. */
  47469. glossiness: number;
  47470. /**
  47471. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47472. */
  47473. specularGlossinessTexture: BaseTexture;
  47474. /**
  47475. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47476. *
  47477. * @param name The material name
  47478. * @param scene The scene the material will be use in.
  47479. */
  47480. constructor(name: string, scene: Scene);
  47481. /**
  47482. * Return the currrent class name of the material.
  47483. */
  47484. getClassName(): string;
  47485. /**
  47486. * Return the active textures of the material.
  47487. */
  47488. getActiveTextures(): BaseTexture[];
  47489. /**
  47490. * Checks to see if a texture is used in the material.
  47491. * @param texture - Base texture to use.
  47492. * @returns - Boolean specifying if a texture is used in the material.
  47493. */
  47494. hasTexture(texture: BaseTexture): boolean;
  47495. /**
  47496. * Makes a duplicate of the current material.
  47497. * @param name - name to use for the new material.
  47498. */
  47499. clone(name: string): PBRSpecularGlossinessMaterial;
  47500. /**
  47501. * Serialize the material to a parsable JSON object.
  47502. */
  47503. serialize(): any;
  47504. /**
  47505. * Parses a JSON object correponding to the serialize function.
  47506. */
  47507. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47508. }
  47509. }
  47510. declare module "babylonjs/Materials/PBR/index" {
  47511. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47512. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  47513. export * from "babylonjs/Materials/PBR/pbrMaterial";
  47514. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  47515. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  47516. }
  47517. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  47518. import { Nullable } from "babylonjs/types";
  47519. import { Scene } from "babylonjs/scene";
  47520. import { Matrix } from "babylonjs/Maths/math";
  47521. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47522. /**
  47523. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47524. * It can help converting any input color in a desired output one. This can then be used to create effects
  47525. * from sepia, black and white to sixties or futuristic rendering...
  47526. *
  47527. * The only supported format is currently 3dl.
  47528. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47529. */
  47530. export class ColorGradingTexture extends BaseTexture {
  47531. /**
  47532. * The current texture matrix. (will always be identity in color grading texture)
  47533. */
  47534. private _textureMatrix;
  47535. /**
  47536. * The texture URL.
  47537. */
  47538. url: string;
  47539. /**
  47540. * Empty line regex stored for GC.
  47541. */
  47542. private static _noneEmptyLineRegex;
  47543. private _engine;
  47544. /**
  47545. * Instantiates a ColorGradingTexture from the following parameters.
  47546. *
  47547. * @param url The location of the color gradind data (currently only supporting 3dl)
  47548. * @param scene The scene the texture will be used in
  47549. */
  47550. constructor(url: string, scene: Scene);
  47551. /**
  47552. * Returns the texture matrix used in most of the material.
  47553. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47554. */
  47555. getTextureMatrix(): Matrix;
  47556. /**
  47557. * Occurs when the file being loaded is a .3dl LUT file.
  47558. */
  47559. private load3dlTexture;
  47560. /**
  47561. * Starts the loading process of the texture.
  47562. */
  47563. private loadTexture;
  47564. /**
  47565. * Clones the color gradind texture.
  47566. */
  47567. clone(): ColorGradingTexture;
  47568. /**
  47569. * Called during delayed load for textures.
  47570. */
  47571. delayLoad(): void;
  47572. /**
  47573. * Parses a color grading texture serialized by Babylon.
  47574. * @param parsedTexture The texture information being parsedTexture
  47575. * @param scene The scene to load the texture in
  47576. * @param rootUrl The root url of the data assets to load
  47577. * @return A color gradind texture
  47578. */
  47579. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47580. /**
  47581. * Serializes the LUT texture to json format.
  47582. */
  47583. serialize(): any;
  47584. }
  47585. }
  47586. declare module "babylonjs/Misc/dds" {
  47587. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47588. import { Engine } from "babylonjs/Engines/engine";
  47589. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47590. import { Nullable } from "babylonjs/types";
  47591. import { Scene } from "babylonjs/scene";
  47592. /**
  47593. * Direct draw surface info
  47594. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47595. */
  47596. export interface DDSInfo {
  47597. /**
  47598. * Width of the texture
  47599. */
  47600. width: number;
  47601. /**
  47602. * Width of the texture
  47603. */
  47604. height: number;
  47605. /**
  47606. * Number of Mipmaps for the texture
  47607. * @see https://en.wikipedia.org/wiki/Mipmap
  47608. */
  47609. mipmapCount: number;
  47610. /**
  47611. * If the textures format is a known fourCC format
  47612. * @see https://www.fourcc.org/
  47613. */
  47614. isFourCC: boolean;
  47615. /**
  47616. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47617. */
  47618. isRGB: boolean;
  47619. /**
  47620. * If the texture is a lumincance format
  47621. */
  47622. isLuminance: boolean;
  47623. /**
  47624. * If this is a cube texture
  47625. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47626. */
  47627. isCube: boolean;
  47628. /**
  47629. * If the texture is a compressed format eg. FOURCC_DXT1
  47630. */
  47631. isCompressed: boolean;
  47632. /**
  47633. * The dxgiFormat of the texture
  47634. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47635. */
  47636. dxgiFormat: number;
  47637. /**
  47638. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47639. */
  47640. textureType: number;
  47641. /**
  47642. * Sphericle polynomial created for the dds texture
  47643. */
  47644. sphericalPolynomial?: SphericalPolynomial;
  47645. }
  47646. /**
  47647. * Class used to provide DDS decompression tools
  47648. */
  47649. export class DDSTools {
  47650. /**
  47651. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47652. */
  47653. static StoreLODInAlphaChannel: boolean;
  47654. /**
  47655. * Gets DDS information from an array buffer
  47656. * @param arrayBuffer defines the array buffer to read data from
  47657. * @returns the DDS information
  47658. */
  47659. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47660. private static _FloatView;
  47661. private static _Int32View;
  47662. private static _ToHalfFloat;
  47663. private static _FromHalfFloat;
  47664. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47665. private static _GetHalfFloatRGBAArrayBuffer;
  47666. private static _GetFloatRGBAArrayBuffer;
  47667. private static _GetFloatAsUIntRGBAArrayBuffer;
  47668. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47669. private static _GetRGBAArrayBuffer;
  47670. private static _ExtractLongWordOrder;
  47671. private static _GetRGBArrayBuffer;
  47672. private static _GetLuminanceArrayBuffer;
  47673. /**
  47674. * Uploads DDS Levels to a Babylon Texture
  47675. * @hidden
  47676. */
  47677. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47678. }
  47679. module "babylonjs/Engines/engine" {
  47680. interface Engine {
  47681. /**
  47682. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47683. * @param rootUrl defines the url where the file to load is located
  47684. * @param scene defines the current scene
  47685. * @param lodScale defines scale to apply to the mip map selection
  47686. * @param lodOffset defines offset to apply to the mip map selection
  47687. * @param onLoad defines an optional callback raised when the texture is loaded
  47688. * @param onError defines an optional callback raised if there is an issue to load the texture
  47689. * @param format defines the format of the data
  47690. * @param forcedExtension defines the extension to use to pick the right loader
  47691. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47692. * @returns the cube texture as an InternalTexture
  47693. */
  47694. 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;
  47695. }
  47696. }
  47697. }
  47698. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47699. import { Nullable } from "babylonjs/types";
  47700. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47701. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47702. /**
  47703. * Implementation of the DDS Texture Loader.
  47704. * @hidden
  47705. */
  47706. export class _DDSTextureLoader implements IInternalTextureLoader {
  47707. /**
  47708. * Defines wether the loader supports cascade loading the different faces.
  47709. */
  47710. readonly supportCascades: boolean;
  47711. /**
  47712. * This returns if the loader support the current file information.
  47713. * @param extension defines the file extension of the file being loaded
  47714. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47715. * @param fallback defines the fallback internal texture if any
  47716. * @param isBase64 defines whether the texture is encoded as a base64
  47717. * @param isBuffer defines whether the texture data are stored as a buffer
  47718. * @returns true if the loader can load the specified file
  47719. */
  47720. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47721. /**
  47722. * Transform the url before loading if required.
  47723. * @param rootUrl the url of the texture
  47724. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47725. * @returns the transformed texture
  47726. */
  47727. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47728. /**
  47729. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47730. * @param rootUrl the url of the texture
  47731. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47732. * @returns the fallback texture
  47733. */
  47734. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47735. /**
  47736. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47737. * @param data contains the texture data
  47738. * @param texture defines the BabylonJS internal texture
  47739. * @param createPolynomials will be true if polynomials have been requested
  47740. * @param onLoad defines the callback to trigger once the texture is ready
  47741. * @param onError defines the callback to trigger in case of error
  47742. */
  47743. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47744. /**
  47745. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47746. * @param data contains the texture data
  47747. * @param texture defines the BabylonJS internal texture
  47748. * @param callback defines the method to call once ready to upload
  47749. */
  47750. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47751. }
  47752. }
  47753. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47754. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47755. /** @hidden */
  47756. export var rgbdEncodePixelShader: {
  47757. name: string;
  47758. shader: string;
  47759. };
  47760. }
  47761. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  47762. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47763. /** @hidden */
  47764. export var rgbdDecodePixelShader: {
  47765. name: string;
  47766. shader: string;
  47767. };
  47768. }
  47769. declare module "babylonjs/Misc/environmentTextureTools" {
  47770. import { Nullable } from "babylonjs/types";
  47771. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47772. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47773. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47774. import "babylonjs/Shaders/rgbdEncode.fragment";
  47775. import "babylonjs/Shaders/rgbdDecode.fragment";
  47776. /**
  47777. * Raw texture data and descriptor sufficient for WebGL texture upload
  47778. */
  47779. export interface EnvironmentTextureInfo {
  47780. /**
  47781. * Version of the environment map
  47782. */
  47783. version: number;
  47784. /**
  47785. * Width of image
  47786. */
  47787. width: number;
  47788. /**
  47789. * Irradiance information stored in the file.
  47790. */
  47791. irradiance: any;
  47792. /**
  47793. * Specular information stored in the file.
  47794. */
  47795. specular: any;
  47796. }
  47797. /**
  47798. * Sets of helpers addressing the serialization and deserialization of environment texture
  47799. * stored in a BabylonJS env file.
  47800. * Those files are usually stored as .env files.
  47801. */
  47802. export class EnvironmentTextureTools {
  47803. /**
  47804. * Magic number identifying the env file.
  47805. */
  47806. private static _MagicBytes;
  47807. /**
  47808. * Gets the environment info from an env file.
  47809. * @param data The array buffer containing the .env bytes.
  47810. * @returns the environment file info (the json header) if successfully parsed.
  47811. */
  47812. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47813. /**
  47814. * Creates an environment texture from a loaded cube texture.
  47815. * @param texture defines the cube texture to convert in env file
  47816. * @return a promise containing the environment data if succesfull.
  47817. */
  47818. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47819. /**
  47820. * Creates a JSON representation of the spherical data.
  47821. * @param texture defines the texture containing the polynomials
  47822. * @return the JSON representation of the spherical info
  47823. */
  47824. private static _CreateEnvTextureIrradiance;
  47825. /**
  47826. * Uploads the texture info contained in the env file to the GPU.
  47827. * @param texture defines the internal texture to upload to
  47828. * @param arrayBuffer defines the buffer cotaining the data to load
  47829. * @param info defines the texture info retrieved through the GetEnvInfo method
  47830. * @returns a promise
  47831. */
  47832. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47833. /**
  47834. * Uploads the levels of image data to the GPU.
  47835. * @param texture defines the internal texture to upload to
  47836. * @param imageData defines the array buffer views of image data [mipmap][face]
  47837. * @returns a promise
  47838. */
  47839. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47840. /**
  47841. * Uploads spherical polynomials information to the texture.
  47842. * @param texture defines the texture we are trying to upload the information to
  47843. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47844. */
  47845. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47846. /** @hidden */
  47847. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47848. }
  47849. }
  47850. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47851. import { Nullable } from "babylonjs/types";
  47852. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47853. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47854. /**
  47855. * Implementation of the ENV Texture Loader.
  47856. * @hidden
  47857. */
  47858. export class _ENVTextureLoader implements IInternalTextureLoader {
  47859. /**
  47860. * Defines wether the loader supports cascade loading the different faces.
  47861. */
  47862. readonly supportCascades: boolean;
  47863. /**
  47864. * This returns if the loader support the current file information.
  47865. * @param extension defines the file extension of the file being loaded
  47866. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47867. * @param fallback defines the fallback internal texture if any
  47868. * @param isBase64 defines whether the texture is encoded as a base64
  47869. * @param isBuffer defines whether the texture data are stored as a buffer
  47870. * @returns true if the loader can load the specified file
  47871. */
  47872. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47873. /**
  47874. * Transform the url before loading if required.
  47875. * @param rootUrl the url of the texture
  47876. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47877. * @returns the transformed texture
  47878. */
  47879. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47880. /**
  47881. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47882. * @param rootUrl the url of the texture
  47883. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47884. * @returns the fallback texture
  47885. */
  47886. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47887. /**
  47888. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47889. * @param data contains the texture data
  47890. * @param texture defines the BabylonJS internal texture
  47891. * @param createPolynomials will be true if polynomials have been requested
  47892. * @param onLoad defines the callback to trigger once the texture is ready
  47893. * @param onError defines the callback to trigger in case of error
  47894. */
  47895. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47896. /**
  47897. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47898. * @param data contains the texture data
  47899. * @param texture defines the BabylonJS internal texture
  47900. * @param callback defines the method to call once ready to upload
  47901. */
  47902. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47903. }
  47904. }
  47905. declare module "babylonjs/Misc/khronosTextureContainer" {
  47906. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47907. /**
  47908. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47909. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47910. */
  47911. export class KhronosTextureContainer {
  47912. /** contents of the KTX container file */
  47913. arrayBuffer: any;
  47914. private static HEADER_LEN;
  47915. private static COMPRESSED_2D;
  47916. private static COMPRESSED_3D;
  47917. private static TEX_2D;
  47918. private static TEX_3D;
  47919. /**
  47920. * Gets the openGL type
  47921. */
  47922. glType: number;
  47923. /**
  47924. * Gets the openGL type size
  47925. */
  47926. glTypeSize: number;
  47927. /**
  47928. * Gets the openGL format
  47929. */
  47930. glFormat: number;
  47931. /**
  47932. * Gets the openGL internal format
  47933. */
  47934. glInternalFormat: number;
  47935. /**
  47936. * Gets the base internal format
  47937. */
  47938. glBaseInternalFormat: number;
  47939. /**
  47940. * Gets image width in pixel
  47941. */
  47942. pixelWidth: number;
  47943. /**
  47944. * Gets image height in pixel
  47945. */
  47946. pixelHeight: number;
  47947. /**
  47948. * Gets image depth in pixels
  47949. */
  47950. pixelDepth: number;
  47951. /**
  47952. * Gets the number of array elements
  47953. */
  47954. numberOfArrayElements: number;
  47955. /**
  47956. * Gets the number of faces
  47957. */
  47958. numberOfFaces: number;
  47959. /**
  47960. * Gets the number of mipmap levels
  47961. */
  47962. numberOfMipmapLevels: number;
  47963. /**
  47964. * Gets the bytes of key value data
  47965. */
  47966. bytesOfKeyValueData: number;
  47967. /**
  47968. * Gets the load type
  47969. */
  47970. loadType: number;
  47971. /**
  47972. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47973. */
  47974. isInvalid: boolean;
  47975. /**
  47976. * Creates a new KhronosTextureContainer
  47977. * @param arrayBuffer contents of the KTX container file
  47978. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47979. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47980. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47981. */
  47982. constructor(
  47983. /** contents of the KTX container file */
  47984. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47985. /**
  47986. * Uploads KTX content to a Babylon Texture.
  47987. * It is assumed that the texture has already been created & is currently bound
  47988. * @hidden
  47989. */
  47990. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47991. private _upload2DCompressedLevels;
  47992. }
  47993. }
  47994. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47995. import { Nullable } from "babylonjs/types";
  47996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47997. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47998. /**
  47999. * Implementation of the KTX Texture Loader.
  48000. * @hidden
  48001. */
  48002. export class _KTXTextureLoader implements IInternalTextureLoader {
  48003. /**
  48004. * Defines wether the loader supports cascade loading the different faces.
  48005. */
  48006. readonly supportCascades: boolean;
  48007. /**
  48008. * This returns if the loader support the current file information.
  48009. * @param extension defines the file extension of the file being loaded
  48010. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48011. * @param fallback defines the fallback internal texture if any
  48012. * @param isBase64 defines whether the texture is encoded as a base64
  48013. * @param isBuffer defines whether the texture data are stored as a buffer
  48014. * @returns true if the loader can load the specified file
  48015. */
  48016. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48017. /**
  48018. * Transform the url before loading if required.
  48019. * @param rootUrl the url of the texture
  48020. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48021. * @returns the transformed texture
  48022. */
  48023. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48024. /**
  48025. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48026. * @param rootUrl the url of the texture
  48027. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48028. * @returns the fallback texture
  48029. */
  48030. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48031. /**
  48032. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48033. * @param data contains the texture data
  48034. * @param texture defines the BabylonJS internal texture
  48035. * @param createPolynomials will be true if polynomials have been requested
  48036. * @param onLoad defines the callback to trigger once the texture is ready
  48037. * @param onError defines the callback to trigger in case of error
  48038. */
  48039. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48040. /**
  48041. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48042. * @param data contains the texture data
  48043. * @param texture defines the BabylonJS internal texture
  48044. * @param callback defines the method to call once ready to upload
  48045. */
  48046. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48047. }
  48048. }
  48049. declare module "babylonjs/Misc/tga" {
  48050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48051. /**
  48052. * Based on jsTGALoader - Javascript loader for TGA file
  48053. * By Vincent Thibault
  48054. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48055. */
  48056. export class TGATools {
  48057. private static _TYPE_INDEXED;
  48058. private static _TYPE_RGB;
  48059. private static _TYPE_GREY;
  48060. private static _TYPE_RLE_INDEXED;
  48061. private static _TYPE_RLE_RGB;
  48062. private static _TYPE_RLE_GREY;
  48063. private static _ORIGIN_MASK;
  48064. private static _ORIGIN_SHIFT;
  48065. private static _ORIGIN_BL;
  48066. private static _ORIGIN_BR;
  48067. private static _ORIGIN_UL;
  48068. private static _ORIGIN_UR;
  48069. /**
  48070. * Gets the header of a TGA file
  48071. * @param data defines the TGA data
  48072. * @returns the header
  48073. */
  48074. static GetTGAHeader(data: Uint8Array): any;
  48075. /**
  48076. * Uploads TGA content to a Babylon Texture
  48077. * @hidden
  48078. */
  48079. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48080. /** @hidden */
  48081. 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;
  48082. /** @hidden */
  48083. 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;
  48084. /** @hidden */
  48085. 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;
  48086. /** @hidden */
  48087. 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;
  48088. /** @hidden */
  48089. 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;
  48090. /** @hidden */
  48091. 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;
  48092. }
  48093. }
  48094. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  48095. import { Nullable } from "babylonjs/types";
  48096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48097. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48098. /**
  48099. * Implementation of the TGA Texture Loader.
  48100. * @hidden
  48101. */
  48102. export class _TGATextureLoader implements IInternalTextureLoader {
  48103. /**
  48104. * Defines wether the loader supports cascade loading the different faces.
  48105. */
  48106. readonly supportCascades: boolean;
  48107. /**
  48108. * This returns if the loader support the current file information.
  48109. * @param extension defines the file extension of the file being loaded
  48110. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48111. * @param fallback defines the fallback internal texture if any
  48112. * @param isBase64 defines whether the texture is encoded as a base64
  48113. * @param isBuffer defines whether the texture data are stored as a buffer
  48114. * @returns true if the loader can load the specified file
  48115. */
  48116. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48117. /**
  48118. * Transform the url before loading if required.
  48119. * @param rootUrl the url of the texture
  48120. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48121. * @returns the transformed texture
  48122. */
  48123. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48124. /**
  48125. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48126. * @param rootUrl the url of the texture
  48127. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48128. * @returns the fallback texture
  48129. */
  48130. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48131. /**
  48132. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48133. * @param data contains the texture data
  48134. * @param texture defines the BabylonJS internal texture
  48135. * @param createPolynomials will be true if polynomials have been requested
  48136. * @param onLoad defines the callback to trigger once the texture is ready
  48137. * @param onError defines the callback to trigger in case of error
  48138. */
  48139. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48140. /**
  48141. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48142. * @param data contains the texture data
  48143. * @param texture defines the BabylonJS internal texture
  48144. * @param callback defines the method to call once ready to upload
  48145. */
  48146. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48147. }
  48148. }
  48149. declare module "babylonjs/Materials/Textures/Loaders/index" {
  48150. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48151. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48152. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48153. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  48154. }
  48155. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  48156. import { Scene } from "babylonjs/scene";
  48157. import { Texture } from "babylonjs/Materials/Textures/texture";
  48158. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48159. /**
  48160. * 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.
  48161. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48162. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48163. */
  48164. export class CustomProceduralTexture extends ProceduralTexture {
  48165. private _animate;
  48166. private _time;
  48167. private _config;
  48168. private _texturePath;
  48169. /**
  48170. * Instantiates a new Custom Procedural Texture.
  48171. * 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.
  48172. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48173. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48174. * @param name Define the name of the texture
  48175. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48176. * @param size Define the size of the texture to create
  48177. * @param scene Define the scene the texture belongs to
  48178. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48179. * @param generateMipMaps Define if the texture should creates mip maps or not
  48180. */
  48181. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48182. private _loadJson;
  48183. /**
  48184. * Is the texture ready to be used ? (rendered at least once)
  48185. * @returns true if ready, otherwise, false.
  48186. */
  48187. isReady(): boolean;
  48188. /**
  48189. * Render the texture to its associated render target.
  48190. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48191. */
  48192. render(useCameraPostProcess?: boolean): void;
  48193. /**
  48194. * Update the list of dependant textures samplers in the shader.
  48195. */
  48196. updateTextures(): void;
  48197. /**
  48198. * Update the uniform values of the procedural texture in the shader.
  48199. */
  48200. updateShaderUniforms(): void;
  48201. /**
  48202. * Define if the texture animates or not.
  48203. */
  48204. animate: boolean;
  48205. }
  48206. }
  48207. declare module "babylonjs/Shaders/noise.fragment" {
  48208. /** @hidden */
  48209. export var noisePixelShader: {
  48210. name: string;
  48211. shader: string;
  48212. };
  48213. }
  48214. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  48215. import { Nullable } from "babylonjs/types";
  48216. import { Scene } from "babylonjs/scene";
  48217. import { Texture } from "babylonjs/Materials/Textures/texture";
  48218. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48219. import "babylonjs/Shaders/noise.fragment";
  48220. /**
  48221. * Class used to generate noise procedural textures
  48222. */
  48223. export class NoiseProceduralTexture extends ProceduralTexture {
  48224. private _time;
  48225. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48226. brightness: number;
  48227. /** Defines the number of octaves to process */
  48228. octaves: number;
  48229. /** Defines the level of persistence (0.8 by default) */
  48230. persistence: number;
  48231. /** Gets or sets animation speed factor (default is 1) */
  48232. animationSpeedFactor: number;
  48233. /**
  48234. * Creates a new NoiseProceduralTexture
  48235. * @param name defines the name fo the texture
  48236. * @param size defines the size of the texture (default is 256)
  48237. * @param scene defines the hosting scene
  48238. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48239. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48240. */
  48241. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48242. private _updateShaderUniforms;
  48243. protected _getDefines(): string;
  48244. /** Generate the current state of the procedural texture */
  48245. render(useCameraPostProcess?: boolean): void;
  48246. /**
  48247. * Serializes this noise procedural texture
  48248. * @returns a serialized noise procedural texture object
  48249. */
  48250. serialize(): any;
  48251. /**
  48252. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48253. * @param parsedTexture defines parsed texture data
  48254. * @param scene defines the current scene
  48255. * @param rootUrl defines the root URL containing noise procedural texture information
  48256. * @returns a parsed NoiseProceduralTexture
  48257. */
  48258. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48259. }
  48260. }
  48261. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  48262. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  48263. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  48264. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  48265. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  48266. }
  48267. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  48268. import { Nullable } from "babylonjs/types";
  48269. import { Scene } from "babylonjs/scene";
  48270. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48271. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48272. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48273. /**
  48274. * Raw cube texture where the raw buffers are passed in
  48275. */
  48276. export class RawCubeTexture extends CubeTexture {
  48277. /**
  48278. * Creates a cube texture where the raw buffers are passed in.
  48279. * @param scene defines the scene the texture is attached to
  48280. * @param data defines the array of data to use to create each face
  48281. * @param size defines the size of the textures
  48282. * @param format defines the format of the data
  48283. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48284. * @param generateMipMaps defines if the engine should generate the mip levels
  48285. * @param invertY defines if data must be stored with Y axis inverted
  48286. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48287. * @param compression defines the compression used (null by default)
  48288. */
  48289. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48290. /**
  48291. * Updates the raw cube texture.
  48292. * @param data defines the data to store
  48293. * @param format defines the data format
  48294. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48295. * @param invertY defines if data must be stored with Y axis inverted
  48296. * @param compression defines the compression used (null by default)
  48297. * @param level defines which level of the texture to update
  48298. */
  48299. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48300. /**
  48301. * Updates a raw cube texture with RGBD encoded data.
  48302. * @param data defines the array of data [mipmap][face] to use to create each face
  48303. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48304. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48305. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48306. * @returns a promsie that resolves when the operation is complete
  48307. */
  48308. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48309. /**
  48310. * Clones the raw cube texture.
  48311. * @return a new cube texture
  48312. */
  48313. clone(): CubeTexture;
  48314. /** @hidden */
  48315. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48316. }
  48317. }
  48318. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  48319. import { Scene } from "babylonjs/scene";
  48320. import { Texture } from "babylonjs/Materials/Textures/texture";
  48321. /**
  48322. * Class used to store 3D textures containing user data
  48323. */
  48324. export class RawTexture3D extends Texture {
  48325. /** Gets or sets the texture format to use */
  48326. format: number;
  48327. private _engine;
  48328. /**
  48329. * Create a new RawTexture3D
  48330. * @param data defines the data of the texture
  48331. * @param width defines the width of the texture
  48332. * @param height defines the height of the texture
  48333. * @param depth defines the depth of the texture
  48334. * @param format defines the texture format to use
  48335. * @param scene defines the hosting scene
  48336. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48337. * @param invertY defines if texture must be stored with Y axis inverted
  48338. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48339. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48340. */
  48341. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48342. /** Gets or sets the texture format to use */
  48343. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48344. /**
  48345. * Update the texture with new data
  48346. * @param data defines the data to store in the texture
  48347. */
  48348. update(data: ArrayBufferView): void;
  48349. }
  48350. }
  48351. declare module "babylonjs/Materials/Textures/refractionTexture" {
  48352. import { Scene } from "babylonjs/scene";
  48353. import { Plane } from "babylonjs/Maths/math";
  48354. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48355. /**
  48356. * Creates a refraction texture used by refraction channel of the standard material.
  48357. * It is like a mirror but to see through a material.
  48358. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48359. */
  48360. export class RefractionTexture extends RenderTargetTexture {
  48361. /**
  48362. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48363. * 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.
  48364. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48365. */
  48366. refractionPlane: Plane;
  48367. /**
  48368. * Define how deep under the surface we should see.
  48369. */
  48370. depth: number;
  48371. /**
  48372. * Creates a refraction texture used by refraction channel of the standard material.
  48373. * It is like a mirror but to see through a material.
  48374. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48375. * @param name Define the texture name
  48376. * @param size Define the size of the underlying texture
  48377. * @param scene Define the scene the refraction belongs to
  48378. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48379. */
  48380. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48381. /**
  48382. * Clone the refraction texture.
  48383. * @returns the cloned texture
  48384. */
  48385. clone(): RefractionTexture;
  48386. /**
  48387. * Serialize the texture to a JSON representation you could use in Parse later on
  48388. * @returns the serialized JSON representation
  48389. */
  48390. serialize(): any;
  48391. }
  48392. }
  48393. declare module "babylonjs/Materials/Textures/index" {
  48394. export * from "babylonjs/Materials/Textures/baseTexture";
  48395. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  48396. export * from "babylonjs/Materials/Textures/cubeTexture";
  48397. export * from "babylonjs/Materials/Textures/dynamicTexture";
  48398. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  48399. export * from "babylonjs/Materials/Textures/internalTexture";
  48400. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  48401. export * from "babylonjs/Materials/Textures/internalTextureTracker";
  48402. export * from "babylonjs/Materials/Textures/Loaders/index";
  48403. export * from "babylonjs/Materials/Textures/mirrorTexture";
  48404. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  48405. export * from "babylonjs/Materials/Textures/Procedurals/index";
  48406. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  48407. export * from "babylonjs/Materials/Textures/rawTexture";
  48408. export * from "babylonjs/Materials/Textures/rawTexture3D";
  48409. export * from "babylonjs/Materials/Textures/refractionTexture";
  48410. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  48411. export * from "babylonjs/Materials/Textures/texture";
  48412. export * from "babylonjs/Materials/Textures/videoTexture";
  48413. }
  48414. declare module "babylonjs/Materials/index" {
  48415. export * from "babylonjs/Materials/Background/index";
  48416. export * from "babylonjs/Materials/colorCurves";
  48417. export * from "babylonjs/Materials/effect";
  48418. export * from "babylonjs/Materials/fresnelParameters";
  48419. export * from "babylonjs/Materials/imageProcessingConfiguration";
  48420. export * from "babylonjs/Materials/material";
  48421. export * from "babylonjs/Materials/materialDefines";
  48422. export * from "babylonjs/Materials/materialHelper";
  48423. export * from "babylonjs/Materials/multiMaterial";
  48424. export * from "babylonjs/Materials/PBR/index";
  48425. export * from "babylonjs/Materials/pushMaterial";
  48426. export * from "babylonjs/Materials/shaderMaterial";
  48427. export * from "babylonjs/Materials/standardMaterial";
  48428. export * from "babylonjs/Materials/Textures/index";
  48429. export * from "babylonjs/Materials/uniformBuffer";
  48430. export * from "babylonjs/Materials/materialFlags";
  48431. }
  48432. declare module "babylonjs/Maths/index" {
  48433. export * from "babylonjs/Maths/math.scalar";
  48434. export * from "babylonjs/Maths/math";
  48435. export * from "babylonjs/Maths/sphericalPolynomial";
  48436. }
  48437. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  48438. import { IDisposable } from "babylonjs/scene";
  48439. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  48440. /**
  48441. * Configuration for Draco compression
  48442. */
  48443. export interface IDracoCompressionConfiguration {
  48444. /**
  48445. * Configuration for the decoder.
  48446. */
  48447. decoder?: {
  48448. /**
  48449. * The url to the WebAssembly module.
  48450. */
  48451. wasmUrl?: string;
  48452. /**
  48453. * The url to the WebAssembly binary.
  48454. */
  48455. wasmBinaryUrl?: string;
  48456. /**
  48457. * The url to the fallback JavaScript module.
  48458. */
  48459. fallbackUrl?: string;
  48460. };
  48461. }
  48462. /**
  48463. * Draco compression (https://google.github.io/draco/)
  48464. *
  48465. * This class wraps the Draco module.
  48466. *
  48467. * **Encoder**
  48468. *
  48469. * The encoder is not currently implemented.
  48470. *
  48471. * **Decoder**
  48472. *
  48473. * 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.
  48474. *
  48475. * To update the configuration, use the following code:
  48476. * ```javascript
  48477. * DracoCompression.Configuration = {
  48478. * decoder: {
  48479. * wasmUrl: "<url to the WebAssembly library>",
  48480. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48481. * fallbackUrl: "<url to the fallback JavaScript library>",
  48482. * }
  48483. * };
  48484. * ```
  48485. *
  48486. * 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.
  48487. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48488. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48489. *
  48490. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48491. * ```javascript
  48492. * var dracoCompression = new DracoCompression();
  48493. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48494. * [VertexBuffer.PositionKind]: 0
  48495. * });
  48496. * ```
  48497. *
  48498. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48499. */
  48500. export class DracoCompression implements IDisposable {
  48501. private static _DecoderModulePromise;
  48502. /**
  48503. * The configuration. Defaults to the following urls:
  48504. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48505. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48506. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48507. */
  48508. static Configuration: IDracoCompressionConfiguration;
  48509. /**
  48510. * Returns true if the decoder is available.
  48511. */
  48512. static readonly DecoderAvailable: boolean;
  48513. /**
  48514. * Constructor
  48515. */
  48516. constructor();
  48517. /**
  48518. * Stop all async operations and release resources.
  48519. */
  48520. dispose(): void;
  48521. /**
  48522. * Decode Draco compressed mesh data to vertex data.
  48523. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48524. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48525. * @returns A promise that resolves with the decoded vertex data
  48526. */
  48527. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48528. [kind: string]: number;
  48529. }): Promise<VertexData>;
  48530. private static _GetDecoderModule;
  48531. private static _LoadScriptAsync;
  48532. private static _LoadFileAsync;
  48533. }
  48534. }
  48535. declare module "babylonjs/Meshes/Compression/index" {
  48536. export * from "babylonjs/Meshes/Compression/dracoCompression";
  48537. }
  48538. declare module "babylonjs/Meshes/csg" {
  48539. import { Nullable } from "babylonjs/types";
  48540. import { Scene } from "babylonjs/scene";
  48541. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  48542. import { Mesh } from "babylonjs/Meshes/mesh";
  48543. import { Material } from "babylonjs/Materials/material";
  48544. /**
  48545. * Class for building Constructive Solid Geometry
  48546. */
  48547. export class CSG {
  48548. private polygons;
  48549. /**
  48550. * The world matrix
  48551. */
  48552. matrix: Matrix;
  48553. /**
  48554. * Stores the position
  48555. */
  48556. position: Vector3;
  48557. /**
  48558. * Stores the rotation
  48559. */
  48560. rotation: Vector3;
  48561. /**
  48562. * Stores the rotation quaternion
  48563. */
  48564. rotationQuaternion: Nullable<Quaternion>;
  48565. /**
  48566. * Stores the scaling vector
  48567. */
  48568. scaling: Vector3;
  48569. /**
  48570. * Convert the Mesh to CSG
  48571. * @param mesh The Mesh to convert to CSG
  48572. * @returns A new CSG from the Mesh
  48573. */
  48574. static FromMesh(mesh: Mesh): CSG;
  48575. /**
  48576. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48577. * @param polygons Polygons used to construct a CSG solid
  48578. */
  48579. private static FromPolygons;
  48580. /**
  48581. * Clones, or makes a deep copy, of the CSG
  48582. * @returns A new CSG
  48583. */
  48584. clone(): CSG;
  48585. /**
  48586. * Unions this CSG with another CSG
  48587. * @param csg The CSG to union against this CSG
  48588. * @returns The unioned CSG
  48589. */
  48590. union(csg: CSG): CSG;
  48591. /**
  48592. * Unions this CSG with another CSG in place
  48593. * @param csg The CSG to union against this CSG
  48594. */
  48595. unionInPlace(csg: CSG): void;
  48596. /**
  48597. * Subtracts this CSG with another CSG
  48598. * @param csg The CSG to subtract against this CSG
  48599. * @returns A new CSG
  48600. */
  48601. subtract(csg: CSG): CSG;
  48602. /**
  48603. * Subtracts this CSG with another CSG in place
  48604. * @param csg The CSG to subtact against this CSG
  48605. */
  48606. subtractInPlace(csg: CSG): void;
  48607. /**
  48608. * Intersect this CSG with another CSG
  48609. * @param csg The CSG to intersect against this CSG
  48610. * @returns A new CSG
  48611. */
  48612. intersect(csg: CSG): CSG;
  48613. /**
  48614. * Intersects this CSG with another CSG in place
  48615. * @param csg The CSG to intersect against this CSG
  48616. */
  48617. intersectInPlace(csg: CSG): void;
  48618. /**
  48619. * Return a new CSG solid with solid and empty space switched. This solid is
  48620. * not modified.
  48621. * @returns A new CSG solid with solid and empty space switched
  48622. */
  48623. inverse(): CSG;
  48624. /**
  48625. * Inverses the CSG in place
  48626. */
  48627. inverseInPlace(): void;
  48628. /**
  48629. * This is used to keep meshes transformations so they can be restored
  48630. * when we build back a Babylon Mesh
  48631. * NB : All CSG operations are performed in world coordinates
  48632. * @param csg The CSG to copy the transform attributes from
  48633. * @returns This CSG
  48634. */
  48635. copyTransformAttributes(csg: CSG): CSG;
  48636. /**
  48637. * Build Raw mesh from CSG
  48638. * Coordinates here are in world space
  48639. * @param name The name of the mesh geometry
  48640. * @param scene The Scene
  48641. * @param keepSubMeshes Specifies if the submeshes should be kept
  48642. * @returns A new Mesh
  48643. */
  48644. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48645. /**
  48646. * Build Mesh from CSG taking material and transforms into account
  48647. * @param name The name of the Mesh
  48648. * @param material The material of the Mesh
  48649. * @param scene The Scene
  48650. * @param keepSubMeshes Specifies if submeshes should be kept
  48651. * @returns The new Mesh
  48652. */
  48653. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48654. }
  48655. }
  48656. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  48657. import { Nullable } from "babylonjs/types";
  48658. import { Scene } from "babylonjs/scene";
  48659. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  48660. import { Mesh } from "babylonjs/Meshes/mesh";
  48661. /**
  48662. * Class containing static functions to help procedurally build meshes
  48663. */
  48664. export class RibbonBuilder {
  48665. /**
  48666. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48667. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  48668. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  48669. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  48670. * * 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
  48671. * * 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
  48672. * * 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
  48673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48674. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48675. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48676. * * 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
  48677. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  48678. * * 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
  48679. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  48680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48681. * @param name defines the name of the mesh
  48682. * @param options defines the options used to create the mesh
  48683. * @param scene defines the hosting scene
  48684. * @returns the ribbon mesh
  48685. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  48686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48687. */
  48688. static CreateRibbon(name: string, options: {
  48689. pathArray: Vector3[][];
  48690. closeArray?: boolean;
  48691. closePath?: boolean;
  48692. offset?: number;
  48693. updatable?: boolean;
  48694. sideOrientation?: number;
  48695. frontUVs?: Vector4;
  48696. backUVs?: Vector4;
  48697. instance?: Mesh;
  48698. invertUV?: boolean;
  48699. uvs?: Vector2[];
  48700. colors?: Color4[];
  48701. }, scene?: Nullable<Scene>): Mesh;
  48702. }
  48703. }
  48704. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  48705. import { Vector4 } from "babylonjs/Maths/math";
  48706. import { Mesh } from "babylonjs/Meshes/mesh";
  48707. /**
  48708. * Class containing static functions to help procedurally build meshes
  48709. */
  48710. export class TorusKnotBuilder {
  48711. /**
  48712. * Creates a torus knot mesh
  48713. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48714. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48715. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48716. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48717. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48718. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48719. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48720. * @param name defines the name of the mesh
  48721. * @param options defines the options used to create the mesh
  48722. * @param scene defines the hosting scene
  48723. * @returns the torus knot mesh
  48724. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48725. */
  48726. static CreateTorusKnot(name: string, options: {
  48727. radius?: number;
  48728. tube?: number;
  48729. radialSegments?: number;
  48730. tubularSegments?: number;
  48731. p?: number;
  48732. q?: number;
  48733. updatable?: boolean;
  48734. sideOrientation?: number;
  48735. frontUVs?: Vector4;
  48736. backUVs?: Vector4;
  48737. }, scene: any): Mesh;
  48738. }
  48739. }
  48740. declare module "babylonjs/Meshes/polygonMesh" {
  48741. import { Scene } from "babylonjs/scene";
  48742. import { Vector2, Path2 } from "babylonjs/Maths/math";
  48743. import { Mesh } from "babylonjs/Meshes/mesh";
  48744. /**
  48745. * Polygon
  48746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48747. */
  48748. export class Polygon {
  48749. /**
  48750. * Creates a rectangle
  48751. * @param xmin bottom X coord
  48752. * @param ymin bottom Y coord
  48753. * @param xmax top X coord
  48754. * @param ymax top Y coord
  48755. * @returns points that make the resulting rectation
  48756. */
  48757. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48758. /**
  48759. * Creates a circle
  48760. * @param radius radius of circle
  48761. * @param cx scale in x
  48762. * @param cy scale in y
  48763. * @param numberOfSides number of sides that make up the circle
  48764. * @returns points that make the resulting circle
  48765. */
  48766. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48767. /**
  48768. * Creates a polygon from input string
  48769. * @param input Input polygon data
  48770. * @returns the parsed points
  48771. */
  48772. static Parse(input: string): Vector2[];
  48773. /**
  48774. * Starts building a polygon from x and y coordinates
  48775. * @param x x coordinate
  48776. * @param y y coordinate
  48777. * @returns the started path2
  48778. */
  48779. static StartingAt(x: number, y: number): Path2;
  48780. }
  48781. /**
  48782. * Builds a polygon
  48783. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48784. */
  48785. export class PolygonMeshBuilder {
  48786. private _points;
  48787. private _outlinepoints;
  48788. private _holes;
  48789. private _name;
  48790. private _scene;
  48791. private _epoints;
  48792. private _eholes;
  48793. private _addToepoint;
  48794. /**
  48795. * Babylon reference to the earcut plugin.
  48796. */
  48797. bjsEarcut: any;
  48798. /**
  48799. * Creates a PolygonMeshBuilder
  48800. * @param name name of the builder
  48801. * @param contours Path of the polygon
  48802. * @param scene scene to add to
  48803. * @param earcutInjection can be used to inject your own earcut reference
  48804. */
  48805. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  48806. /**
  48807. * Adds a whole within the polygon
  48808. * @param hole Array of points defining the hole
  48809. * @returns this
  48810. */
  48811. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48812. /**
  48813. * Creates the polygon
  48814. * @param updatable If the mesh should be updatable
  48815. * @param depth The depth of the mesh created
  48816. * @returns the created mesh
  48817. */
  48818. build(updatable?: boolean, depth?: number): Mesh;
  48819. /**
  48820. * Adds a side to the polygon
  48821. * @param positions points that make the polygon
  48822. * @param normals normals of the polygon
  48823. * @param uvs uvs of the polygon
  48824. * @param indices indices of the polygon
  48825. * @param bounds bounds of the polygon
  48826. * @param points points of the polygon
  48827. * @param depth depth of the polygon
  48828. * @param flip flip of the polygon
  48829. */
  48830. private addSide;
  48831. }
  48832. }
  48833. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  48834. import { Scene } from "babylonjs/scene";
  48835. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  48836. import { Mesh } from "babylonjs/Meshes/mesh";
  48837. /**
  48838. * Class containing static functions to help procedurally build meshes
  48839. */
  48840. export class PolygonBuilder {
  48841. /**
  48842. * Creates a polygon mesh
  48843. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48844. * * 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
  48845. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48847. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  48848. * * Remember you can only change the shape positions, not their number when updating a polygon
  48849. * @param name defines the name of the mesh
  48850. * @param options defines the options used to create the mesh
  48851. * @param scene defines the hosting scene
  48852. * @param earcutInjection can be used to inject your own earcut reference
  48853. * @returns the polygon mesh
  48854. */
  48855. static CreatePolygon(name: string, options: {
  48856. shape: Vector3[];
  48857. holes?: Vector3[][];
  48858. depth?: number;
  48859. faceUV?: Vector4[];
  48860. faceColors?: Color4[];
  48861. updatable?: boolean;
  48862. sideOrientation?: number;
  48863. frontUVs?: Vector4;
  48864. backUVs?: Vector4;
  48865. }, scene: Scene, earcutInjection?: any): Mesh;
  48866. /**
  48867. * Creates an extruded polygon mesh, with depth in the Y direction.
  48868. * * 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)
  48869. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48870. * @param name defines the name of the mesh
  48871. * @param options defines the options used to create the mesh
  48872. * @param scene defines the hosting scene
  48873. * @param earcutInjection can be used to inject your own earcut reference
  48874. * @returns the polygon mesh
  48875. */
  48876. static ExtrudePolygon(name: string, options: {
  48877. shape: Vector3[];
  48878. holes?: Vector3[][];
  48879. depth?: number;
  48880. faceUV?: Vector4[];
  48881. faceColors?: Color4[];
  48882. updatable?: boolean;
  48883. sideOrientation?: number;
  48884. frontUVs?: Vector4;
  48885. backUVs?: Vector4;
  48886. }, scene: Scene, earcutInjection?: any): Mesh;
  48887. }
  48888. }
  48889. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  48890. import { Nullable } from "babylonjs/types";
  48891. import { Scene } from "babylonjs/scene";
  48892. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  48893. import { Mesh } from "babylonjs/Meshes/mesh";
  48894. /**
  48895. * Class containing static functions to help procedurally build meshes
  48896. */
  48897. export class ShapeBuilder {
  48898. /**
  48899. * 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.
  48900. * * 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.
  48901. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48902. * * 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.
  48903. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  48904. * * 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
  48905. * * 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
  48906. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  48907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  48910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48911. * @param name defines the name of the mesh
  48912. * @param options defines the options used to create the mesh
  48913. * @param scene defines the hosting scene
  48914. * @returns the extruded shape mesh
  48915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48917. */
  48918. static ExtrudeShape(name: string, options: {
  48919. shape: Vector3[];
  48920. path: Vector3[];
  48921. scale?: number;
  48922. rotation?: number;
  48923. cap?: number;
  48924. updatable?: boolean;
  48925. sideOrientation?: number;
  48926. frontUVs?: Vector4;
  48927. backUVs?: Vector4;
  48928. instance?: Mesh;
  48929. invertUV?: boolean;
  48930. }, scene?: Nullable<Scene>): Mesh;
  48931. /**
  48932. * Creates an custom extruded shape mesh.
  48933. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  48934. * * 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.
  48935. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  48936. * * 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
  48937. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48938. * * 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
  48939. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48940. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48941. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48942. * * 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
  48943. * * 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
  48944. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48949. * @param name defines the name of the mesh
  48950. * @param options defines the options used to create the mesh
  48951. * @param scene defines the hosting scene
  48952. * @returns the custom extruded shape mesh
  48953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48956. */
  48957. static ExtrudeShapeCustom(name: string, options: {
  48958. shape: Vector3[];
  48959. path: Vector3[];
  48960. scaleFunction?: any;
  48961. rotationFunction?: any;
  48962. ribbonCloseArray?: boolean;
  48963. ribbonClosePath?: boolean;
  48964. cap?: number;
  48965. updatable?: boolean;
  48966. sideOrientation?: number;
  48967. frontUVs?: Vector4;
  48968. backUVs?: Vector4;
  48969. instance?: Mesh;
  48970. invertUV?: boolean;
  48971. }, scene: Scene): Mesh;
  48972. private static _ExtrudeShapeGeneric;
  48973. }
  48974. }
  48975. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  48976. import { Scene } from "babylonjs/scene";
  48977. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  48978. import { Mesh } from "babylonjs/Meshes/mesh";
  48979. /**
  48980. * Class containing static functions to help procedurally build meshes
  48981. */
  48982. export class LatheBuilder {
  48983. /**
  48984. * Creates lathe mesh.
  48985. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  48986. * * 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
  48987. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  48988. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  48989. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  48990. * * 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
  48991. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  48992. * * 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
  48993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48997. * @param name defines the name of the mesh
  48998. * @param options defines the options used to create the mesh
  48999. * @param scene defines the hosting scene
  49000. * @returns the lathe mesh
  49001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49002. */
  49003. static CreateLathe(name: string, options: {
  49004. shape: Vector3[];
  49005. radius?: number;
  49006. tessellation?: number;
  49007. clip?: number;
  49008. arc?: number;
  49009. closed?: boolean;
  49010. updatable?: boolean;
  49011. sideOrientation?: number;
  49012. frontUVs?: Vector4;
  49013. backUVs?: Vector4;
  49014. cap?: number;
  49015. invertUV?: boolean;
  49016. }, scene: Scene): Mesh;
  49017. }
  49018. }
  49019. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  49020. import { Scene } from "babylonjs/scene";
  49021. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  49022. import { Mesh } from "babylonjs/Meshes/mesh";
  49023. /**
  49024. * Class containing static functions to help procedurally build meshes
  49025. */
  49026. export class TubeBuilder {
  49027. /**
  49028. * Creates a tube mesh.
  49029. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49030. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49031. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49032. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49033. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49034. * * 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)
  49035. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49036. * * 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
  49037. * * 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
  49038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49039. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49040. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49042. * @param name defines the name of the mesh
  49043. * @param options defines the options used to create the mesh
  49044. * @param scene defines the hosting scene
  49045. * @returns the tube mesh
  49046. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49047. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49048. */
  49049. static CreateTube(name: string, options: {
  49050. path: Vector3[];
  49051. radius?: number;
  49052. tessellation?: number;
  49053. radiusFunction?: {
  49054. (i: number, distance: number): number;
  49055. };
  49056. cap?: number;
  49057. arc?: number;
  49058. updatable?: boolean;
  49059. sideOrientation?: number;
  49060. frontUVs?: Vector4;
  49061. backUVs?: Vector4;
  49062. instance?: Mesh;
  49063. invertUV?: boolean;
  49064. }, scene: Scene): Mesh;
  49065. }
  49066. }
  49067. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  49068. import { Scene } from "babylonjs/scene";
  49069. import { Vector4 } from "babylonjs/Maths/math";
  49070. import { Mesh } from "babylonjs/Meshes/mesh";
  49071. /**
  49072. * Class containing static functions to help procedurally build meshes
  49073. */
  49074. export class IcoSphereBuilder {
  49075. /**
  49076. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49077. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49078. * * 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`)
  49079. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49080. * * 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
  49081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49084. * @param name defines the name of the mesh
  49085. * @param options defines the options used to create the mesh
  49086. * @param scene defines the hosting scene
  49087. * @returns the icosahedron mesh
  49088. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49089. */
  49090. static CreateIcoSphere(name: string, options: {
  49091. radius?: number;
  49092. radiusX?: number;
  49093. radiusY?: number;
  49094. radiusZ?: number;
  49095. flat?: boolean;
  49096. subdivisions?: number;
  49097. sideOrientation?: number;
  49098. frontUVs?: Vector4;
  49099. backUVs?: Vector4;
  49100. updatable?: boolean;
  49101. }, scene: Scene): Mesh;
  49102. }
  49103. }
  49104. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  49105. import { Vector3 } from "babylonjs/Maths/math";
  49106. import { Mesh } from "babylonjs/Meshes/mesh";
  49107. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49108. /**
  49109. * Class containing static functions to help procedurally build meshes
  49110. */
  49111. export class DecalBuilder {
  49112. /**
  49113. * Creates a decal mesh.
  49114. * 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
  49115. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49116. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49117. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49118. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49119. * @param name defines the name of the mesh
  49120. * @param sourceMesh defines the mesh where the decal must be applied
  49121. * @param options defines the options used to create the mesh
  49122. * @param scene defines the hosting scene
  49123. * @returns the decal mesh
  49124. * @see https://doc.babylonjs.com/how_to/decals
  49125. */
  49126. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49127. position?: Vector3;
  49128. normal?: Vector3;
  49129. size?: Vector3;
  49130. angle?: number;
  49131. }): Mesh;
  49132. }
  49133. }
  49134. declare module "babylonjs/Meshes/meshBuilder" {
  49135. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  49136. import { Nullable } from "babylonjs/types";
  49137. import { Scene } from "babylonjs/scene";
  49138. import { Mesh } from "babylonjs/Meshes/mesh";
  49139. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  49140. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  49141. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49142. /**
  49143. * Class containing static functions to help procedurally build meshes
  49144. */
  49145. export class MeshBuilder {
  49146. /**
  49147. * Creates a box mesh
  49148. * * The parameter `size` sets the size (float) of each box side (default 1)
  49149. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49150. * * 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)
  49151. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49155. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49156. * @param name defines the name of the mesh
  49157. * @param options defines the options used to create the mesh
  49158. * @param scene defines the hosting scene
  49159. * @returns the box mesh
  49160. */
  49161. static CreateBox(name: string, options: {
  49162. size?: number;
  49163. width?: number;
  49164. height?: number;
  49165. depth?: number;
  49166. faceUV?: Vector4[];
  49167. faceColors?: Color4[];
  49168. sideOrientation?: number;
  49169. frontUVs?: Vector4;
  49170. backUVs?: Vector4;
  49171. updatable?: boolean;
  49172. }, scene?: Nullable<Scene>): Mesh;
  49173. /**
  49174. * Creates a sphere mesh
  49175. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49176. * * 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`)
  49177. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49178. * * 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
  49179. * * 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)
  49180. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49181. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49183. * @param name defines the name of the mesh
  49184. * @param options defines the options used to create the mesh
  49185. * @param scene defines the hosting scene
  49186. * @returns the sphere mesh
  49187. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49188. */
  49189. static CreateSphere(name: string, options: {
  49190. segments?: number;
  49191. diameter?: number;
  49192. diameterX?: number;
  49193. diameterY?: number;
  49194. diameterZ?: number;
  49195. arc?: number;
  49196. slice?: number;
  49197. sideOrientation?: number;
  49198. frontUVs?: Vector4;
  49199. backUVs?: Vector4;
  49200. updatable?: boolean;
  49201. }, scene: any): Mesh;
  49202. /**
  49203. * Creates a plane polygonal mesh. By default, this is a disc
  49204. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49205. * * 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
  49206. * * 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
  49207. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49208. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49210. * @param name defines the name of the mesh
  49211. * @param options defines the options used to create the mesh
  49212. * @param scene defines the hosting scene
  49213. * @returns the plane polygonal mesh
  49214. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49215. */
  49216. static CreateDisc(name: string, options: {
  49217. radius?: number;
  49218. tessellation?: number;
  49219. arc?: number;
  49220. updatable?: boolean;
  49221. sideOrientation?: number;
  49222. frontUVs?: Vector4;
  49223. backUVs?: Vector4;
  49224. }, scene?: Nullable<Scene>): Mesh;
  49225. /**
  49226. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49227. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49228. * * 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`)
  49229. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49230. * * 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
  49231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49234. * @param name defines the name of the mesh
  49235. * @param options defines the options used to create the mesh
  49236. * @param scene defines the hosting scene
  49237. * @returns the icosahedron mesh
  49238. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49239. */
  49240. static CreateIcoSphere(name: string, options: {
  49241. radius?: number;
  49242. radiusX?: number;
  49243. radiusY?: number;
  49244. radiusZ?: number;
  49245. flat?: boolean;
  49246. subdivisions?: number;
  49247. sideOrientation?: number;
  49248. frontUVs?: Vector4;
  49249. backUVs?: Vector4;
  49250. updatable?: boolean;
  49251. }, scene: Scene): Mesh;
  49252. /**
  49253. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49254. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49255. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49256. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49257. * * 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
  49258. * * 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
  49259. * * 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
  49260. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49261. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49262. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49263. * * 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
  49264. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49265. * * 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
  49266. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49268. * @param name defines the name of the mesh
  49269. * @param options defines the options used to create the mesh
  49270. * @param scene defines the hosting scene
  49271. * @returns the ribbon mesh
  49272. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49273. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49274. */
  49275. static CreateRibbon(name: string, options: {
  49276. pathArray: Vector3[][];
  49277. closeArray?: boolean;
  49278. closePath?: boolean;
  49279. offset?: number;
  49280. updatable?: boolean;
  49281. sideOrientation?: number;
  49282. frontUVs?: Vector4;
  49283. backUVs?: Vector4;
  49284. instance?: Mesh;
  49285. invertUV?: boolean;
  49286. uvs?: Vector2[];
  49287. colors?: Color4[];
  49288. }, scene?: Nullable<Scene>): Mesh;
  49289. /**
  49290. * Creates a cylinder or a cone mesh
  49291. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49292. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49293. * * 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.
  49294. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49295. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49296. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49297. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49298. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49299. * * 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).
  49300. * * 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
  49301. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49302. * * 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
  49303. * * 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.
  49304. * * If `enclose` is false, a ring surface is one element.
  49305. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49306. * * 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
  49307. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49308. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49309. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49310. * @param name defines the name of the mesh
  49311. * @param options defines the options used to create the mesh
  49312. * @param scene defines the hosting scene
  49313. * @returns the cylinder mesh
  49314. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49315. */
  49316. static CreateCylinder(name: string, options: {
  49317. height?: number;
  49318. diameterTop?: number;
  49319. diameterBottom?: number;
  49320. diameter?: number;
  49321. tessellation?: number;
  49322. subdivisions?: number;
  49323. arc?: number;
  49324. faceColors?: Color4[];
  49325. faceUV?: Vector4[];
  49326. updatable?: boolean;
  49327. hasRings?: boolean;
  49328. enclose?: boolean;
  49329. sideOrientation?: number;
  49330. frontUVs?: Vector4;
  49331. backUVs?: Vector4;
  49332. }, scene: any): Mesh;
  49333. /**
  49334. * Creates a torus mesh
  49335. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49336. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49337. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49339. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49341. * @param name defines the name of the mesh
  49342. * @param options defines the options used to create the mesh
  49343. * @param scene defines the hosting scene
  49344. * @returns the torus mesh
  49345. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49346. */
  49347. static CreateTorus(name: string, options: {
  49348. diameter?: number;
  49349. thickness?: number;
  49350. tessellation?: number;
  49351. updatable?: boolean;
  49352. sideOrientation?: number;
  49353. frontUVs?: Vector4;
  49354. backUVs?: Vector4;
  49355. }, scene: any): Mesh;
  49356. /**
  49357. * Creates a torus knot mesh
  49358. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49359. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49360. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49361. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49362. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49363. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49364. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49365. * @param name defines the name of the mesh
  49366. * @param options defines the options used to create the mesh
  49367. * @param scene defines the hosting scene
  49368. * @returns the torus knot mesh
  49369. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49370. */
  49371. static CreateTorusKnot(name: string, options: {
  49372. radius?: number;
  49373. tube?: number;
  49374. radialSegments?: number;
  49375. tubularSegments?: number;
  49376. p?: number;
  49377. q?: number;
  49378. updatable?: boolean;
  49379. sideOrientation?: number;
  49380. frontUVs?: Vector4;
  49381. backUVs?: Vector4;
  49382. }, scene: any): Mesh;
  49383. /**
  49384. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49385. * * 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
  49386. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49387. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49388. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49389. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49390. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49391. * * 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
  49392. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49395. * @param name defines the name of the new line system
  49396. * @param options defines the options used to create the line system
  49397. * @param scene defines the hosting scene
  49398. * @returns a new line system mesh
  49399. */
  49400. static CreateLineSystem(name: string, options: {
  49401. lines: Vector3[][];
  49402. updatable?: boolean;
  49403. instance?: Nullable<LinesMesh>;
  49404. colors?: Nullable<Color4[][]>;
  49405. useVertexAlpha?: boolean;
  49406. }, scene: Nullable<Scene>): LinesMesh;
  49407. /**
  49408. * Creates a line mesh
  49409. * 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
  49410. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49411. * * The parameter `points` is an array successive Vector3
  49412. * * 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
  49413. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49414. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49415. * * When updating an instance, remember that only point positions can change, not the number of points
  49416. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49418. * @param name defines the name of the new line system
  49419. * @param options defines the options used to create the line system
  49420. * @param scene defines the hosting scene
  49421. * @returns a new line mesh
  49422. */
  49423. static CreateLines(name: string, options: {
  49424. points: Vector3[];
  49425. updatable?: boolean;
  49426. instance?: Nullable<LinesMesh>;
  49427. colors?: Color4[];
  49428. useVertexAlpha?: boolean;
  49429. }, scene?: Nullable<Scene>): LinesMesh;
  49430. /**
  49431. * Creates a dashed line mesh
  49432. * * 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
  49433. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49434. * * The parameter `points` is an array successive Vector3
  49435. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49436. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49437. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49438. * * 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
  49439. * * When updating an instance, remember that only point positions can change, not the number of points
  49440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49441. * @param name defines the name of the mesh
  49442. * @param options defines the options used to create the mesh
  49443. * @param scene defines the hosting scene
  49444. * @returns the dashed line mesh
  49445. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49446. */
  49447. static CreateDashedLines(name: string, options: {
  49448. points: Vector3[];
  49449. dashSize?: number;
  49450. gapSize?: number;
  49451. dashNb?: number;
  49452. updatable?: boolean;
  49453. instance?: LinesMesh;
  49454. }, scene?: Nullable<Scene>): LinesMesh;
  49455. /**
  49456. * 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.
  49457. * * 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.
  49458. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49459. * * 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.
  49460. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49461. * * 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
  49462. * * 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
  49463. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49466. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49468. * @param name defines the name of the mesh
  49469. * @param options defines the options used to create the mesh
  49470. * @param scene defines the hosting scene
  49471. * @returns the extruded shape mesh
  49472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49473. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49474. */
  49475. static ExtrudeShape(name: string, options: {
  49476. shape: Vector3[];
  49477. path: Vector3[];
  49478. scale?: number;
  49479. rotation?: number;
  49480. cap?: number;
  49481. updatable?: boolean;
  49482. sideOrientation?: number;
  49483. frontUVs?: Vector4;
  49484. backUVs?: Vector4;
  49485. instance?: Mesh;
  49486. invertUV?: boolean;
  49487. }, scene?: Nullable<Scene>): Mesh;
  49488. /**
  49489. * Creates an custom extruded shape mesh.
  49490. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49491. * * 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.
  49492. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49493. * * 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
  49494. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49495. * * 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
  49496. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49497. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49498. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49499. * * 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
  49500. * * 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
  49501. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49503. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49506. * @param name defines the name of the mesh
  49507. * @param options defines the options used to create the mesh
  49508. * @param scene defines the hosting scene
  49509. * @returns the custom extruded shape mesh
  49510. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49513. */
  49514. static ExtrudeShapeCustom(name: string, options: {
  49515. shape: Vector3[];
  49516. path: Vector3[];
  49517. scaleFunction?: any;
  49518. rotationFunction?: any;
  49519. ribbonCloseArray?: boolean;
  49520. ribbonClosePath?: boolean;
  49521. cap?: number;
  49522. updatable?: boolean;
  49523. sideOrientation?: number;
  49524. frontUVs?: Vector4;
  49525. backUVs?: Vector4;
  49526. instance?: Mesh;
  49527. invertUV?: boolean;
  49528. }, scene: Scene): Mesh;
  49529. /**
  49530. * Creates lathe mesh.
  49531. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49532. * * 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
  49533. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49534. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49535. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49536. * * 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
  49537. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49538. * * 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
  49539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49540. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49541. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49543. * @param name defines the name of the mesh
  49544. * @param options defines the options used to create the mesh
  49545. * @param scene defines the hosting scene
  49546. * @returns the lathe mesh
  49547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49548. */
  49549. static CreateLathe(name: string, options: {
  49550. shape: Vector3[];
  49551. radius?: number;
  49552. tessellation?: number;
  49553. clip?: number;
  49554. arc?: number;
  49555. closed?: boolean;
  49556. updatable?: boolean;
  49557. sideOrientation?: number;
  49558. frontUVs?: Vector4;
  49559. backUVs?: Vector4;
  49560. cap?: number;
  49561. invertUV?: boolean;
  49562. }, scene: Scene): Mesh;
  49563. /**
  49564. * Creates a plane mesh
  49565. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49566. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49567. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49571. * @param name defines the name of the mesh
  49572. * @param options defines the options used to create the mesh
  49573. * @param scene defines the hosting scene
  49574. * @returns the plane mesh
  49575. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49576. */
  49577. static CreatePlane(name: string, options: {
  49578. size?: number;
  49579. width?: number;
  49580. height?: number;
  49581. sideOrientation?: number;
  49582. frontUVs?: Vector4;
  49583. backUVs?: Vector4;
  49584. updatable?: boolean;
  49585. sourcePlane?: Plane;
  49586. }, scene: Scene): Mesh;
  49587. /**
  49588. * Creates a ground mesh
  49589. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49590. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49592. * @param name defines the name of the mesh
  49593. * @param options defines the options used to create the mesh
  49594. * @param scene defines the hosting scene
  49595. * @returns the ground mesh
  49596. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49597. */
  49598. static CreateGround(name: string, options: {
  49599. width?: number;
  49600. height?: number;
  49601. subdivisions?: number;
  49602. subdivisionsX?: number;
  49603. subdivisionsY?: number;
  49604. updatable?: boolean;
  49605. }, scene: any): Mesh;
  49606. /**
  49607. * Creates a tiled ground mesh
  49608. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49609. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49610. * * 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
  49611. * * 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
  49612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49613. * @param name defines the name of the mesh
  49614. * @param options defines the options used to create the mesh
  49615. * @param scene defines the hosting scene
  49616. * @returns the tiled ground mesh
  49617. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49618. */
  49619. static CreateTiledGround(name: string, options: {
  49620. xmin: number;
  49621. zmin: number;
  49622. xmax: number;
  49623. zmax: number;
  49624. subdivisions?: {
  49625. w: number;
  49626. h: number;
  49627. };
  49628. precision?: {
  49629. w: number;
  49630. h: number;
  49631. };
  49632. updatable?: boolean;
  49633. }, scene: Scene): Mesh;
  49634. /**
  49635. * Creates a ground mesh from a height map
  49636. * * The parameter `url` sets the URL of the height map image resource.
  49637. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49638. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49639. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49640. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49641. * * 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.
  49642. * * 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).
  49643. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49645. * @param name defines the name of the mesh
  49646. * @param url defines the url to the height map
  49647. * @param options defines the options used to create the mesh
  49648. * @param scene defines the hosting scene
  49649. * @returns the ground mesh
  49650. * @see https://doc.babylonjs.com/babylon101/height_map
  49651. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49652. */
  49653. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49654. width?: number;
  49655. height?: number;
  49656. subdivisions?: number;
  49657. minHeight?: number;
  49658. maxHeight?: number;
  49659. colorFilter?: Color3;
  49660. alphaFilter?: number;
  49661. updatable?: boolean;
  49662. onReady?: (mesh: GroundMesh) => void;
  49663. }, scene: Scene): GroundMesh;
  49664. /**
  49665. * Creates a polygon mesh
  49666. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49667. * * 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
  49668. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49669. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  49671. * * Remember you can only change the shape positions, not their number when updating a polygon
  49672. * @param name defines the name of the mesh
  49673. * @param options defines the options used to create the mesh
  49674. * @param scene defines the hosting scene
  49675. * @param earcutInjection can be used to inject your own earcut reference
  49676. * @returns the polygon mesh
  49677. */
  49678. static CreatePolygon(name: string, options: {
  49679. shape: Vector3[];
  49680. holes?: Vector3[][];
  49681. depth?: number;
  49682. faceUV?: Vector4[];
  49683. faceColors?: Color4[];
  49684. updatable?: boolean;
  49685. sideOrientation?: number;
  49686. frontUVs?: Vector4;
  49687. backUVs?: Vector4;
  49688. }, scene: Scene, earcutInjection?: any): Mesh;
  49689. /**
  49690. * Creates an extruded polygon mesh, with depth in the Y direction.
  49691. * * 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)
  49692. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49693. * @param name defines the name of the mesh
  49694. * @param options defines the options used to create the mesh
  49695. * @param scene defines the hosting scene
  49696. * @param earcutInjection can be used to inject your own earcut reference
  49697. * @returns the polygon mesh
  49698. */
  49699. static ExtrudePolygon(name: string, options: {
  49700. shape: Vector3[];
  49701. holes?: Vector3[][];
  49702. depth?: number;
  49703. faceUV?: Vector4[];
  49704. faceColors?: Color4[];
  49705. updatable?: boolean;
  49706. sideOrientation?: number;
  49707. frontUVs?: Vector4;
  49708. backUVs?: Vector4;
  49709. }, scene: Scene, earcutInjection?: any): Mesh;
  49710. /**
  49711. * Creates a tube mesh.
  49712. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49713. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49714. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49715. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49716. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49717. * * 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)
  49718. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49719. * * 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
  49720. * * 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
  49721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49722. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49723. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49725. * @param name defines the name of the mesh
  49726. * @param options defines the options used to create the mesh
  49727. * @param scene defines the hosting scene
  49728. * @returns the tube mesh
  49729. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49730. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49731. */
  49732. static CreateTube(name: string, options: {
  49733. path: Vector3[];
  49734. radius?: number;
  49735. tessellation?: number;
  49736. radiusFunction?: {
  49737. (i: number, distance: number): number;
  49738. };
  49739. cap?: number;
  49740. arc?: number;
  49741. updatable?: boolean;
  49742. sideOrientation?: number;
  49743. frontUVs?: Vector4;
  49744. backUVs?: Vector4;
  49745. instance?: Mesh;
  49746. invertUV?: boolean;
  49747. }, scene: Scene): Mesh;
  49748. /**
  49749. * Creates a polyhedron mesh
  49750. * * 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
  49751. * * The parameter `size` (positive float, default 1) sets the polygon size
  49752. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49753. * * 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`
  49754. * * 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
  49755. * * 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)`)
  49756. * * 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
  49757. * * 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
  49758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49761. * @param name defines the name of the mesh
  49762. * @param options defines the options used to create the mesh
  49763. * @param scene defines the hosting scene
  49764. * @returns the polyhedron mesh
  49765. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49766. */
  49767. static CreatePolyhedron(name: string, options: {
  49768. type?: number;
  49769. size?: number;
  49770. sizeX?: number;
  49771. sizeY?: number;
  49772. sizeZ?: number;
  49773. custom?: any;
  49774. faceUV?: Vector4[];
  49775. faceColors?: Color4[];
  49776. flat?: boolean;
  49777. updatable?: boolean;
  49778. sideOrientation?: number;
  49779. frontUVs?: Vector4;
  49780. backUVs?: Vector4;
  49781. }, scene: Scene): Mesh;
  49782. /**
  49783. * Creates a decal mesh.
  49784. * 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
  49785. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49786. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49787. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49788. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49789. * @param name defines the name of the mesh
  49790. * @param sourceMesh defines the mesh where the decal must be applied
  49791. * @param options defines the options used to create the mesh
  49792. * @param scene defines the hosting scene
  49793. * @returns the decal mesh
  49794. * @see https://doc.babylonjs.com/how_to/decals
  49795. */
  49796. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49797. position?: Vector3;
  49798. normal?: Vector3;
  49799. size?: Vector3;
  49800. angle?: number;
  49801. }): Mesh;
  49802. }
  49803. }
  49804. declare module "babylonjs/Meshes/meshSimplification" {
  49805. import { Mesh } from "babylonjs/Meshes/mesh";
  49806. /**
  49807. * A simplifier interface for future simplification implementations
  49808. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49809. */
  49810. export interface ISimplifier {
  49811. /**
  49812. * Simplification of a given mesh according to the given settings.
  49813. * Since this requires computation, it is assumed that the function runs async.
  49814. * @param settings The settings of the simplification, including quality and distance
  49815. * @param successCallback A callback that will be called after the mesh was simplified.
  49816. * @param errorCallback in case of an error, this callback will be called. optional.
  49817. */
  49818. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49819. }
  49820. /**
  49821. * Expected simplification settings.
  49822. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49823. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49824. */
  49825. export interface ISimplificationSettings {
  49826. /**
  49827. * Gets or sets the expected quality
  49828. */
  49829. quality: number;
  49830. /**
  49831. * Gets or sets the distance when this optimized version should be used
  49832. */
  49833. distance: number;
  49834. /**
  49835. * Gets an already optimized mesh
  49836. */
  49837. optimizeMesh?: boolean;
  49838. }
  49839. /**
  49840. * Class used to specify simplification options
  49841. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49842. */
  49843. export class SimplificationSettings implements ISimplificationSettings {
  49844. /** expected quality */
  49845. quality: number;
  49846. /** distance when this optimized version should be used */
  49847. distance: number;
  49848. /** already optimized mesh */
  49849. optimizeMesh?: boolean | undefined;
  49850. /**
  49851. * Creates a SimplificationSettings
  49852. * @param quality expected quality
  49853. * @param distance distance when this optimized version should be used
  49854. * @param optimizeMesh already optimized mesh
  49855. */
  49856. constructor(
  49857. /** expected quality */
  49858. quality: number,
  49859. /** distance when this optimized version should be used */
  49860. distance: number,
  49861. /** already optimized mesh */
  49862. optimizeMesh?: boolean | undefined);
  49863. }
  49864. /**
  49865. * Interface used to define a simplification task
  49866. */
  49867. export interface ISimplificationTask {
  49868. /**
  49869. * Array of settings
  49870. */
  49871. settings: Array<ISimplificationSettings>;
  49872. /**
  49873. * Simplification type
  49874. */
  49875. simplificationType: SimplificationType;
  49876. /**
  49877. * Mesh to simplify
  49878. */
  49879. mesh: Mesh;
  49880. /**
  49881. * Callback called on success
  49882. */
  49883. successCallback?: () => void;
  49884. /**
  49885. * Defines if parallel processing can be used
  49886. */
  49887. parallelProcessing: boolean;
  49888. }
  49889. /**
  49890. * Queue used to order the simplification tasks
  49891. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49892. */
  49893. export class SimplificationQueue {
  49894. private _simplificationArray;
  49895. /**
  49896. * Gets a boolean indicating that the process is still running
  49897. */
  49898. running: boolean;
  49899. /**
  49900. * Creates a new queue
  49901. */
  49902. constructor();
  49903. /**
  49904. * Adds a new simplification task
  49905. * @param task defines a task to add
  49906. */
  49907. addTask(task: ISimplificationTask): void;
  49908. /**
  49909. * Execute next task
  49910. */
  49911. executeNext(): void;
  49912. /**
  49913. * Execute a simplification task
  49914. * @param task defines the task to run
  49915. */
  49916. runSimplification(task: ISimplificationTask): void;
  49917. private getSimplifier;
  49918. }
  49919. /**
  49920. * The implemented types of simplification
  49921. * At the moment only Quadratic Error Decimation is implemented
  49922. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49923. */
  49924. export enum SimplificationType {
  49925. /** Quadratic error decimation */
  49926. QUADRATIC = 0
  49927. }
  49928. }
  49929. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  49930. import { Scene } from "babylonjs/scene";
  49931. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  49932. import { ISceneComponent } from "babylonjs/sceneComponent";
  49933. module "babylonjs/scene" {
  49934. interface Scene {
  49935. /** @hidden (Backing field) */
  49936. _simplificationQueue: SimplificationQueue;
  49937. /**
  49938. * Gets or sets the simplification queue attached to the scene
  49939. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49940. */
  49941. simplificationQueue: SimplificationQueue;
  49942. }
  49943. }
  49944. module "babylonjs/Meshes/mesh" {
  49945. interface Mesh {
  49946. /**
  49947. * Simplify the mesh according to the given array of settings.
  49948. * Function will return immediately and will simplify async
  49949. * @param settings a collection of simplification settings
  49950. * @param parallelProcessing should all levels calculate parallel or one after the other
  49951. * @param simplificationType the type of simplification to run
  49952. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49953. * @returns the current mesh
  49954. */
  49955. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49956. }
  49957. }
  49958. /**
  49959. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49960. * created in a scene
  49961. */
  49962. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49963. /**
  49964. * The component name helpfull to identify the component in the list of scene components.
  49965. */
  49966. readonly name: string;
  49967. /**
  49968. * The scene the component belongs to.
  49969. */
  49970. scene: Scene;
  49971. /**
  49972. * Creates a new instance of the component for the given scene
  49973. * @param scene Defines the scene to register the component in
  49974. */
  49975. constructor(scene: Scene);
  49976. /**
  49977. * Registers the component in a given scene
  49978. */
  49979. register(): void;
  49980. /**
  49981. * Rebuilds the elements related to this component in case of
  49982. * context lost for instance.
  49983. */
  49984. rebuild(): void;
  49985. /**
  49986. * Disposes the component and the associated ressources
  49987. */
  49988. dispose(): void;
  49989. private _beforeCameraUpdate;
  49990. }
  49991. }
  49992. declare module "babylonjs/Meshes/Builders/index" {
  49993. export * from "babylonjs/Meshes/Builders/boxBuilder";
  49994. export * from "babylonjs/Meshes/Builders/discBuilder";
  49995. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  49996. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  49997. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  49998. export * from "babylonjs/Meshes/Builders/torusBuilder";
  49999. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  50000. export * from "babylonjs/Meshes/Builders/linesBuilder";
  50001. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  50002. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  50003. export * from "babylonjs/Meshes/Builders/latheBuilder";
  50004. export * from "babylonjs/Meshes/Builders/planeBuilder";
  50005. export * from "babylonjs/Meshes/Builders/groundBuilder";
  50006. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  50007. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  50008. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  50009. export * from "babylonjs/Meshes/Builders/decalBuilder";
  50010. }
  50011. declare module "babylonjs/Meshes/index" {
  50012. export * from "babylonjs/Meshes/abstractMesh";
  50013. export * from "babylonjs/Meshes/buffer";
  50014. export * from "babylonjs/Meshes/Compression/index";
  50015. export * from "babylonjs/Meshes/csg";
  50016. export * from "babylonjs/Meshes/geometry";
  50017. export * from "babylonjs/Meshes/groundMesh";
  50018. export * from "babylonjs/Meshes/instancedMesh";
  50019. export * from "babylonjs/Meshes/linesMesh";
  50020. export * from "babylonjs/Meshes/mesh";
  50021. export * from "babylonjs/Meshes/mesh.vertexData";
  50022. export * from "babylonjs/Meshes/meshBuilder";
  50023. export * from "babylonjs/Meshes/meshSimplification";
  50024. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  50025. export * from "babylonjs/Meshes/polygonMesh";
  50026. export * from "babylonjs/Meshes/subMesh";
  50027. export * from "babylonjs/Meshes/transformNode";
  50028. export * from "babylonjs/Meshes/Builders/index";
  50029. }
  50030. declare module "babylonjs/Morph/index" {
  50031. export * from "babylonjs/Morph/morphTarget";
  50032. export * from "babylonjs/Morph/morphTargetManager";
  50033. }
  50034. declare module "babylonjs/Offline/database" {
  50035. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  50036. /**
  50037. * Class used to enable access to IndexedDB
  50038. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50039. */
  50040. export class Database implements IOfflineProvider {
  50041. private _callbackManifestChecked;
  50042. private _currentSceneUrl;
  50043. private _db;
  50044. private _enableSceneOffline;
  50045. private _enableTexturesOffline;
  50046. private _manifestVersionFound;
  50047. private _mustUpdateRessources;
  50048. private _hasReachedQuota;
  50049. private _isSupported;
  50050. private _idbFactory;
  50051. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50052. private static IsUASupportingBlobStorage;
  50053. /**
  50054. * Gets a boolean indicating if Database storate is enabled (off by default)
  50055. */
  50056. static IDBStorageEnabled: boolean;
  50057. /**
  50058. * Gets a boolean indicating if scene must be saved in the database
  50059. */
  50060. readonly enableSceneOffline: boolean;
  50061. /**
  50062. * Gets a boolean indicating if textures must be saved in the database
  50063. */
  50064. readonly enableTexturesOffline: boolean;
  50065. /**
  50066. * Creates a new Database
  50067. * @param urlToScene defines the url to load the scene
  50068. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50069. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50070. */
  50071. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50072. private static _ParseURL;
  50073. private static _ReturnFullUrlLocation;
  50074. private _checkManifestFile;
  50075. /**
  50076. * Open the database and make it available
  50077. * @param successCallback defines the callback to call on success
  50078. * @param errorCallback defines the callback to call on error
  50079. */
  50080. open(successCallback: () => void, errorCallback: () => void): void;
  50081. /**
  50082. * Loads an image from the database
  50083. * @param url defines the url to load from
  50084. * @param image defines the target DOM image
  50085. */
  50086. loadImage(url: string, image: HTMLImageElement): void;
  50087. private _loadImageFromDBAsync;
  50088. private _saveImageIntoDBAsync;
  50089. private _checkVersionFromDB;
  50090. private _loadVersionFromDBAsync;
  50091. private _saveVersionIntoDBAsync;
  50092. /**
  50093. * Loads a file from database
  50094. * @param url defines the URL to load from
  50095. * @param sceneLoaded defines a callback to call on success
  50096. * @param progressCallBack defines a callback to call when progress changed
  50097. * @param errorCallback defines a callback to call on error
  50098. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50099. */
  50100. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50101. private _loadFileAsync;
  50102. private _saveFileAsync;
  50103. /**
  50104. * Validates if xhr data is correct
  50105. * @param xhr defines the request to validate
  50106. * @param dataType defines the expected data type
  50107. * @returns true if data is correct
  50108. */
  50109. private static _ValidateXHRData;
  50110. }
  50111. }
  50112. declare module "babylonjs/Offline/index" {
  50113. export * from "babylonjs/Offline/database";
  50114. export * from "babylonjs/Offline/IOfflineProvider";
  50115. }
  50116. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  50117. /** @hidden */
  50118. export var gpuUpdateParticlesPixelShader: {
  50119. name: string;
  50120. shader: string;
  50121. };
  50122. }
  50123. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  50124. /** @hidden */
  50125. export var gpuUpdateParticlesVertexShader: {
  50126. name: string;
  50127. shader: string;
  50128. };
  50129. }
  50130. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  50131. /** @hidden */
  50132. export var clipPlaneFragmentDeclaration2: {
  50133. name: string;
  50134. shader: string;
  50135. };
  50136. }
  50137. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  50138. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  50139. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  50140. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  50141. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  50142. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  50143. /** @hidden */
  50144. export var gpuRenderParticlesPixelShader: {
  50145. name: string;
  50146. shader: string;
  50147. };
  50148. }
  50149. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  50150. /** @hidden */
  50151. export var clipPlaneVertexDeclaration2: {
  50152. name: string;
  50153. shader: string;
  50154. };
  50155. }
  50156. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  50157. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  50158. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  50159. /** @hidden */
  50160. export var gpuRenderParticlesVertexShader: {
  50161. name: string;
  50162. shader: string;
  50163. };
  50164. }
  50165. declare module "babylonjs/Particles/gpuParticleSystem" {
  50166. import { Nullable } from "babylonjs/types";
  50167. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  50168. import { Observable } from "babylonjs/Misc/observable";
  50169. import { Color4, Color3 } from "babylonjs/Maths/math";
  50170. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50171. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  50172. import { Scene, IDisposable } from "babylonjs/scene";
  50173. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  50174. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  50175. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  50176. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  50177. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  50178. /**
  50179. * This represents a GPU particle system in Babylon
  50180. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50181. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50182. */
  50183. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50184. /**
  50185. * The layer mask we are rendering the particles through.
  50186. */
  50187. layerMask: number;
  50188. private _capacity;
  50189. private _activeCount;
  50190. private _currentActiveCount;
  50191. private _accumulatedCount;
  50192. private _renderEffect;
  50193. private _updateEffect;
  50194. private _buffer0;
  50195. private _buffer1;
  50196. private _spriteBuffer;
  50197. private _updateVAO;
  50198. private _renderVAO;
  50199. private _targetIndex;
  50200. private _sourceBuffer;
  50201. private _targetBuffer;
  50202. private _engine;
  50203. private _currentRenderId;
  50204. private _started;
  50205. private _stopped;
  50206. private _timeDelta;
  50207. private _randomTexture;
  50208. private _randomTexture2;
  50209. private _attributesStrideSize;
  50210. private _updateEffectOptions;
  50211. private _randomTextureSize;
  50212. private _actualFrame;
  50213. private readonly _rawTextureWidth;
  50214. /**
  50215. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50216. */
  50217. static readonly IsSupported: boolean;
  50218. /**
  50219. * An event triggered when the system is disposed.
  50220. */
  50221. onDisposeObservable: Observable<GPUParticleSystem>;
  50222. /**
  50223. * Gets the maximum number of particles active at the same time.
  50224. * @returns The max number of active particles.
  50225. */
  50226. getCapacity(): number;
  50227. /**
  50228. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50229. * to override the particles.
  50230. */
  50231. forceDepthWrite: boolean;
  50232. /**
  50233. * Gets or set the number of active particles
  50234. */
  50235. activeParticleCount: number;
  50236. private _preWarmDone;
  50237. /**
  50238. * Is this system ready to be used/rendered
  50239. * @return true if the system is ready
  50240. */
  50241. isReady(): boolean;
  50242. /**
  50243. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50244. * @returns True if it has been started, otherwise false.
  50245. */
  50246. isStarted(): boolean;
  50247. /**
  50248. * Starts the particle system and begins to emit
  50249. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50250. */
  50251. start(delay?: number): void;
  50252. /**
  50253. * Stops the particle system.
  50254. */
  50255. stop(): void;
  50256. /**
  50257. * Remove all active particles
  50258. */
  50259. reset(): void;
  50260. /**
  50261. * Returns the string "GPUParticleSystem"
  50262. * @returns a string containing the class name
  50263. */
  50264. getClassName(): string;
  50265. private _colorGradientsTexture;
  50266. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50267. /**
  50268. * Adds a new color gradient
  50269. * @param gradient defines the gradient to use (between 0 and 1)
  50270. * @param color1 defines the color to affect to the specified gradient
  50271. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50272. * @returns the current particle system
  50273. */
  50274. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50275. /**
  50276. * Remove a specific color gradient
  50277. * @param gradient defines the gradient to remove
  50278. * @returns the current particle system
  50279. */
  50280. removeColorGradient(gradient: number): GPUParticleSystem;
  50281. private _angularSpeedGradientsTexture;
  50282. private _sizeGradientsTexture;
  50283. private _velocityGradientsTexture;
  50284. private _limitVelocityGradientsTexture;
  50285. private _dragGradientsTexture;
  50286. private _addFactorGradient;
  50287. /**
  50288. * Adds a new size gradient
  50289. * @param gradient defines the gradient to use (between 0 and 1)
  50290. * @param factor defines the size factor to affect to the specified gradient
  50291. * @returns the current particle system
  50292. */
  50293. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50294. /**
  50295. * Remove a specific size gradient
  50296. * @param gradient defines the gradient to remove
  50297. * @returns the current particle system
  50298. */
  50299. removeSizeGradient(gradient: number): GPUParticleSystem;
  50300. /**
  50301. * Adds a new angular speed gradient
  50302. * @param gradient defines the gradient to use (between 0 and 1)
  50303. * @param factor defines the angular speed to affect to the specified gradient
  50304. * @returns the current particle system
  50305. */
  50306. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50307. /**
  50308. * Remove a specific angular speed gradient
  50309. * @param gradient defines the gradient to remove
  50310. * @returns the current particle system
  50311. */
  50312. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50313. /**
  50314. * Adds a new velocity gradient
  50315. * @param gradient defines the gradient to use (between 0 and 1)
  50316. * @param factor defines the velocity to affect to the specified gradient
  50317. * @returns the current particle system
  50318. */
  50319. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50320. /**
  50321. * Remove a specific velocity gradient
  50322. * @param gradient defines the gradient to remove
  50323. * @returns the current particle system
  50324. */
  50325. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50326. /**
  50327. * Adds a new limit velocity gradient
  50328. * @param gradient defines the gradient to use (between 0 and 1)
  50329. * @param factor defines the limit velocity value to affect to the specified gradient
  50330. * @returns the current particle system
  50331. */
  50332. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50333. /**
  50334. * Remove a specific limit velocity gradient
  50335. * @param gradient defines the gradient to remove
  50336. * @returns the current particle system
  50337. */
  50338. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50339. /**
  50340. * Adds a new drag gradient
  50341. * @param gradient defines the gradient to use (between 0 and 1)
  50342. * @param factor defines the drag value to affect to the specified gradient
  50343. * @returns the current particle system
  50344. */
  50345. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50346. /**
  50347. * Remove a specific drag gradient
  50348. * @param gradient defines the gradient to remove
  50349. * @returns the current particle system
  50350. */
  50351. removeDragGradient(gradient: number): GPUParticleSystem;
  50352. /**
  50353. * Not supported by GPUParticleSystem
  50354. * @param gradient defines the gradient to use (between 0 and 1)
  50355. * @param factor defines the emit rate value to affect to the specified gradient
  50356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50357. * @returns the current particle system
  50358. */
  50359. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50360. /**
  50361. * Not supported by GPUParticleSystem
  50362. * @param gradient defines the gradient to remove
  50363. * @returns the current particle system
  50364. */
  50365. removeEmitRateGradient(gradient: number): IParticleSystem;
  50366. /**
  50367. * Not supported by GPUParticleSystem
  50368. * @param gradient defines the gradient to use (between 0 and 1)
  50369. * @param factor defines the start size value to affect to the specified gradient
  50370. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50371. * @returns the current particle system
  50372. */
  50373. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50374. /**
  50375. * Not supported by GPUParticleSystem
  50376. * @param gradient defines the gradient to remove
  50377. * @returns the current particle system
  50378. */
  50379. removeStartSizeGradient(gradient: number): IParticleSystem;
  50380. /**
  50381. * Not supported by GPUParticleSystem
  50382. * @param gradient defines the gradient to use (between 0 and 1)
  50383. * @param min defines the color remap minimal range
  50384. * @param max defines the color remap maximal range
  50385. * @returns the current particle system
  50386. */
  50387. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50388. /**
  50389. * Not supported by GPUParticleSystem
  50390. * @param gradient defines the gradient to remove
  50391. * @returns the current particle system
  50392. */
  50393. removeColorRemapGradient(): IParticleSystem;
  50394. /**
  50395. * Not supported by GPUParticleSystem
  50396. * @param gradient defines the gradient to use (between 0 and 1)
  50397. * @param min defines the alpha remap minimal range
  50398. * @param max defines the alpha remap maximal range
  50399. * @returns the current particle system
  50400. */
  50401. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50402. /**
  50403. * Not supported by GPUParticleSystem
  50404. * @param gradient defines the gradient to remove
  50405. * @returns the current particle system
  50406. */
  50407. removeAlphaRemapGradient(): IParticleSystem;
  50408. /**
  50409. * Not supported by GPUParticleSystem
  50410. * @param gradient defines the gradient to use (between 0 and 1)
  50411. * @param color defines the color to affect to the specified gradient
  50412. * @returns the current particle system
  50413. */
  50414. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50415. /**
  50416. * Not supported by GPUParticleSystem
  50417. * @param gradient defines the gradient to remove
  50418. * @returns the current particle system
  50419. */
  50420. removeRampGradient(): IParticleSystem;
  50421. /**
  50422. * Not supported by GPUParticleSystem
  50423. * @returns the list of ramp gradients
  50424. */
  50425. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50426. /**
  50427. * Not supported by GPUParticleSystem
  50428. * Gets or sets a boolean indicating that ramp gradients must be used
  50429. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50430. */
  50431. useRampGradients: boolean;
  50432. /**
  50433. * Not supported by GPUParticleSystem
  50434. * @param gradient defines the gradient to use (between 0 and 1)
  50435. * @param factor defines the life time factor to affect to the specified gradient
  50436. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50437. * @returns the current particle system
  50438. */
  50439. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50440. /**
  50441. * Not supported by GPUParticleSystem
  50442. * @param gradient defines the gradient to remove
  50443. * @returns the current particle system
  50444. */
  50445. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50446. /**
  50447. * Instantiates a GPU particle system.
  50448. * 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.
  50449. * @param name The name of the particle system
  50450. * @param options The options used to create the system
  50451. * @param scene The scene the particle system belongs to
  50452. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50453. */
  50454. constructor(name: string, options: Partial<{
  50455. capacity: number;
  50456. randomTextureSize: number;
  50457. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50458. protected _reset(): void;
  50459. private _createUpdateVAO;
  50460. private _createRenderVAO;
  50461. private _initialize;
  50462. /** @hidden */
  50463. _recreateUpdateEffect(): void;
  50464. /** @hidden */
  50465. _recreateRenderEffect(): void;
  50466. /**
  50467. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50468. * @param preWarm defines if we are in the pre-warmimg phase
  50469. */
  50470. animate(preWarm?: boolean): void;
  50471. private _createFactorGradientTexture;
  50472. private _createSizeGradientTexture;
  50473. private _createAngularSpeedGradientTexture;
  50474. private _createVelocityGradientTexture;
  50475. private _createLimitVelocityGradientTexture;
  50476. private _createDragGradientTexture;
  50477. private _createColorGradientTexture;
  50478. /**
  50479. * Renders the particle system in its current state
  50480. * @param preWarm defines if the system should only update the particles but not render them
  50481. * @returns the current number of particles
  50482. */
  50483. render(preWarm?: boolean): number;
  50484. /**
  50485. * Rebuilds the particle system
  50486. */
  50487. rebuild(): void;
  50488. private _releaseBuffers;
  50489. private _releaseVAOs;
  50490. /**
  50491. * Disposes the particle system and free the associated resources
  50492. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50493. */
  50494. dispose(disposeTexture?: boolean): void;
  50495. /**
  50496. * Clones the particle system.
  50497. * @param name The name of the cloned object
  50498. * @param newEmitter The new emitter to use
  50499. * @returns the cloned particle system
  50500. */
  50501. clone(name: string, newEmitter: any): GPUParticleSystem;
  50502. /**
  50503. * Serializes the particle system to a JSON object.
  50504. * @returns the JSON object
  50505. */
  50506. serialize(): any;
  50507. /**
  50508. * Parses a JSON object to create a GPU particle system.
  50509. * @param parsedParticleSystem The JSON object to parse
  50510. * @param scene The scene to create the particle system in
  50511. * @param rootUrl The root url to use to load external dependencies like texture
  50512. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50513. * @returns the parsed GPU particle system
  50514. */
  50515. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50516. }
  50517. }
  50518. declare module "babylonjs/Particles/particleSystemSet" {
  50519. import { Nullable } from "babylonjs/types";
  50520. import { Color3 } from "babylonjs/Maths/math";
  50521. import { TransformNode } from "babylonjs/Meshes/transformNode";
  50522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50523. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50524. import { Scene, IDisposable } from "babylonjs/scene";
  50525. /**
  50526. * Represents a set of particle systems working together to create a specific effect
  50527. */
  50528. export class ParticleSystemSet implements IDisposable {
  50529. private _emitterCreationOptions;
  50530. private _emitterNode;
  50531. /**
  50532. * Gets the particle system list
  50533. */
  50534. systems: IParticleSystem[];
  50535. /**
  50536. * Gets the emitter node used with this set
  50537. */
  50538. readonly emitterNode: Nullable<TransformNode>;
  50539. /**
  50540. * Creates a new emitter mesh as a sphere
  50541. * @param options defines the options used to create the sphere
  50542. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50543. * @param scene defines the hosting scene
  50544. */
  50545. setEmitterAsSphere(options: {
  50546. diameter: number;
  50547. segments: number;
  50548. color: Color3;
  50549. }, renderingGroupId: number, scene: Scene): void;
  50550. /**
  50551. * Starts all particle systems of the set
  50552. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50553. */
  50554. start(emitter?: AbstractMesh): void;
  50555. /**
  50556. * Release all associated resources
  50557. */
  50558. dispose(): void;
  50559. /**
  50560. * Serialize the set into a JSON compatible object
  50561. * @returns a JSON compatible representation of the set
  50562. */
  50563. serialize(): any;
  50564. /**
  50565. * Parse a new ParticleSystemSet from a serialized source
  50566. * @param data defines a JSON compatible representation of the set
  50567. * @param scene defines the hosting scene
  50568. * @param gpu defines if we want GPU particles or CPU particles
  50569. * @returns a new ParticleSystemSet
  50570. */
  50571. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50572. }
  50573. }
  50574. declare module "babylonjs/Particles/particleHelper" {
  50575. import { Nullable } from "babylonjs/types";
  50576. import { Scene } from "babylonjs/scene";
  50577. import { Vector3 } from "babylonjs/Maths/math";
  50578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50579. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50580. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  50581. /**
  50582. * This class is made for on one-liner static method to help creating particle system set.
  50583. */
  50584. export class ParticleHelper {
  50585. /**
  50586. * Gets or sets base Assets URL
  50587. */
  50588. static BaseAssetsUrl: string;
  50589. /**
  50590. * Create a default particle system that you can tweak
  50591. * @param emitter defines the emitter to use
  50592. * @param capacity defines the system capacity (default is 500 particles)
  50593. * @param scene defines the hosting scene
  50594. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50595. * @returns the new Particle system
  50596. */
  50597. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50598. /**
  50599. * This is the main static method (one-liner) of this helper to create different particle systems
  50600. * @param type This string represents the type to the particle system to create
  50601. * @param scene The scene where the particle system should live
  50602. * @param gpu If the system will use gpu
  50603. * @returns the ParticleSystemSet created
  50604. */
  50605. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50606. /**
  50607. * Static function used to export a particle system to a ParticleSystemSet variable.
  50608. * Please note that the emitter shape is not exported
  50609. * @param systems defines the particle systems to export
  50610. * @returns the created particle system set
  50611. */
  50612. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50613. }
  50614. }
  50615. declare module "babylonjs/Particles/particleSystemComponent" {
  50616. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  50617. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  50618. import "babylonjs/Shaders/particles.vertex";
  50619. module "babylonjs/Engines/engine" {
  50620. interface Engine {
  50621. /**
  50622. * Create an effect to use with particle systems.
  50623. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50624. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50625. * @param uniformsNames defines a list of attribute names
  50626. * @param samplers defines an array of string used to represent textures
  50627. * @param defines defines the string containing the defines to use to compile the shaders
  50628. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50629. * @param onCompiled defines a function to call when the effect creation is successful
  50630. * @param onError defines a function to call when the effect creation has failed
  50631. * @returns the new Effect
  50632. */
  50633. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50634. }
  50635. }
  50636. module "babylonjs/Meshes/mesh" {
  50637. interface Mesh {
  50638. /**
  50639. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50640. * @returns an array of IParticleSystem
  50641. */
  50642. getEmittedParticleSystems(): IParticleSystem[];
  50643. /**
  50644. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50645. * @returns an array of IParticleSystem
  50646. */
  50647. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50648. }
  50649. }
  50650. /**
  50651. * @hidden
  50652. */
  50653. export var _IDoNeedToBeInTheBuild: number;
  50654. }
  50655. declare module "babylonjs/Particles/index" {
  50656. export * from "babylonjs/Particles/baseParticleSystem";
  50657. export * from "babylonjs/Particles/EmitterTypes/index";
  50658. export * from "babylonjs/Particles/gpuParticleSystem";
  50659. export * from "babylonjs/Particles/IParticleSystem";
  50660. export * from "babylonjs/Particles/particle";
  50661. export * from "babylonjs/Particles/particleHelper";
  50662. export * from "babylonjs/Particles/particleSystem";
  50663. export * from "babylonjs/Particles/particleSystemComponent";
  50664. export * from "babylonjs/Particles/particleSystemSet";
  50665. export * from "babylonjs/Particles/solidParticle";
  50666. export * from "babylonjs/Particles/solidParticleSystem";
  50667. export * from "babylonjs/Particles/subEmitter";
  50668. }
  50669. declare module "babylonjs/Physics/physicsEngineComponent" {
  50670. import { Nullable } from "babylonjs/types";
  50671. import { Observable, Observer } from "babylonjs/Misc/observable";
  50672. import { Vector3 } from "babylonjs/Maths/math";
  50673. import { Mesh } from "babylonjs/Meshes/mesh";
  50674. import { ISceneComponent } from "babylonjs/sceneComponent";
  50675. import { Scene } from "babylonjs/scene";
  50676. import { Node } from "babylonjs/node";
  50677. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50678. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50679. module "babylonjs/scene" {
  50680. interface Scene {
  50681. /** @hidden (Backing field) */
  50682. _physicsEngine: Nullable<IPhysicsEngine>;
  50683. /**
  50684. * Gets the current physics engine
  50685. * @returns a IPhysicsEngine or null if none attached
  50686. */
  50687. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50688. /**
  50689. * Enables physics to the current scene
  50690. * @param gravity defines the scene's gravity for the physics engine
  50691. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50692. * @return a boolean indicating if the physics engine was initialized
  50693. */
  50694. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50695. /**
  50696. * Disables and disposes the physics engine associated with the scene
  50697. */
  50698. disablePhysicsEngine(): void;
  50699. /**
  50700. * Gets a boolean indicating if there is an active physics engine
  50701. * @returns a boolean indicating if there is an active physics engine
  50702. */
  50703. isPhysicsEnabled(): boolean;
  50704. /**
  50705. * Deletes a physics compound impostor
  50706. * @param compound defines the compound to delete
  50707. */
  50708. deleteCompoundImpostor(compound: any): void;
  50709. /**
  50710. * An event triggered when physic simulation is about to be run
  50711. */
  50712. onBeforePhysicsObservable: Observable<Scene>;
  50713. /**
  50714. * An event triggered when physic simulation has been done
  50715. */
  50716. onAfterPhysicsObservable: Observable<Scene>;
  50717. }
  50718. }
  50719. module "babylonjs/Meshes/abstractMesh" {
  50720. interface AbstractMesh {
  50721. /** @hidden */
  50722. _physicsImpostor: Nullable<PhysicsImpostor>;
  50723. /**
  50724. * Gets or sets impostor used for physic simulation
  50725. * @see http://doc.babylonjs.com/features/physics_engine
  50726. */
  50727. physicsImpostor: Nullable<PhysicsImpostor>;
  50728. /**
  50729. * Gets the current physics impostor
  50730. * @see http://doc.babylonjs.com/features/physics_engine
  50731. * @returns a physics impostor or null
  50732. */
  50733. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50734. /** Apply a physic impulse to the mesh
  50735. * @param force defines the force to apply
  50736. * @param contactPoint defines where to apply the force
  50737. * @returns the current mesh
  50738. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50739. */
  50740. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50741. /**
  50742. * Creates a physic joint between two meshes
  50743. * @param otherMesh defines the other mesh to use
  50744. * @param pivot1 defines the pivot to use on this mesh
  50745. * @param pivot2 defines the pivot to use on the other mesh
  50746. * @param options defines additional options (can be plugin dependent)
  50747. * @returns the current mesh
  50748. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50749. */
  50750. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50751. /** @hidden */
  50752. _disposePhysicsObserver: Nullable<Observer<Node>>;
  50753. }
  50754. }
  50755. /**
  50756. * Defines the physics engine scene component responsible to manage a physics engine
  50757. */
  50758. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50759. /**
  50760. * The component name helpful to identify the component in the list of scene components.
  50761. */
  50762. readonly name: string;
  50763. /**
  50764. * The scene the component belongs to.
  50765. */
  50766. scene: Scene;
  50767. /**
  50768. * Creates a new instance of the component for the given scene
  50769. * @param scene Defines the scene to register the component in
  50770. */
  50771. constructor(scene: Scene);
  50772. /**
  50773. * Registers the component in a given scene
  50774. */
  50775. register(): void;
  50776. /**
  50777. * Rebuilds the elements related to this component in case of
  50778. * context lost for instance.
  50779. */
  50780. rebuild(): void;
  50781. /**
  50782. * Disposes the component and the associated ressources
  50783. */
  50784. dispose(): void;
  50785. }
  50786. }
  50787. declare module "babylonjs/Physics/physicsHelper" {
  50788. import { Nullable } from "babylonjs/types";
  50789. import { Vector3 } from "babylonjs/Maths/math";
  50790. import { Mesh } from "babylonjs/Meshes/mesh";
  50791. import { Ray } from "babylonjs/Culling/ray";
  50792. import { Scene } from "babylonjs/scene";
  50793. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50794. /**
  50795. * A helper for physics simulations
  50796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50797. */
  50798. export class PhysicsHelper {
  50799. private _scene;
  50800. private _physicsEngine;
  50801. /**
  50802. * Initializes the Physics helper
  50803. * @param scene Babylon.js scene
  50804. */
  50805. constructor(scene: Scene);
  50806. /**
  50807. * Applies a radial explosion impulse
  50808. * @param origin the origin of the explosion
  50809. * @param radius the explosion radius
  50810. * @param strength the explosion strength
  50811. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50812. * @returns A physics radial explosion event, or null
  50813. */
  50814. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50815. /**
  50816. * Applies a radial explosion force
  50817. * @param origin the origin of the explosion
  50818. * @param radius the explosion radius
  50819. * @param strength the explosion strength
  50820. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50821. * @returns A physics radial explosion event, or null
  50822. */
  50823. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50824. /**
  50825. * Creates a gravitational field
  50826. * @param origin the origin of the explosion
  50827. * @param radius the explosion radius
  50828. * @param strength the explosion strength
  50829. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50830. * @returns A physics gravitational field event, or null
  50831. */
  50832. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50833. /**
  50834. * Creates a physics updraft event
  50835. * @param origin the origin of the updraft
  50836. * @param radius the radius of the updraft
  50837. * @param strength the strength of the updraft
  50838. * @param height the height of the updraft
  50839. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50840. * @returns A physics updraft event, or null
  50841. */
  50842. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50843. /**
  50844. * Creates a physics vortex event
  50845. * @param origin the of the vortex
  50846. * @param radius the radius of the vortex
  50847. * @param strength the strength of the vortex
  50848. * @param height the height of the vortex
  50849. * @returns a Physics vortex event, or null
  50850. * A physics vortex event or null
  50851. */
  50852. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  50853. }
  50854. /**
  50855. * Represents a physics radial explosion event
  50856. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50857. */
  50858. export class PhysicsRadialExplosionEvent {
  50859. private _scene;
  50860. private _sphere;
  50861. private _sphereOptions;
  50862. private _rays;
  50863. private _dataFetched;
  50864. /**
  50865. * Initializes a radial explosioin event
  50866. * @param scene BabylonJS scene
  50867. */
  50868. constructor(scene: Scene);
  50869. /**
  50870. * Returns the data related to the radial explosion event (sphere & rays).
  50871. * @returns The radial explosion event data
  50872. */
  50873. getData(): PhysicsRadialExplosionEventData;
  50874. /**
  50875. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50876. * @param impostor A physics imposter
  50877. * @param origin the origin of the explosion
  50878. * @param radius the explosion radius
  50879. * @param strength the explosion strength
  50880. * @param falloff possible options: Constant & Linear
  50881. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  50882. */
  50883. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  50884. /**
  50885. * Disposes the sphere.
  50886. * @param force Specifies if the sphere should be disposed by force
  50887. */
  50888. dispose(force?: boolean): void;
  50889. /*** Helpers ***/
  50890. private _prepareSphere;
  50891. private _intersectsWithSphere;
  50892. }
  50893. /**
  50894. * Represents a gravitational field event
  50895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50896. */
  50897. export class PhysicsGravitationalFieldEvent {
  50898. private _physicsHelper;
  50899. private _scene;
  50900. private _origin;
  50901. private _radius;
  50902. private _strength;
  50903. private _falloff;
  50904. private _tickCallback;
  50905. private _sphere;
  50906. private _dataFetched;
  50907. /**
  50908. * Initializes the physics gravitational field event
  50909. * @param physicsHelper A physics helper
  50910. * @param scene BabylonJS scene
  50911. * @param origin The origin position of the gravitational field event
  50912. * @param radius The radius of the gravitational field event
  50913. * @param strength The strength of the gravitational field event
  50914. * @param falloff The falloff for the gravitational field event
  50915. */
  50916. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  50917. /**
  50918. * Returns the data related to the gravitational field event (sphere).
  50919. * @returns A gravitational field event
  50920. */
  50921. getData(): PhysicsGravitationalFieldEventData;
  50922. /**
  50923. * Enables the gravitational field.
  50924. */
  50925. enable(): void;
  50926. /**
  50927. * Disables the gravitational field.
  50928. */
  50929. disable(): void;
  50930. /**
  50931. * Disposes the sphere.
  50932. * @param force The force to dispose from the gravitational field event
  50933. */
  50934. dispose(force?: boolean): void;
  50935. private _tick;
  50936. }
  50937. /**
  50938. * Represents a physics updraft event
  50939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50940. */
  50941. export class PhysicsUpdraftEvent {
  50942. private _scene;
  50943. private _origin;
  50944. private _radius;
  50945. private _strength;
  50946. private _height;
  50947. private _updraftMode;
  50948. private _physicsEngine;
  50949. private _originTop;
  50950. private _originDirection;
  50951. private _tickCallback;
  50952. private _cylinder;
  50953. private _cylinderPosition;
  50954. private _dataFetched;
  50955. /**
  50956. * Initializes the physics updraft event
  50957. * @param _scene BabylonJS scene
  50958. * @param _origin The origin position of the updraft
  50959. * @param _radius The radius of the updraft
  50960. * @param _strength The strength of the updraft
  50961. * @param _height The height of the updraft
  50962. * @param _updraftMode The mode of the updraft
  50963. */
  50964. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  50965. /**
  50966. * Returns the data related to the updraft event (cylinder).
  50967. * @returns A physics updraft event
  50968. */
  50969. getData(): PhysicsUpdraftEventData;
  50970. /**
  50971. * Enables the updraft.
  50972. */
  50973. enable(): void;
  50974. /**
  50975. * Disables the cortex.
  50976. */
  50977. disable(): void;
  50978. /**
  50979. * Disposes the sphere.
  50980. * @param force Specifies if the updraft should be disposed by force
  50981. */
  50982. dispose(force?: boolean): void;
  50983. private getImpostorForceAndContactPoint;
  50984. private _tick;
  50985. /*** Helpers ***/
  50986. private _prepareCylinder;
  50987. private _intersectsWithCylinder;
  50988. }
  50989. /**
  50990. * Represents a physics vortex event
  50991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50992. */
  50993. export class PhysicsVortexEvent {
  50994. private _scene;
  50995. private _origin;
  50996. private _radius;
  50997. private _strength;
  50998. private _height;
  50999. private _physicsEngine;
  51000. private _originTop;
  51001. private _centripetalForceThreshold;
  51002. private _updraftMultiplier;
  51003. private _tickCallback;
  51004. private _cylinder;
  51005. private _cylinderPosition;
  51006. private _dataFetched;
  51007. /**
  51008. * Initializes the physics vortex event
  51009. * @param _scene The BabylonJS scene
  51010. * @param _origin The origin position of the vortex
  51011. * @param _radius The radius of the vortex
  51012. * @param _strength The strength of the vortex
  51013. * @param _height The height of the vortex
  51014. */
  51015. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  51016. /**
  51017. * Returns the data related to the vortex event (cylinder).
  51018. * @returns The physics vortex event data
  51019. */
  51020. getData(): PhysicsVortexEventData;
  51021. /**
  51022. * Enables the vortex.
  51023. */
  51024. enable(): void;
  51025. /**
  51026. * Disables the cortex.
  51027. */
  51028. disable(): void;
  51029. /**
  51030. * Disposes the sphere.
  51031. * @param force
  51032. */
  51033. dispose(force?: boolean): void;
  51034. private getImpostorForceAndContactPoint;
  51035. private _tick;
  51036. /*** Helpers ***/
  51037. private _prepareCylinder;
  51038. private _intersectsWithCylinder;
  51039. }
  51040. /**
  51041. * The strenght of the force in correspondence to the distance of the affected object
  51042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51043. */
  51044. export enum PhysicsRadialImpulseFalloff {
  51045. /** Defines that impulse is constant in strength across it's whole radius */
  51046. Constant = 0,
  51047. /** DEfines that impulse gets weaker if it's further from the origin */
  51048. Linear = 1
  51049. }
  51050. /**
  51051. * The strength of the force in correspondence to the distance of the affected object
  51052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51053. */
  51054. export enum PhysicsUpdraftMode {
  51055. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51056. Center = 0,
  51057. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51058. Perpendicular = 1
  51059. }
  51060. /**
  51061. * Interface for a physics force and contact point
  51062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51063. */
  51064. export interface PhysicsForceAndContactPoint {
  51065. /**
  51066. * The force applied at the contact point
  51067. */
  51068. force: Vector3;
  51069. /**
  51070. * The contact point
  51071. */
  51072. contactPoint: Vector3;
  51073. }
  51074. /**
  51075. * Interface for radial explosion event data
  51076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51077. */
  51078. export interface PhysicsRadialExplosionEventData {
  51079. /**
  51080. * A sphere used for the radial explosion event
  51081. */
  51082. sphere: Mesh;
  51083. /**
  51084. * An array of rays for the radial explosion event
  51085. */
  51086. rays: Array<Ray>;
  51087. }
  51088. /**
  51089. * Interface for gravitational field event data
  51090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51091. */
  51092. export interface PhysicsGravitationalFieldEventData {
  51093. /**
  51094. * A sphere mesh used for the gravitational field event
  51095. */
  51096. sphere: Mesh;
  51097. }
  51098. /**
  51099. * Interface for updraft event data
  51100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51101. */
  51102. export interface PhysicsUpdraftEventData {
  51103. /**
  51104. * A cylinder used for the updraft event
  51105. */
  51106. cylinder: Mesh;
  51107. }
  51108. /**
  51109. * Interface for vortex event data
  51110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51111. */
  51112. export interface PhysicsVortexEventData {
  51113. /**
  51114. * A cylinder used for the vortex event
  51115. */
  51116. cylinder: Mesh;
  51117. }
  51118. }
  51119. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51120. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51121. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51122. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51123. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51124. import { Nullable } from "babylonjs/types";
  51125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51126. /**
  51127. * AmmoJS Physics plugin
  51128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51129. * @see https://github.com/kripken/ammo.js/
  51130. */
  51131. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51132. private _useDeltaForWorldStep;
  51133. /**
  51134. * Reference to the Ammo library
  51135. */
  51136. bjsAMMO: any;
  51137. /**
  51138. * Created ammoJS world which physics bodies are added to
  51139. */
  51140. world: any;
  51141. /**
  51142. * Name of the plugin
  51143. */
  51144. name: string;
  51145. private _timeStep;
  51146. private _fixedTimeStep;
  51147. private _maxSteps;
  51148. private _tmpQuaternion;
  51149. private _tmpAmmoTransform;
  51150. private _tmpAmmoQuaternion;
  51151. private _tmpAmmoConcreteContactResultCallback;
  51152. private _collisionConfiguration;
  51153. private _dispatcher;
  51154. private _overlappingPairCache;
  51155. private _solver;
  51156. private _tmpAmmoVectorA;
  51157. private _tmpAmmoVectorB;
  51158. private _tmpAmmoVectorC;
  51159. private _tmpContactCallbackResult;
  51160. private static readonly DISABLE_COLLISION_FLAG;
  51161. private static readonly KINEMATIC_FLAG;
  51162. private static readonly DISABLE_DEACTIVATION_FLAG;
  51163. /**
  51164. * Initializes the ammoJS plugin
  51165. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51166. * @param ammoInjection can be used to inject your own ammo reference
  51167. */
  51168. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51169. /**
  51170. * Sets the gravity of the physics world (m/(s^2))
  51171. * @param gravity Gravity to set
  51172. */
  51173. setGravity(gravity: Vector3): void;
  51174. /**
  51175. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51176. * @param timeStep timestep to use in seconds
  51177. */
  51178. setTimeStep(timeStep: number): void;
  51179. /**
  51180. * 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)
  51181. * @param fixedTimeStep fixedTimeStep to use in seconds
  51182. */
  51183. setFixedTimeStep(fixedTimeStep: number): void;
  51184. /**
  51185. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51186. * @param maxSteps the maximum number of steps by the physics engine per frame
  51187. */
  51188. setMaxSteps(maxSteps: number): void;
  51189. /**
  51190. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51191. * @returns the current timestep in seconds
  51192. */
  51193. getTimeStep(): number;
  51194. private _isImpostorInContact;
  51195. private _isImpostorPairInContact;
  51196. private _stepSimulation;
  51197. /**
  51198. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51199. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51200. * After the step the babylon meshes are set to the position of the physics imposters
  51201. * @param delta amount of time to step forward
  51202. * @param impostors array of imposters to update before/after the step
  51203. */
  51204. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51205. private _tmpVector;
  51206. private _tmpMatrix;
  51207. /**
  51208. * Applies an implulse on the imposter
  51209. * @param impostor imposter to apply impulse
  51210. * @param force amount of force to be applied to the imposter
  51211. * @param contactPoint the location to apply the impulse on the imposter
  51212. */
  51213. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51214. /**
  51215. * Applies a force on the imposter
  51216. * @param impostor imposter to apply force
  51217. * @param force amount of force to be applied to the imposter
  51218. * @param contactPoint the location to apply the force on the imposter
  51219. */
  51220. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51221. /**
  51222. * Creates a physics body using the plugin
  51223. * @param impostor the imposter to create the physics body on
  51224. */
  51225. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51226. /**
  51227. * Removes the physics body from the imposter and disposes of the body's memory
  51228. * @param impostor imposter to remove the physics body from
  51229. */
  51230. removePhysicsBody(impostor: PhysicsImpostor): void;
  51231. /**
  51232. * Generates a joint
  51233. * @param impostorJoint the imposter joint to create the joint with
  51234. */
  51235. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51236. /**
  51237. * Removes a joint
  51238. * @param impostorJoint the imposter joint to remove the joint from
  51239. */
  51240. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51241. private _addMeshVerts;
  51242. private _createShape;
  51243. /**
  51244. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51245. * @param impostor imposter containing the physics body and babylon object
  51246. */
  51247. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51248. /**
  51249. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51250. * @param impostor imposter containing the physics body and babylon object
  51251. * @param newPosition new position
  51252. * @param newRotation new rotation
  51253. */
  51254. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51255. /**
  51256. * If this plugin is supported
  51257. * @returns true if its supported
  51258. */
  51259. isSupported(): boolean;
  51260. /**
  51261. * Sets the linear velocity of the physics body
  51262. * @param impostor imposter to set the velocity on
  51263. * @param velocity velocity to set
  51264. */
  51265. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51266. /**
  51267. * Sets the angular velocity of the physics body
  51268. * @param impostor imposter to set the velocity on
  51269. * @param velocity velocity to set
  51270. */
  51271. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51272. /**
  51273. * gets the linear velocity
  51274. * @param impostor imposter to get linear velocity from
  51275. * @returns linear velocity
  51276. */
  51277. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51278. /**
  51279. * gets the angular velocity
  51280. * @param impostor imposter to get angular velocity from
  51281. * @returns angular velocity
  51282. */
  51283. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51284. /**
  51285. * Sets the mass of physics body
  51286. * @param impostor imposter to set the mass on
  51287. * @param mass mass to set
  51288. */
  51289. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51290. /**
  51291. * Gets the mass of the physics body
  51292. * @param impostor imposter to get the mass from
  51293. * @returns mass
  51294. */
  51295. getBodyMass(impostor: PhysicsImpostor): number;
  51296. /**
  51297. * Gets friction of the impostor
  51298. * @param impostor impostor to get friction from
  51299. * @returns friction value
  51300. */
  51301. getBodyFriction(impostor: PhysicsImpostor): number;
  51302. /**
  51303. * Sets friction of the impostor
  51304. * @param impostor impostor to set friction on
  51305. * @param friction friction value
  51306. */
  51307. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51308. /**
  51309. * Gets restitution of the impostor
  51310. * @param impostor impostor to get restitution from
  51311. * @returns restitution value
  51312. */
  51313. getBodyRestitution(impostor: PhysicsImpostor): number;
  51314. /**
  51315. * Sets resitution of the impostor
  51316. * @param impostor impostor to set resitution on
  51317. * @param restitution resitution value
  51318. */
  51319. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51320. /**
  51321. * Sleeps the physics body and stops it from being active
  51322. * @param impostor impostor to sleep
  51323. */
  51324. sleepBody(impostor: PhysicsImpostor): void;
  51325. /**
  51326. * Activates the physics body
  51327. * @param impostor impostor to activate
  51328. */
  51329. wakeUpBody(impostor: PhysicsImpostor): void;
  51330. /**
  51331. * Updates the distance parameters of the joint
  51332. * @param joint joint to update
  51333. * @param maxDistance maximum distance of the joint
  51334. * @param minDistance minimum distance of the joint
  51335. */
  51336. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51337. /**
  51338. * Sets a motor on the joint
  51339. * @param joint joint to set motor on
  51340. * @param speed speed of the motor
  51341. * @param maxForce maximum force of the motor
  51342. * @param motorIndex index of the motor
  51343. */
  51344. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51345. /**
  51346. * Sets the motors limit
  51347. * @param joint joint to set limit on
  51348. * @param upperLimit upper limit
  51349. * @param lowerLimit lower limit
  51350. */
  51351. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51352. /**
  51353. * Syncs the position and rotation of a mesh with the impostor
  51354. * @param mesh mesh to sync
  51355. * @param impostor impostor to update the mesh with
  51356. */
  51357. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51358. /**
  51359. * Gets the radius of the impostor
  51360. * @param impostor impostor to get radius from
  51361. * @returns the radius
  51362. */
  51363. getRadius(impostor: PhysicsImpostor): number;
  51364. /**
  51365. * Gets the box size of the impostor
  51366. * @param impostor impostor to get box size from
  51367. * @param result the resulting box size
  51368. */
  51369. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51370. /**
  51371. * Disposes of the impostor
  51372. */
  51373. dispose(): void;
  51374. }
  51375. }
  51376. declare module "babylonjs/Physics/Plugins/index" {
  51377. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  51378. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  51379. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  51380. }
  51381. declare module "babylonjs/Physics/index" {
  51382. export * from "babylonjs/Physics/IPhysicsEngine";
  51383. export * from "babylonjs/Physics/physicsEngine";
  51384. export * from "babylonjs/Physics/physicsEngineComponent";
  51385. export * from "babylonjs/Physics/physicsHelper";
  51386. export * from "babylonjs/Physics/physicsImpostor";
  51387. export * from "babylonjs/Physics/physicsJoint";
  51388. export * from "babylonjs/Physics/Plugins/index";
  51389. }
  51390. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  51391. /** @hidden */
  51392. export var blackAndWhitePixelShader: {
  51393. name: string;
  51394. shader: string;
  51395. };
  51396. }
  51397. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  51398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51399. import { Camera } from "babylonjs/Cameras/camera";
  51400. import { Engine } from "babylonjs/Engines/engine";
  51401. import "babylonjs/Shaders/blackAndWhite.fragment";
  51402. /**
  51403. * Post process used to render in black and white
  51404. */
  51405. export class BlackAndWhitePostProcess extends PostProcess {
  51406. /**
  51407. * Linear about to convert he result to black and white (default: 1)
  51408. */
  51409. degree: number;
  51410. /**
  51411. * Creates a black and white post process
  51412. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51413. * @param name The name of the effect.
  51414. * @param options The required width/height ratio to downsize to before computing the render pass.
  51415. * @param camera The camera to apply the render pass to.
  51416. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51417. * @param engine The engine which the post process will be applied. (default: current engine)
  51418. * @param reusable If the post process can be reused on the same frame. (default: false)
  51419. */
  51420. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51421. }
  51422. }
  51423. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  51424. import { Nullable } from "babylonjs/types";
  51425. import { Camera } from "babylonjs/Cameras/camera";
  51426. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51427. import { Engine } from "babylonjs/Engines/engine";
  51428. /**
  51429. * This represents a set of one or more post processes in Babylon.
  51430. * A post process can be used to apply a shader to a texture after it is rendered.
  51431. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51432. */
  51433. export class PostProcessRenderEffect {
  51434. private _postProcesses;
  51435. private _getPostProcesses;
  51436. private _singleInstance;
  51437. private _cameras;
  51438. private _indicesForCamera;
  51439. /**
  51440. * Name of the effect
  51441. * @hidden
  51442. */
  51443. _name: string;
  51444. /**
  51445. * Instantiates a post process render effect.
  51446. * A post process can be used to apply a shader to a texture after it is rendered.
  51447. * @param engine The engine the effect is tied to
  51448. * @param name The name of the effect
  51449. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51450. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51451. */
  51452. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51453. /**
  51454. * Checks if all the post processes in the effect are supported.
  51455. */
  51456. readonly isSupported: boolean;
  51457. /**
  51458. * Updates the current state of the effect
  51459. * @hidden
  51460. */
  51461. _update(): void;
  51462. /**
  51463. * Attaches the effect on cameras
  51464. * @param cameras The camera to attach to.
  51465. * @hidden
  51466. */
  51467. _attachCameras(cameras: Camera): void;
  51468. /**
  51469. * Attaches the effect on cameras
  51470. * @param cameras The camera to attach to.
  51471. * @hidden
  51472. */
  51473. _attachCameras(cameras: Camera[]): void;
  51474. /**
  51475. * Detatches the effect on cameras
  51476. * @param cameras The camera to detatch from.
  51477. * @hidden
  51478. */
  51479. _detachCameras(cameras: Camera): void;
  51480. /**
  51481. * Detatches the effect on cameras
  51482. * @param cameras The camera to detatch from.
  51483. * @hidden
  51484. */
  51485. _detachCameras(cameras: Camera[]): void;
  51486. /**
  51487. * Enables the effect on given cameras
  51488. * @param cameras The camera to enable.
  51489. * @hidden
  51490. */
  51491. _enable(cameras: Camera): void;
  51492. /**
  51493. * Enables the effect on given cameras
  51494. * @param cameras The camera to enable.
  51495. * @hidden
  51496. */
  51497. _enable(cameras: Nullable<Camera[]>): void;
  51498. /**
  51499. * Disables the effect on the given cameras
  51500. * @param cameras The camera to disable.
  51501. * @hidden
  51502. */
  51503. _disable(cameras: Camera): void;
  51504. /**
  51505. * Disables the effect on the given cameras
  51506. * @param cameras The camera to disable.
  51507. * @hidden
  51508. */
  51509. _disable(cameras: Nullable<Camera[]>): void;
  51510. /**
  51511. * Gets a list of the post processes contained in the effect.
  51512. * @param camera The camera to get the post processes on.
  51513. * @returns The list of the post processes in the effect.
  51514. */
  51515. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51516. }
  51517. }
  51518. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  51519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51520. /** @hidden */
  51521. export var extractHighlightsPixelShader: {
  51522. name: string;
  51523. shader: string;
  51524. };
  51525. }
  51526. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  51527. import { Nullable } from "babylonjs/types";
  51528. import { Camera } from "babylonjs/Cameras/camera";
  51529. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51530. import { Engine } from "babylonjs/Engines/engine";
  51531. import "babylonjs/Shaders/extractHighlights.fragment";
  51532. /**
  51533. * 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.
  51534. */
  51535. export class ExtractHighlightsPostProcess extends PostProcess {
  51536. /**
  51537. * The luminance threshold, pixels below this value will be set to black.
  51538. */
  51539. threshold: number;
  51540. /** @hidden */
  51541. _exposure: number;
  51542. /**
  51543. * Post process which has the input texture to be used when performing highlight extraction
  51544. * @hidden
  51545. */
  51546. _inputPostProcess: Nullable<PostProcess>;
  51547. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51548. }
  51549. }
  51550. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  51551. /** @hidden */
  51552. export var bloomMergePixelShader: {
  51553. name: string;
  51554. shader: string;
  51555. };
  51556. }
  51557. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  51558. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51559. import { Nullable } from "babylonjs/types";
  51560. import { Engine } from "babylonjs/Engines/engine";
  51561. import { Camera } from "babylonjs/Cameras/camera";
  51562. import "babylonjs/Shaders/bloomMerge.fragment";
  51563. /**
  51564. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51565. */
  51566. export class BloomMergePostProcess extends PostProcess {
  51567. /** Weight of the bloom to be added to the original input. */
  51568. weight: number;
  51569. /**
  51570. * Creates a new instance of @see BloomMergePostProcess
  51571. * @param name The name of the effect.
  51572. * @param originalFromInput Post process which's input will be used for the merge.
  51573. * @param blurred Blurred highlights post process which's output will be used.
  51574. * @param weight Weight of the bloom to be added to the original input.
  51575. * @param options The required width/height ratio to downsize to before computing the render pass.
  51576. * @param camera The camera to apply the render pass to.
  51577. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51578. * @param engine The engine which the post process will be applied. (default: current engine)
  51579. * @param reusable If the post process can be reused on the same frame. (default: false)
  51580. * @param textureType Type of textures used when performing the post process. (default: 0)
  51581. * @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)
  51582. */
  51583. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51584. /** Weight of the bloom to be added to the original input. */
  51585. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51586. }
  51587. }
  51588. declare module "babylonjs/PostProcesses/bloomEffect" {
  51589. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51590. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51591. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  51592. import { Camera } from "babylonjs/Cameras/camera";
  51593. import { Scene } from "babylonjs/scene";
  51594. /**
  51595. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51596. */
  51597. export class BloomEffect extends PostProcessRenderEffect {
  51598. private bloomScale;
  51599. /**
  51600. * @hidden Internal
  51601. */
  51602. _effects: Array<PostProcess>;
  51603. /**
  51604. * @hidden Internal
  51605. */
  51606. _downscale: ExtractHighlightsPostProcess;
  51607. private _blurX;
  51608. private _blurY;
  51609. private _merge;
  51610. /**
  51611. * The luminance threshold to find bright areas of the image to bloom.
  51612. */
  51613. threshold: number;
  51614. /**
  51615. * The strength of the bloom.
  51616. */
  51617. weight: number;
  51618. /**
  51619. * Specifies the size of the bloom blur kernel, relative to the final output size
  51620. */
  51621. kernel: number;
  51622. /**
  51623. * Creates a new instance of @see BloomEffect
  51624. * @param scene The scene the effect belongs to.
  51625. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51626. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51627. * @param bloomWeight The the strength of bloom.
  51628. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51629. * @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)
  51630. */
  51631. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51632. /**
  51633. * Disposes each of the internal effects for a given camera.
  51634. * @param camera The camera to dispose the effect on.
  51635. */
  51636. disposeEffects(camera: Camera): void;
  51637. /**
  51638. * @hidden Internal
  51639. */
  51640. _updateEffects(): void;
  51641. /**
  51642. * Internal
  51643. * @returns if all the contained post processes are ready.
  51644. * @hidden
  51645. */
  51646. _isReady(): boolean;
  51647. }
  51648. }
  51649. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  51650. /** @hidden */
  51651. export var chromaticAberrationPixelShader: {
  51652. name: string;
  51653. shader: string;
  51654. };
  51655. }
  51656. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  51657. import { Vector2 } from "babylonjs/Maths/math";
  51658. import { Nullable } from "babylonjs/types";
  51659. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51660. import { Camera } from "babylonjs/Cameras/camera";
  51661. import { Engine } from "babylonjs/Engines/engine";
  51662. import "babylonjs/Shaders/chromaticAberration.fragment";
  51663. /**
  51664. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51665. */
  51666. export class ChromaticAberrationPostProcess extends PostProcess {
  51667. /**
  51668. * The amount of seperation of rgb channels (default: 30)
  51669. */
  51670. aberrationAmount: number;
  51671. /**
  51672. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51673. */
  51674. radialIntensity: number;
  51675. /**
  51676. * 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))
  51677. */
  51678. direction: Vector2;
  51679. /**
  51680. * 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))
  51681. */
  51682. centerPosition: Vector2;
  51683. /**
  51684. * Creates a new instance ChromaticAberrationPostProcess
  51685. * @param name The name of the effect.
  51686. * @param screenWidth The width of the screen to apply the effect on.
  51687. * @param screenHeight The height of the screen to apply the effect on.
  51688. * @param options The required width/height ratio to downsize to before computing the render pass.
  51689. * @param camera The camera to apply the render pass to.
  51690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51691. * @param engine The engine which the post process will be applied. (default: current engine)
  51692. * @param reusable If the post process can be reused on the same frame. (default: false)
  51693. * @param textureType Type of textures used when performing the post process. (default: 0)
  51694. * @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)
  51695. */
  51696. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51697. }
  51698. }
  51699. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  51700. /** @hidden */
  51701. export var circleOfConfusionPixelShader: {
  51702. name: string;
  51703. shader: string;
  51704. };
  51705. }
  51706. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  51707. import { Nullable } from "babylonjs/types";
  51708. import { Engine } from "babylonjs/Engines/engine";
  51709. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51710. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51711. import { Camera } from "babylonjs/Cameras/camera";
  51712. import "babylonjs/Shaders/circleOfConfusion.fragment";
  51713. /**
  51714. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51715. */
  51716. export class CircleOfConfusionPostProcess extends PostProcess {
  51717. /**
  51718. * 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.
  51719. */
  51720. lensSize: number;
  51721. /**
  51722. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51723. */
  51724. fStop: number;
  51725. /**
  51726. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51727. */
  51728. focusDistance: number;
  51729. /**
  51730. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51731. */
  51732. focalLength: number;
  51733. private _depthTexture;
  51734. /**
  51735. * Creates a new instance CircleOfConfusionPostProcess
  51736. * @param name The name of the effect.
  51737. * @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.
  51738. * @param options The required width/height ratio to downsize to before computing the render pass.
  51739. * @param camera The camera to apply the render pass to.
  51740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51741. * @param engine The engine which the post process will be applied. (default: current engine)
  51742. * @param reusable If the post process can be reused on the same frame. (default: false)
  51743. * @param textureType Type of textures used when performing the post process. (default: 0)
  51744. * @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)
  51745. */
  51746. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51747. /**
  51748. * 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.
  51749. */
  51750. depthTexture: RenderTargetTexture;
  51751. }
  51752. }
  51753. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  51754. /** @hidden */
  51755. export var colorCorrectionPixelShader: {
  51756. name: string;
  51757. shader: string;
  51758. };
  51759. }
  51760. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  51761. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51762. import { Engine } from "babylonjs/Engines/engine";
  51763. import { Camera } from "babylonjs/Cameras/camera";
  51764. import "babylonjs/Shaders/colorCorrection.fragment";
  51765. /**
  51766. *
  51767. * This post-process allows the modification of rendered colors by using
  51768. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51769. *
  51770. * The object needs to be provided an url to a texture containing the color
  51771. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51772. * Use an image editing software to tweak the LUT to match your needs.
  51773. *
  51774. * For an example of a color LUT, see here:
  51775. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51776. * For explanations on color grading, see here:
  51777. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51778. *
  51779. */
  51780. export class ColorCorrectionPostProcess extends PostProcess {
  51781. private _colorTableTexture;
  51782. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51783. }
  51784. }
  51785. declare module "babylonjs/Shaders/convolution.fragment" {
  51786. /** @hidden */
  51787. export var convolutionPixelShader: {
  51788. name: string;
  51789. shader: string;
  51790. };
  51791. }
  51792. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  51793. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51794. import { Nullable } from "babylonjs/types";
  51795. import { Camera } from "babylonjs/Cameras/camera";
  51796. import { Engine } from "babylonjs/Engines/engine";
  51797. import "babylonjs/Shaders/convolution.fragment";
  51798. /**
  51799. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51800. * input texture to perform effects such as edge detection or sharpening
  51801. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51802. */
  51803. export class ConvolutionPostProcess extends PostProcess {
  51804. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51805. kernel: number[];
  51806. /**
  51807. * Creates a new instance ConvolutionPostProcess
  51808. * @param name The name of the effect.
  51809. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51810. * @param options The required width/height ratio to downsize to before computing the render pass.
  51811. * @param camera The camera to apply the render pass to.
  51812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51813. * @param engine The engine which the post process will be applied. (default: current engine)
  51814. * @param reusable If the post process can be reused on the same frame. (default: false)
  51815. * @param textureType Type of textures used when performing the post process. (default: 0)
  51816. */
  51817. constructor(name: string,
  51818. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51819. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51820. /**
  51821. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51822. */
  51823. static EdgeDetect0Kernel: number[];
  51824. /**
  51825. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51826. */
  51827. static EdgeDetect1Kernel: number[];
  51828. /**
  51829. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51830. */
  51831. static EdgeDetect2Kernel: number[];
  51832. /**
  51833. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51834. */
  51835. static SharpenKernel: number[];
  51836. /**
  51837. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51838. */
  51839. static EmbossKernel: number[];
  51840. /**
  51841. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51842. */
  51843. static GaussianKernel: number[];
  51844. }
  51845. }
  51846. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  51847. import { Nullable } from "babylonjs/types";
  51848. import { Vector2 } from "babylonjs/Maths/math";
  51849. import { Camera } from "babylonjs/Cameras/camera";
  51850. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51851. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  51852. import { Engine } from "babylonjs/Engines/engine";
  51853. import { Scene } from "babylonjs/scene";
  51854. /**
  51855. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51856. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51857. * based on samples that have a large difference in distance than the center pixel.
  51858. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51859. */
  51860. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51861. direction: Vector2;
  51862. /**
  51863. * Creates a new instance CircleOfConfusionPostProcess
  51864. * @param name The name of the effect.
  51865. * @param scene The scene the effect belongs to.
  51866. * @param direction The direction the blur should be applied.
  51867. * @param kernel The size of the kernel used to blur.
  51868. * @param options The required width/height ratio to downsize to before computing the render pass.
  51869. * @param camera The camera to apply the render pass to.
  51870. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51871. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51873. * @param engine The engine which the post process will be applied. (default: current engine)
  51874. * @param reusable If the post process can be reused on the same frame. (default: false)
  51875. * @param textureType Type of textures used when performing the post process. (default: 0)
  51876. * @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)
  51877. */
  51878. 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);
  51879. }
  51880. }
  51881. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  51882. /** @hidden */
  51883. export var depthOfFieldMergePixelShader: {
  51884. name: string;
  51885. shader: string;
  51886. };
  51887. }
  51888. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  51889. import { Nullable } from "babylonjs/types";
  51890. import { Camera } from "babylonjs/Cameras/camera";
  51891. import { Effect } from "babylonjs/Materials/effect";
  51892. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51893. import { Engine } from "babylonjs/Engines/engine";
  51894. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  51895. /**
  51896. * Options to be set when merging outputs from the default pipeline.
  51897. */
  51898. export class DepthOfFieldMergePostProcessOptions {
  51899. /**
  51900. * The original image to merge on top of
  51901. */
  51902. originalFromInput: PostProcess;
  51903. /**
  51904. * Parameters to perform the merge of the depth of field effect
  51905. */
  51906. depthOfField?: {
  51907. circleOfConfusion: PostProcess;
  51908. blurSteps: Array<PostProcess>;
  51909. };
  51910. /**
  51911. * Parameters to perform the merge of bloom effect
  51912. */
  51913. bloom?: {
  51914. blurred: PostProcess;
  51915. weight: number;
  51916. };
  51917. }
  51918. /**
  51919. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51920. */
  51921. export class DepthOfFieldMergePostProcess extends PostProcess {
  51922. private blurSteps;
  51923. /**
  51924. * Creates a new instance of DepthOfFieldMergePostProcess
  51925. * @param name The name of the effect.
  51926. * @param originalFromInput Post process which's input will be used for the merge.
  51927. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51928. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51929. * @param options The required width/height ratio to downsize to before computing the render pass.
  51930. * @param camera The camera to apply the render pass to.
  51931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51932. * @param engine The engine which the post process will be applied. (default: current engine)
  51933. * @param reusable If the post process can be reused on the same frame. (default: false)
  51934. * @param textureType Type of textures used when performing the post process. (default: 0)
  51935. * @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)
  51936. */
  51937. 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);
  51938. /**
  51939. * Updates the effect with the current post process compile time values and recompiles the shader.
  51940. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51941. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51942. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51943. * @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
  51944. * @param onCompiled Called when the shader has been compiled.
  51945. * @param onError Called if there is an error when compiling a shader.
  51946. */
  51947. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51948. }
  51949. }
  51950. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  51951. import { Nullable } from "babylonjs/types";
  51952. import { Camera } from "babylonjs/Cameras/camera";
  51953. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51954. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51955. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  51956. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  51957. import { Scene } from "babylonjs/scene";
  51958. /**
  51959. * Specifies the level of max blur that should be applied when using the depth of field effect
  51960. */
  51961. export enum DepthOfFieldEffectBlurLevel {
  51962. /**
  51963. * Subtle blur
  51964. */
  51965. Low = 0,
  51966. /**
  51967. * Medium blur
  51968. */
  51969. Medium = 1,
  51970. /**
  51971. * Large blur
  51972. */
  51973. High = 2
  51974. }
  51975. /**
  51976. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51977. */
  51978. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51979. private _circleOfConfusion;
  51980. /**
  51981. * @hidden Internal, blurs from high to low
  51982. */
  51983. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51984. private _depthOfFieldBlurY;
  51985. private _dofMerge;
  51986. /**
  51987. * @hidden Internal post processes in depth of field effect
  51988. */
  51989. _effects: Array<PostProcess>;
  51990. /**
  51991. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51992. */
  51993. focalLength: number;
  51994. /**
  51995. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51996. */
  51997. fStop: number;
  51998. /**
  51999. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52000. */
  52001. focusDistance: number;
  52002. /**
  52003. * 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.
  52004. */
  52005. lensSize: number;
  52006. /**
  52007. * Creates a new instance DepthOfFieldEffect
  52008. * @param scene The scene the effect belongs to.
  52009. * @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.
  52010. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52011. * @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)
  52012. */
  52013. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52014. /**
  52015. * 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.
  52016. */
  52017. depthTexture: RenderTargetTexture;
  52018. /**
  52019. * Disposes each of the internal effects for a given camera.
  52020. * @param camera The camera to dispose the effect on.
  52021. */
  52022. disposeEffects(camera: Camera): void;
  52023. /**
  52024. * @hidden Internal
  52025. */
  52026. _updateEffects(): void;
  52027. /**
  52028. * Internal
  52029. * @returns if all the contained post processes are ready.
  52030. * @hidden
  52031. */
  52032. _isReady(): boolean;
  52033. }
  52034. }
  52035. declare module "babylonjs/Shaders/displayPass.fragment" {
  52036. /** @hidden */
  52037. export var displayPassPixelShader: {
  52038. name: string;
  52039. shader: string;
  52040. };
  52041. }
  52042. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  52043. import { Nullable } from "babylonjs/types";
  52044. import { Camera } from "babylonjs/Cameras/camera";
  52045. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52046. import { Engine } from "babylonjs/Engines/engine";
  52047. import "babylonjs/Shaders/displayPass.fragment";
  52048. /**
  52049. * DisplayPassPostProcess which produces an output the same as it's input
  52050. */
  52051. export class DisplayPassPostProcess extends PostProcess {
  52052. /**
  52053. * Creates the DisplayPassPostProcess
  52054. * @param name The name of the effect.
  52055. * @param options The required width/height ratio to downsize to before computing the render pass.
  52056. * @param camera The camera to apply the render pass to.
  52057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52058. * @param engine The engine which the post process will be applied. (default: current engine)
  52059. * @param reusable If the post process can be reused on the same frame. (default: false)
  52060. */
  52061. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52062. }
  52063. }
  52064. declare module "babylonjs/Shaders/filter.fragment" {
  52065. /** @hidden */
  52066. export var filterPixelShader: {
  52067. name: string;
  52068. shader: string;
  52069. };
  52070. }
  52071. declare module "babylonjs/PostProcesses/filterPostProcess" {
  52072. import { Nullable } from "babylonjs/types";
  52073. import { Matrix } from "babylonjs/Maths/math";
  52074. import { Camera } from "babylonjs/Cameras/camera";
  52075. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52076. import { Engine } from "babylonjs/Engines/engine";
  52077. import "babylonjs/Shaders/filter.fragment";
  52078. /**
  52079. * Applies a kernel filter to the image
  52080. */
  52081. export class FilterPostProcess extends PostProcess {
  52082. /** The matrix to be applied to the image */
  52083. kernelMatrix: Matrix;
  52084. /**
  52085. *
  52086. * @param name The name of the effect.
  52087. * @param kernelMatrix The matrix to be applied to the image
  52088. * @param options The required width/height ratio to downsize to before computing the render pass.
  52089. * @param camera The camera to apply the render pass to.
  52090. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52091. * @param engine The engine which the post process will be applied. (default: current engine)
  52092. * @param reusable If the post process can be reused on the same frame. (default: false)
  52093. */
  52094. constructor(name: string,
  52095. /** The matrix to be applied to the image */
  52096. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52097. }
  52098. }
  52099. declare module "babylonjs/Shaders/fxaa.fragment" {
  52100. /** @hidden */
  52101. export var fxaaPixelShader: {
  52102. name: string;
  52103. shader: string;
  52104. };
  52105. }
  52106. declare module "babylonjs/Shaders/fxaa.vertex" {
  52107. /** @hidden */
  52108. export var fxaaVertexShader: {
  52109. name: string;
  52110. shader: string;
  52111. };
  52112. }
  52113. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  52114. import { Nullable } from "babylonjs/types";
  52115. import { Camera } from "babylonjs/Cameras/camera";
  52116. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52117. import { Engine } from "babylonjs/Engines/engine";
  52118. import "babylonjs/Shaders/fxaa.fragment";
  52119. import "babylonjs/Shaders/fxaa.vertex";
  52120. /**
  52121. * Fxaa post process
  52122. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52123. */
  52124. export class FxaaPostProcess extends PostProcess {
  52125. /** @hidden */
  52126. texelWidth: number;
  52127. /** @hidden */
  52128. texelHeight: number;
  52129. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52130. private _getDefines;
  52131. }
  52132. }
  52133. declare module "babylonjs/Shaders/grain.fragment" {
  52134. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52135. /** @hidden */
  52136. export var grainPixelShader: {
  52137. name: string;
  52138. shader: string;
  52139. };
  52140. }
  52141. declare module "babylonjs/PostProcesses/grainPostProcess" {
  52142. import { Nullable } from "babylonjs/types";
  52143. import { Camera } from "babylonjs/Cameras/camera";
  52144. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52145. import { Engine } from "babylonjs/Engines/engine";
  52146. import "babylonjs/Shaders/grain.fragment";
  52147. /**
  52148. * The GrainPostProcess adds noise to the image at mid luminance levels
  52149. */
  52150. export class GrainPostProcess extends PostProcess {
  52151. /**
  52152. * The intensity of the grain added (default: 30)
  52153. */
  52154. intensity: number;
  52155. /**
  52156. * If the grain should be randomized on every frame
  52157. */
  52158. animated: boolean;
  52159. /**
  52160. * Creates a new instance of @see GrainPostProcess
  52161. * @param name The name of the effect.
  52162. * @param options The required width/height ratio to downsize to before computing the render pass.
  52163. * @param camera The camera to apply the render pass to.
  52164. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52165. * @param engine The engine which the post process will be applied. (default: current engine)
  52166. * @param reusable If the post process can be reused on the same frame. (default: false)
  52167. * @param textureType Type of textures used when performing the post process. (default: 0)
  52168. * @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)
  52169. */
  52170. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52171. }
  52172. }
  52173. declare module "babylonjs/Shaders/highlights.fragment" {
  52174. /** @hidden */
  52175. export var highlightsPixelShader: {
  52176. name: string;
  52177. shader: string;
  52178. };
  52179. }
  52180. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  52181. import { Nullable } from "babylonjs/types";
  52182. import { Camera } from "babylonjs/Cameras/camera";
  52183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52184. import { Engine } from "babylonjs/Engines/engine";
  52185. import "babylonjs/Shaders/highlights.fragment";
  52186. /**
  52187. * Extracts highlights from the image
  52188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52189. */
  52190. export class HighlightsPostProcess extends PostProcess {
  52191. /**
  52192. * Extracts highlights from the image
  52193. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52194. * @param name The name of the effect.
  52195. * @param options The required width/height ratio to downsize to before computing the render pass.
  52196. * @param camera The camera to apply the render pass to.
  52197. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52198. * @param engine The engine which the post process will be applied. (default: current engine)
  52199. * @param reusable If the post process can be reused on the same frame. (default: false)
  52200. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52201. */
  52202. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52203. }
  52204. }
  52205. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  52206. /** @hidden */
  52207. export var mrtFragmentDeclaration: {
  52208. name: string;
  52209. shader: string;
  52210. };
  52211. }
  52212. declare module "babylonjs/Shaders/geometry.fragment" {
  52213. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  52214. /** @hidden */
  52215. export var geometryPixelShader: {
  52216. name: string;
  52217. shader: string;
  52218. };
  52219. }
  52220. declare module "babylonjs/Shaders/geometry.vertex" {
  52221. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52222. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52225. /** @hidden */
  52226. export var geometryVertexShader: {
  52227. name: string;
  52228. shader: string;
  52229. };
  52230. }
  52231. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  52232. import { Matrix } from "babylonjs/Maths/math";
  52233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52234. import { Mesh } from "babylonjs/Meshes/mesh";
  52235. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  52236. import { Effect } from "babylonjs/Materials/effect";
  52237. import { Scene } from "babylonjs/scene";
  52238. import "babylonjs/Shaders/geometry.fragment";
  52239. import "babylonjs/Shaders/geometry.vertex";
  52240. /**
  52241. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52242. */
  52243. export class GeometryBufferRenderer {
  52244. /**
  52245. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52246. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52247. */
  52248. static readonly POSITION_TEXTURE_TYPE: number;
  52249. /**
  52250. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52251. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52252. */
  52253. static readonly VELOCITY_TEXTURE_TYPE: number;
  52254. /**
  52255. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52256. * in order to compute objects velocities when enableVelocity is set to "true"
  52257. * @hidden
  52258. */
  52259. _previousTransformationMatrices: {
  52260. [index: number]: Matrix;
  52261. };
  52262. private _scene;
  52263. private _multiRenderTarget;
  52264. private _ratio;
  52265. private _enablePosition;
  52266. private _enableVelocity;
  52267. private _positionIndex;
  52268. private _velocityIndex;
  52269. protected _effect: Effect;
  52270. protected _cachedDefines: string;
  52271. /**
  52272. * Set the render list (meshes to be rendered) used in the G buffer.
  52273. */
  52274. renderList: Mesh[];
  52275. /**
  52276. * Gets wether or not G buffer are supported by the running hardware.
  52277. * This requires draw buffer supports
  52278. */
  52279. readonly isSupported: boolean;
  52280. /**
  52281. * Returns the index of the given texture type in the G-Buffer textures array
  52282. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52283. * @returns the index of the given texture type in the G-Buffer textures array
  52284. */
  52285. getTextureIndex(textureType: number): number;
  52286. /**
  52287. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52288. */
  52289. /**
  52290. * Sets whether or not objects positions are enabled for the G buffer.
  52291. */
  52292. enablePosition: boolean;
  52293. /**
  52294. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52295. */
  52296. /**
  52297. * Sets wether or not objects velocities are enabled for the G buffer.
  52298. */
  52299. enableVelocity: boolean;
  52300. /**
  52301. * Gets the scene associated with the buffer.
  52302. */
  52303. readonly scene: Scene;
  52304. /**
  52305. * Gets the ratio used by the buffer during its creation.
  52306. * How big is the buffer related to the main canvas.
  52307. */
  52308. readonly ratio: number;
  52309. /** @hidden */
  52310. static _SceneComponentInitialization: (scene: Scene) => void;
  52311. /**
  52312. * Creates a new G Buffer for the scene
  52313. * @param scene The scene the buffer belongs to
  52314. * @param ratio How big is the buffer related to the main canvas.
  52315. */
  52316. constructor(scene: Scene, ratio?: number);
  52317. /**
  52318. * Checks wether everything is ready to render a submesh to the G buffer.
  52319. * @param subMesh the submesh to check readiness for
  52320. * @param useInstances is the mesh drawn using instance or not
  52321. * @returns true if ready otherwise false
  52322. */
  52323. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52324. /**
  52325. * Gets the current underlying G Buffer.
  52326. * @returns the buffer
  52327. */
  52328. getGBuffer(): MultiRenderTarget;
  52329. /**
  52330. * Gets the number of samples used to render the buffer (anti aliasing).
  52331. */
  52332. /**
  52333. * Sets the number of samples used to render the buffer (anti aliasing).
  52334. */
  52335. samples: number;
  52336. /**
  52337. * Disposes the renderer and frees up associated resources.
  52338. */
  52339. dispose(): void;
  52340. protected _createRenderTargets(): void;
  52341. }
  52342. }
  52343. declare module "babylonjs/Shaders/motionBlur.fragment" {
  52344. /** @hidden */
  52345. export var motionBlurPixelShader: {
  52346. name: string;
  52347. shader: string;
  52348. };
  52349. }
  52350. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  52351. import { Nullable } from "babylonjs/types";
  52352. import { Camera } from "babylonjs/Cameras/camera";
  52353. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52354. import { Scene } from "babylonjs/scene";
  52355. import "babylonjs/Shaders/motionBlur.fragment";
  52356. import { Engine } from "babylonjs/Engines/engine";
  52357. /**
  52358. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52359. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52360. * As an example, all you have to do is to create the post-process:
  52361. * var mb = new BABYLON.MotionBlurPostProcess(
  52362. * 'mb', // The name of the effect.
  52363. * scene, // The scene containing the objects to blur according to their velocity.
  52364. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52365. * camera // The camera to apply the render pass to.
  52366. * );
  52367. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52368. */
  52369. export class MotionBlurPostProcess extends PostProcess {
  52370. /**
  52371. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52372. */
  52373. motionStrength: number;
  52374. /**
  52375. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52376. */
  52377. /**
  52378. * Sets the number of iterations to be used for motion blur quality
  52379. */
  52380. motionBlurSamples: number;
  52381. private _motionBlurSamples;
  52382. private _geometryBufferRenderer;
  52383. /**
  52384. * Creates a new instance MotionBlurPostProcess
  52385. * @param name The name of the effect.
  52386. * @param scene The scene containing the objects to blur according to their velocity.
  52387. * @param options The required width/height ratio to downsize to before computing the render pass.
  52388. * @param camera The camera to apply the render pass to.
  52389. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52390. * @param engine The engine which the post process will be applied. (default: current engine)
  52391. * @param reusable If the post process can be reused on the same frame. (default: false)
  52392. * @param textureType Type of textures used when performing the post process. (default: 0)
  52393. * @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)
  52394. */
  52395. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52396. /**
  52397. * Disposes the post process.
  52398. * @param camera The camera to dispose the post process on.
  52399. */
  52400. dispose(camera?: Camera): void;
  52401. }
  52402. }
  52403. declare module "babylonjs/Shaders/refraction.fragment" {
  52404. /** @hidden */
  52405. export var refractionPixelShader: {
  52406. name: string;
  52407. shader: string;
  52408. };
  52409. }
  52410. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  52411. import { Color3 } from "babylonjs/Maths/math";
  52412. import { Camera } from "babylonjs/Cameras/camera";
  52413. import { Texture } from "babylonjs/Materials/Textures/texture";
  52414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52415. import { Engine } from "babylonjs/Engines/engine";
  52416. import "babylonjs/Shaders/refraction.fragment";
  52417. /**
  52418. * Post process which applies a refractin texture
  52419. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52420. */
  52421. export class RefractionPostProcess extends PostProcess {
  52422. /** the base color of the refraction (used to taint the rendering) */
  52423. color: Color3;
  52424. /** simulated refraction depth */
  52425. depth: number;
  52426. /** the coefficient of the base color (0 to remove base color tainting) */
  52427. colorLevel: number;
  52428. private _refTexture;
  52429. private _ownRefractionTexture;
  52430. /**
  52431. * Gets or sets the refraction texture
  52432. * Please note that you are responsible for disposing the texture if you set it manually
  52433. */
  52434. refractionTexture: Texture;
  52435. /**
  52436. * Initializes the RefractionPostProcess
  52437. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52438. * @param name The name of the effect.
  52439. * @param refractionTextureUrl Url of the refraction texture to use
  52440. * @param color the base color of the refraction (used to taint the rendering)
  52441. * @param depth simulated refraction depth
  52442. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52443. * @param camera The camera to apply the render pass to.
  52444. * @param options The required width/height ratio to downsize to before computing the render pass.
  52445. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52446. * @param engine The engine which the post process will be applied. (default: current engine)
  52447. * @param reusable If the post process can be reused on the same frame. (default: false)
  52448. */
  52449. constructor(name: string, refractionTextureUrl: string,
  52450. /** the base color of the refraction (used to taint the rendering) */
  52451. color: Color3,
  52452. /** simulated refraction depth */
  52453. depth: number,
  52454. /** the coefficient of the base color (0 to remove base color tainting) */
  52455. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52456. /**
  52457. * Disposes of the post process
  52458. * @param camera Camera to dispose post process on
  52459. */
  52460. dispose(camera: Camera): void;
  52461. }
  52462. }
  52463. declare module "babylonjs/Shaders/sharpen.fragment" {
  52464. /** @hidden */
  52465. export var sharpenPixelShader: {
  52466. name: string;
  52467. shader: string;
  52468. };
  52469. }
  52470. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  52471. import { Nullable } from "babylonjs/types";
  52472. import { Camera } from "babylonjs/Cameras/camera";
  52473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  52474. import "babylonjs/Shaders/sharpen.fragment";
  52475. import { Engine } from "babylonjs/Engines/engine";
  52476. /**
  52477. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52478. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52479. */
  52480. export class SharpenPostProcess extends PostProcess {
  52481. /**
  52482. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52483. */
  52484. colorAmount: number;
  52485. /**
  52486. * How much sharpness should be applied (default: 0.3)
  52487. */
  52488. edgeAmount: number;
  52489. /**
  52490. * Creates a new instance ConvolutionPostProcess
  52491. * @param name The name of the effect.
  52492. * @param options The required width/height ratio to downsize to before computing the render pass.
  52493. * @param camera The camera to apply the render pass to.
  52494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52495. * @param engine The engine which the post process will be applied. (default: current engine)
  52496. * @param reusable If the post process can be reused on the same frame. (default: false)
  52497. * @param textureType Type of textures used when performing the post process. (default: 0)
  52498. * @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)
  52499. */
  52500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52501. }
  52502. }
  52503. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  52504. import { Nullable } from "babylonjs/types";
  52505. import { Camera } from "babylonjs/Cameras/camera";
  52506. import { Engine } from "babylonjs/Engines/engine";
  52507. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  52508. /**
  52509. * PostProcessRenderPipeline
  52510. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52511. */
  52512. export class PostProcessRenderPipeline {
  52513. private engine;
  52514. private _renderEffects;
  52515. private _renderEffectsForIsolatedPass;
  52516. /**
  52517. * @hidden
  52518. */
  52519. protected _cameras: Camera[];
  52520. /** @hidden */
  52521. _name: string;
  52522. /**
  52523. * Initializes a PostProcessRenderPipeline
  52524. * @param engine engine to add the pipeline to
  52525. * @param name name of the pipeline
  52526. */
  52527. constructor(engine: Engine, name: string);
  52528. /**
  52529. * "PostProcessRenderPipeline"
  52530. * @returns "PostProcessRenderPipeline"
  52531. */
  52532. getClassName(): string;
  52533. /**
  52534. * If all the render effects in the pipeline are support
  52535. */
  52536. readonly isSupported: boolean;
  52537. /**
  52538. * Adds an effect to the pipeline
  52539. * @param renderEffect the effect to add
  52540. */
  52541. addEffect(renderEffect: PostProcessRenderEffect): void;
  52542. /** @hidden */
  52543. _rebuild(): void;
  52544. /** @hidden */
  52545. _enableEffect(renderEffectName: string, cameras: Camera): void;
  52546. /** @hidden */
  52547. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52548. /** @hidden */
  52549. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52550. /** @hidden */
  52551. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52552. /** @hidden */
  52553. _attachCameras(cameras: Camera, unique: boolean): void;
  52554. /** @hidden */
  52555. _attachCameras(cameras: Camera[], unique: boolean): void;
  52556. /** @hidden */
  52557. _detachCameras(cameras: Camera): void;
  52558. /** @hidden */
  52559. _detachCameras(cameras: Nullable<Camera[]>): void;
  52560. /** @hidden */
  52561. _update(): void;
  52562. /** @hidden */
  52563. _reset(): void;
  52564. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52565. /**
  52566. * Disposes of the pipeline
  52567. */
  52568. dispose(): void;
  52569. }
  52570. }
  52571. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  52572. import { IAnimatable } from "babylonjs/Misc/tools";
  52573. import { Camera } from "babylonjs/Cameras/camera";
  52574. import { IDisposable } from "babylonjs/scene";
  52575. import { Scene } from "babylonjs/scene";
  52576. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  52577. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  52578. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  52579. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  52580. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  52581. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52582. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  52583. import { Animation } from "babylonjs/Animations/animation";
  52584. /**
  52585. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52586. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52587. */
  52588. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52589. private _scene;
  52590. private _camerasToBeAttached;
  52591. /**
  52592. * ID of the sharpen post process,
  52593. */
  52594. private readonly SharpenPostProcessId;
  52595. /**
  52596. * @ignore
  52597. * ID of the image processing post process;
  52598. */
  52599. readonly ImageProcessingPostProcessId: string;
  52600. /**
  52601. * @ignore
  52602. * ID of the Fast Approximate Anti-Aliasing post process;
  52603. */
  52604. readonly FxaaPostProcessId: string;
  52605. /**
  52606. * ID of the chromatic aberration post process,
  52607. */
  52608. private readonly ChromaticAberrationPostProcessId;
  52609. /**
  52610. * ID of the grain post process
  52611. */
  52612. private readonly GrainPostProcessId;
  52613. /**
  52614. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52615. */
  52616. sharpen: SharpenPostProcess;
  52617. private _sharpenEffect;
  52618. private bloom;
  52619. /**
  52620. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52621. */
  52622. depthOfField: DepthOfFieldEffect;
  52623. /**
  52624. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52625. */
  52626. fxaa: FxaaPostProcess;
  52627. /**
  52628. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52629. */
  52630. imageProcessing: ImageProcessingPostProcess;
  52631. /**
  52632. * Chromatic aberration post process which will shift rgb colors in the image
  52633. */
  52634. chromaticAberration: ChromaticAberrationPostProcess;
  52635. private _chromaticAberrationEffect;
  52636. /**
  52637. * Grain post process which add noise to the image
  52638. */
  52639. grain: GrainPostProcess;
  52640. private _grainEffect;
  52641. /**
  52642. * Glow post process which adds a glow to emmisive areas of the image
  52643. */
  52644. private _glowLayer;
  52645. /**
  52646. * Animations which can be used to tweak settings over a period of time
  52647. */
  52648. animations: Animation[];
  52649. private _imageProcessingConfigurationObserver;
  52650. private _sharpenEnabled;
  52651. private _bloomEnabled;
  52652. private _depthOfFieldEnabled;
  52653. private _depthOfFieldBlurLevel;
  52654. private _fxaaEnabled;
  52655. private _imageProcessingEnabled;
  52656. private _defaultPipelineTextureType;
  52657. private _bloomScale;
  52658. private _chromaticAberrationEnabled;
  52659. private _grainEnabled;
  52660. private _buildAllowed;
  52661. /**
  52662. * Enable or disable the sharpen process from the pipeline
  52663. */
  52664. sharpenEnabled: boolean;
  52665. private _resizeObserver;
  52666. private _hardwareScaleLevel;
  52667. private _bloomKernel;
  52668. /**
  52669. * Specifies the size of the bloom blur kernel, relative to the final output size
  52670. */
  52671. bloomKernel: number;
  52672. /**
  52673. * Specifies the weight of the bloom in the final rendering
  52674. */
  52675. private _bloomWeight;
  52676. /**
  52677. * Specifies the luma threshold for the area that will be blurred by the bloom
  52678. */
  52679. private _bloomThreshold;
  52680. private _hdr;
  52681. /**
  52682. * The strength of the bloom.
  52683. */
  52684. bloomWeight: number;
  52685. /**
  52686. * The strength of the bloom.
  52687. */
  52688. bloomThreshold: number;
  52689. /**
  52690. * The scale of the bloom, lower value will provide better performance.
  52691. */
  52692. bloomScale: number;
  52693. /**
  52694. * Enable or disable the bloom from the pipeline
  52695. */
  52696. bloomEnabled: boolean;
  52697. private _rebuildBloom;
  52698. /**
  52699. * If the depth of field is enabled.
  52700. */
  52701. depthOfFieldEnabled: boolean;
  52702. /**
  52703. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52704. */
  52705. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52706. /**
  52707. * If the anti aliasing is enabled.
  52708. */
  52709. fxaaEnabled: boolean;
  52710. private _samples;
  52711. /**
  52712. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52713. */
  52714. samples: number;
  52715. /**
  52716. * If image processing is enabled.
  52717. */
  52718. imageProcessingEnabled: boolean;
  52719. /**
  52720. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52721. */
  52722. glowLayerEnabled: boolean;
  52723. /**
  52724. * Enable or disable the chromaticAberration process from the pipeline
  52725. */
  52726. chromaticAberrationEnabled: boolean;
  52727. /**
  52728. * Enable or disable the grain process from the pipeline
  52729. */
  52730. grainEnabled: boolean;
  52731. /**
  52732. * @constructor
  52733. * @param name - The rendering pipeline name (default: "")
  52734. * @param hdr - If high dynamic range textures should be used (default: true)
  52735. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52736. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52737. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52738. */
  52739. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52740. /**
  52741. * Force the compilation of the entire pipeline.
  52742. */
  52743. prepare(): void;
  52744. private _hasCleared;
  52745. private _prevPostProcess;
  52746. private _prevPrevPostProcess;
  52747. private _setAutoClearAndTextureSharing;
  52748. private _depthOfFieldSceneObserver;
  52749. private _buildPipeline;
  52750. private _disposePostProcesses;
  52751. /**
  52752. * Adds a camera to the pipeline
  52753. * @param camera the camera to be added
  52754. */
  52755. addCamera(camera: Camera): void;
  52756. /**
  52757. * Removes a camera from the pipeline
  52758. * @param camera the camera to remove
  52759. */
  52760. removeCamera(camera: Camera): void;
  52761. /**
  52762. * Dispose of the pipeline and stop all post processes
  52763. */
  52764. dispose(): void;
  52765. /**
  52766. * Serialize the rendering pipeline (Used when exporting)
  52767. * @returns the serialized object
  52768. */
  52769. serialize(): any;
  52770. /**
  52771. * Parse the serialized pipeline
  52772. * @param source Source pipeline.
  52773. * @param scene The scene to load the pipeline to.
  52774. * @param rootUrl The URL of the serialized pipeline.
  52775. * @returns An instantiated pipeline from the serialized object.
  52776. */
  52777. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52778. }
  52779. }
  52780. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  52781. /** @hidden */
  52782. export var lensHighlightsPixelShader: {
  52783. name: string;
  52784. shader: string;
  52785. };
  52786. }
  52787. declare module "babylonjs/Shaders/depthOfField.fragment" {
  52788. /** @hidden */
  52789. export var depthOfFieldPixelShader: {
  52790. name: string;
  52791. shader: string;
  52792. };
  52793. }
  52794. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  52795. import { Camera } from "babylonjs/Cameras/camera";
  52796. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52797. import { Scene } from "babylonjs/scene";
  52798. import "babylonjs/Shaders/chromaticAberration.fragment";
  52799. import "babylonjs/Shaders/lensHighlights.fragment";
  52800. import "babylonjs/Shaders/depthOfField.fragment";
  52801. /**
  52802. * BABYLON.JS Chromatic Aberration GLSL Shader
  52803. * Author: Olivier Guyot
  52804. * Separates very slightly R, G and B colors on the edges of the screen
  52805. * Inspired by Francois Tarlier & Martins Upitis
  52806. */
  52807. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52808. /**
  52809. * @ignore
  52810. * The chromatic aberration PostProcess id in the pipeline
  52811. */
  52812. LensChromaticAberrationEffect: string;
  52813. /**
  52814. * @ignore
  52815. * The highlights enhancing PostProcess id in the pipeline
  52816. */
  52817. HighlightsEnhancingEffect: string;
  52818. /**
  52819. * @ignore
  52820. * The depth-of-field PostProcess id in the pipeline
  52821. */
  52822. LensDepthOfFieldEffect: string;
  52823. private _scene;
  52824. private _depthTexture;
  52825. private _grainTexture;
  52826. private _chromaticAberrationPostProcess;
  52827. private _highlightsPostProcess;
  52828. private _depthOfFieldPostProcess;
  52829. private _edgeBlur;
  52830. private _grainAmount;
  52831. private _chromaticAberration;
  52832. private _distortion;
  52833. private _highlightsGain;
  52834. private _highlightsThreshold;
  52835. private _dofDistance;
  52836. private _dofAperture;
  52837. private _dofDarken;
  52838. private _dofPentagon;
  52839. private _blurNoise;
  52840. /**
  52841. * @constructor
  52842. *
  52843. * Effect parameters are as follow:
  52844. * {
  52845. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52846. * edge_blur: number; // from 0 to x (1 for realism)
  52847. * distortion: number; // from 0 to x (1 for realism)
  52848. * grain_amount: number; // from 0 to 1
  52849. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52850. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52851. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52852. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52853. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52854. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52855. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52856. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52857. * }
  52858. * Note: if an effect parameter is unset, effect is disabled
  52859. *
  52860. * @param name The rendering pipeline name
  52861. * @param parameters - An object containing all parameters (see above)
  52862. * @param scene The scene linked to this pipeline
  52863. * @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)
  52864. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52865. */
  52866. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52867. /**
  52868. * Sets the amount of blur at the edges
  52869. * @param amount blur amount
  52870. */
  52871. setEdgeBlur(amount: number): void;
  52872. /**
  52873. * Sets edge blur to 0
  52874. */
  52875. disableEdgeBlur(): void;
  52876. /**
  52877. * Sets the amout of grain
  52878. * @param amount Amount of grain
  52879. */
  52880. setGrainAmount(amount: number): void;
  52881. /**
  52882. * Set grain amount to 0
  52883. */
  52884. disableGrain(): void;
  52885. /**
  52886. * Sets the chromatic aberration amount
  52887. * @param amount amount of chromatic aberration
  52888. */
  52889. setChromaticAberration(amount: number): void;
  52890. /**
  52891. * Sets chromatic aberration amount to 0
  52892. */
  52893. disableChromaticAberration(): void;
  52894. /**
  52895. * Sets the EdgeDistortion amount
  52896. * @param amount amount of EdgeDistortion
  52897. */
  52898. setEdgeDistortion(amount: number): void;
  52899. /**
  52900. * Sets edge distortion to 0
  52901. */
  52902. disableEdgeDistortion(): void;
  52903. /**
  52904. * Sets the FocusDistance amount
  52905. * @param amount amount of FocusDistance
  52906. */
  52907. setFocusDistance(amount: number): void;
  52908. /**
  52909. * Disables depth of field
  52910. */
  52911. disableDepthOfField(): void;
  52912. /**
  52913. * Sets the Aperture amount
  52914. * @param amount amount of Aperture
  52915. */
  52916. setAperture(amount: number): void;
  52917. /**
  52918. * Sets the DarkenOutOfFocus amount
  52919. * @param amount amount of DarkenOutOfFocus
  52920. */
  52921. setDarkenOutOfFocus(amount: number): void;
  52922. /**
  52923. * Creates a pentagon bokeh effect
  52924. */
  52925. enablePentagonBokeh(): void;
  52926. /**
  52927. * Disables the pentagon bokeh effect
  52928. */
  52929. disablePentagonBokeh(): void;
  52930. /**
  52931. * Enables noise blur
  52932. */
  52933. enableNoiseBlur(): void;
  52934. /**
  52935. * Disables noise blur
  52936. */
  52937. disableNoiseBlur(): void;
  52938. /**
  52939. * Sets the HighlightsGain amount
  52940. * @param amount amount of HighlightsGain
  52941. */
  52942. setHighlightsGain(amount: number): void;
  52943. /**
  52944. * Sets the HighlightsThreshold amount
  52945. * @param amount amount of HighlightsThreshold
  52946. */
  52947. setHighlightsThreshold(amount: number): void;
  52948. /**
  52949. * Disables highlights
  52950. */
  52951. disableHighlights(): void;
  52952. /**
  52953. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52954. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52955. */
  52956. dispose(disableDepthRender?: boolean): void;
  52957. private _createChromaticAberrationPostProcess;
  52958. private _createHighlightsPostProcess;
  52959. private _createDepthOfFieldPostProcess;
  52960. private _createGrainTexture;
  52961. }
  52962. }
  52963. declare module "babylonjs/Shaders/ssao2.fragment" {
  52964. /** @hidden */
  52965. export var ssao2PixelShader: {
  52966. name: string;
  52967. shader: string;
  52968. };
  52969. }
  52970. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  52971. /** @hidden */
  52972. export var ssaoCombinePixelShader: {
  52973. name: string;
  52974. shader: string;
  52975. };
  52976. }
  52977. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  52978. import { Camera } from "babylonjs/Cameras/camera";
  52979. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  52980. import { Scene } from "babylonjs/scene";
  52981. import "babylonjs/Shaders/ssao2.fragment";
  52982. import "babylonjs/Shaders/ssaoCombine.fragment";
  52983. /**
  52984. * Render pipeline to produce ssao effect
  52985. */
  52986. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52987. /**
  52988. * @ignore
  52989. * The PassPostProcess id in the pipeline that contains the original scene color
  52990. */
  52991. SSAOOriginalSceneColorEffect: string;
  52992. /**
  52993. * @ignore
  52994. * The SSAO PostProcess id in the pipeline
  52995. */
  52996. SSAORenderEffect: string;
  52997. /**
  52998. * @ignore
  52999. * The horizontal blur PostProcess id in the pipeline
  53000. */
  53001. SSAOBlurHRenderEffect: string;
  53002. /**
  53003. * @ignore
  53004. * The vertical blur PostProcess id in the pipeline
  53005. */
  53006. SSAOBlurVRenderEffect: string;
  53007. /**
  53008. * @ignore
  53009. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53010. */
  53011. SSAOCombineRenderEffect: string;
  53012. /**
  53013. * The output strength of the SSAO post-process. Default value is 1.0.
  53014. */
  53015. totalStrength: number;
  53016. /**
  53017. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53018. */
  53019. maxZ: number;
  53020. /**
  53021. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53022. */
  53023. minZAspect: number;
  53024. private _samples;
  53025. /**
  53026. * Number of samples used for the SSAO calculations. Default value is 8
  53027. */
  53028. samples: number;
  53029. private _textureSamples;
  53030. /**
  53031. * Number of samples to use for antialiasing
  53032. */
  53033. textureSamples: number;
  53034. /**
  53035. * Ratio object used for SSAO ratio and blur ratio
  53036. */
  53037. private _ratio;
  53038. /**
  53039. * Dynamically generated sphere sampler.
  53040. */
  53041. private _sampleSphere;
  53042. /**
  53043. * Blur filter offsets
  53044. */
  53045. private _samplerOffsets;
  53046. private _expensiveBlur;
  53047. /**
  53048. * If bilateral blur should be used
  53049. */
  53050. expensiveBlur: boolean;
  53051. /**
  53052. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53053. */
  53054. radius: number;
  53055. /**
  53056. * The base color of the SSAO post-process
  53057. * The final result is "base + ssao" between [0, 1]
  53058. */
  53059. base: number;
  53060. /**
  53061. * Support test.
  53062. */
  53063. static readonly IsSupported: boolean;
  53064. private _scene;
  53065. private _depthTexture;
  53066. private _normalTexture;
  53067. private _randomTexture;
  53068. private _originalColorPostProcess;
  53069. private _ssaoPostProcess;
  53070. private _blurHPostProcess;
  53071. private _blurVPostProcess;
  53072. private _ssaoCombinePostProcess;
  53073. private _firstUpdate;
  53074. /**
  53075. * @constructor
  53076. * @param name The rendering pipeline name
  53077. * @param scene The scene linked to this pipeline
  53078. * @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 }
  53079. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53080. */
  53081. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53082. /**
  53083. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53084. */
  53085. dispose(disableGeometryBufferRenderer?: boolean): void;
  53086. private _createBlurPostProcess;
  53087. /** @hidden */
  53088. _rebuild(): void;
  53089. private _bits;
  53090. private _radicalInverse_VdC;
  53091. private _hammersley;
  53092. private _hemisphereSample_uniform;
  53093. private _generateHemisphere;
  53094. private _createSSAOPostProcess;
  53095. private _createSSAOCombinePostProcess;
  53096. private _createRandomTexture;
  53097. /**
  53098. * Serialize the rendering pipeline (Used when exporting)
  53099. * @returns the serialized object
  53100. */
  53101. serialize(): any;
  53102. /**
  53103. * Parse the serialized pipeline
  53104. * @param source Source pipeline.
  53105. * @param scene The scene to load the pipeline to.
  53106. * @param rootUrl The URL of the serialized pipeline.
  53107. * @returns An instantiated pipeline from the serialized object.
  53108. */
  53109. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53110. }
  53111. }
  53112. declare module "babylonjs/Shaders/ssao.fragment" {
  53113. /** @hidden */
  53114. export var ssaoPixelShader: {
  53115. name: string;
  53116. shader: string;
  53117. };
  53118. }
  53119. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  53120. import { Camera } from "babylonjs/Cameras/camera";
  53121. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53122. import { Scene } from "babylonjs/scene";
  53123. import "babylonjs/Shaders/ssao.fragment";
  53124. import "babylonjs/Shaders/ssaoCombine.fragment";
  53125. /**
  53126. * Render pipeline to produce ssao effect
  53127. */
  53128. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53129. /**
  53130. * @ignore
  53131. * The PassPostProcess id in the pipeline that contains the original scene color
  53132. */
  53133. SSAOOriginalSceneColorEffect: string;
  53134. /**
  53135. * @ignore
  53136. * The SSAO PostProcess id in the pipeline
  53137. */
  53138. SSAORenderEffect: string;
  53139. /**
  53140. * @ignore
  53141. * The horizontal blur PostProcess id in the pipeline
  53142. */
  53143. SSAOBlurHRenderEffect: string;
  53144. /**
  53145. * @ignore
  53146. * The vertical blur PostProcess id in the pipeline
  53147. */
  53148. SSAOBlurVRenderEffect: string;
  53149. /**
  53150. * @ignore
  53151. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53152. */
  53153. SSAOCombineRenderEffect: string;
  53154. /**
  53155. * The output strength of the SSAO post-process. Default value is 1.0.
  53156. */
  53157. totalStrength: number;
  53158. /**
  53159. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53160. */
  53161. radius: number;
  53162. /**
  53163. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53164. * Must not be equal to fallOff and superior to fallOff.
  53165. * Default value is 0.975
  53166. */
  53167. area: number;
  53168. /**
  53169. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53170. * Must not be equal to area and inferior to area.
  53171. * Default value is 0.0
  53172. */
  53173. fallOff: number;
  53174. /**
  53175. * The base color of the SSAO post-process
  53176. * The final result is "base + ssao" between [0, 1]
  53177. */
  53178. base: number;
  53179. private _scene;
  53180. private _depthTexture;
  53181. private _randomTexture;
  53182. private _originalColorPostProcess;
  53183. private _ssaoPostProcess;
  53184. private _blurHPostProcess;
  53185. private _blurVPostProcess;
  53186. private _ssaoCombinePostProcess;
  53187. private _firstUpdate;
  53188. /**
  53189. * @constructor
  53190. * @param name - The rendering pipeline name
  53191. * @param scene - The scene linked to this pipeline
  53192. * @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 }
  53193. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53194. */
  53195. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53196. /**
  53197. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53198. */
  53199. dispose(disableDepthRender?: boolean): void;
  53200. private _createBlurPostProcess;
  53201. /** @hidden */
  53202. _rebuild(): void;
  53203. private _createSSAOPostProcess;
  53204. private _createSSAOCombinePostProcess;
  53205. private _createRandomTexture;
  53206. }
  53207. }
  53208. declare module "babylonjs/Shaders/standard.fragment" {
  53209. /** @hidden */
  53210. export var standardPixelShader: {
  53211. name: string;
  53212. shader: string;
  53213. };
  53214. }
  53215. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  53216. import { Nullable } from "babylonjs/types";
  53217. import { IAnimatable } from "babylonjs/Misc/tools";
  53218. import { Camera } from "babylonjs/Cameras/camera";
  53219. import { Texture } from "babylonjs/Materials/Textures/texture";
  53220. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53221. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53222. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  53223. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  53224. import { IDisposable } from "babylonjs/scene";
  53225. import { SpotLight } from "babylonjs/Lights/spotLight";
  53226. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  53227. import { Scene } from "babylonjs/scene";
  53228. import { Animation } from "babylonjs/Animations/animation";
  53229. import "babylonjs/Shaders/standard.fragment";
  53230. /**
  53231. * Standard rendering pipeline
  53232. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53233. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53234. */
  53235. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53236. /**
  53237. * Public members
  53238. */
  53239. /**
  53240. * Post-process which contains the original scene color before the pipeline applies all the effects
  53241. */
  53242. originalPostProcess: Nullable<PostProcess>;
  53243. /**
  53244. * Post-process used to down scale an image x4
  53245. */
  53246. downSampleX4PostProcess: Nullable<PostProcess>;
  53247. /**
  53248. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53249. */
  53250. brightPassPostProcess: Nullable<PostProcess>;
  53251. /**
  53252. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53253. */
  53254. blurHPostProcesses: PostProcess[];
  53255. /**
  53256. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53257. */
  53258. blurVPostProcesses: PostProcess[];
  53259. /**
  53260. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53261. */
  53262. textureAdderPostProcess: Nullable<PostProcess>;
  53263. /**
  53264. * Post-process used to create volumetric lighting effect
  53265. */
  53266. volumetricLightPostProcess: Nullable<PostProcess>;
  53267. /**
  53268. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53269. */
  53270. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53271. /**
  53272. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53273. */
  53274. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53275. /**
  53276. * Post-process used to merge the volumetric light effect and the real scene color
  53277. */
  53278. volumetricLightMergePostProces: Nullable<PostProcess>;
  53279. /**
  53280. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53281. */
  53282. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53283. /**
  53284. * Base post-process used to calculate the average luminance of the final image for HDR
  53285. */
  53286. luminancePostProcess: Nullable<PostProcess>;
  53287. /**
  53288. * Post-processes used to create down sample post-processes in order to get
  53289. * the average luminance of the final image for HDR
  53290. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53291. */
  53292. luminanceDownSamplePostProcesses: PostProcess[];
  53293. /**
  53294. * Post-process used to create a HDR effect (light adaptation)
  53295. */
  53296. hdrPostProcess: Nullable<PostProcess>;
  53297. /**
  53298. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53299. */
  53300. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53301. /**
  53302. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53303. */
  53304. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53305. /**
  53306. * Post-process used to merge the final HDR post-process and the real scene color
  53307. */
  53308. hdrFinalPostProcess: Nullable<PostProcess>;
  53309. /**
  53310. * Post-process used to create a lens flare effect
  53311. */
  53312. lensFlarePostProcess: Nullable<PostProcess>;
  53313. /**
  53314. * Post-process that merges the result of the lens flare post-process and the real scene color
  53315. */
  53316. lensFlareComposePostProcess: Nullable<PostProcess>;
  53317. /**
  53318. * Post-process used to create a motion blur effect
  53319. */
  53320. motionBlurPostProcess: Nullable<PostProcess>;
  53321. /**
  53322. * Post-process used to create a depth of field effect
  53323. */
  53324. depthOfFieldPostProcess: Nullable<PostProcess>;
  53325. /**
  53326. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53327. */
  53328. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53329. /**
  53330. * Represents the brightness threshold in order to configure the illuminated surfaces
  53331. */
  53332. brightThreshold: number;
  53333. /**
  53334. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53335. */
  53336. blurWidth: number;
  53337. /**
  53338. * Sets if the blur for highlighted surfaces must be only horizontal
  53339. */
  53340. horizontalBlur: boolean;
  53341. /**
  53342. * Sets the overall exposure used by the pipeline
  53343. */
  53344. exposure: number;
  53345. /**
  53346. * Texture used typically to simulate "dirty" on camera lens
  53347. */
  53348. lensTexture: Nullable<Texture>;
  53349. /**
  53350. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53351. */
  53352. volumetricLightCoefficient: number;
  53353. /**
  53354. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53355. */
  53356. volumetricLightPower: number;
  53357. /**
  53358. * Used the set the blur intensity to smooth the volumetric lights
  53359. */
  53360. volumetricLightBlurScale: number;
  53361. /**
  53362. * Light (spot or directional) used to generate the volumetric lights rays
  53363. * The source light must have a shadow generate so the pipeline can get its
  53364. * depth map
  53365. */
  53366. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53367. /**
  53368. * For eye adaptation, represents the minimum luminance the eye can see
  53369. */
  53370. hdrMinimumLuminance: number;
  53371. /**
  53372. * For eye adaptation, represents the decrease luminance speed
  53373. */
  53374. hdrDecreaseRate: number;
  53375. /**
  53376. * For eye adaptation, represents the increase luminance speed
  53377. */
  53378. hdrIncreaseRate: number;
  53379. /**
  53380. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53381. */
  53382. lensColorTexture: Nullable<Texture>;
  53383. /**
  53384. * The overall strengh for the lens flare effect
  53385. */
  53386. lensFlareStrength: number;
  53387. /**
  53388. * Dispersion coefficient for lens flare ghosts
  53389. */
  53390. lensFlareGhostDispersal: number;
  53391. /**
  53392. * Main lens flare halo width
  53393. */
  53394. lensFlareHaloWidth: number;
  53395. /**
  53396. * Based on the lens distortion effect, defines how much the lens flare result
  53397. * is distorted
  53398. */
  53399. lensFlareDistortionStrength: number;
  53400. /**
  53401. * Lens star texture must be used to simulate rays on the flares and is available
  53402. * in the documentation
  53403. */
  53404. lensStarTexture: Nullable<Texture>;
  53405. /**
  53406. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53407. * flare effect by taking account of the dirt texture
  53408. */
  53409. lensFlareDirtTexture: Nullable<Texture>;
  53410. /**
  53411. * Represents the focal length for the depth of field effect
  53412. */
  53413. depthOfFieldDistance: number;
  53414. /**
  53415. * Represents the blur intensity for the blurred part of the depth of field effect
  53416. */
  53417. depthOfFieldBlurWidth: number;
  53418. /**
  53419. * For motion blur, defines how much the image is blurred by the movement
  53420. */
  53421. motionStrength: number;
  53422. /**
  53423. * List of animations for the pipeline (IAnimatable implementation)
  53424. */
  53425. animations: Animation[];
  53426. /**
  53427. * Private members
  53428. */
  53429. private _scene;
  53430. private _currentDepthOfFieldSource;
  53431. private _basePostProcess;
  53432. private _hdrCurrentLuminance;
  53433. private _floatTextureType;
  53434. private _ratio;
  53435. private _bloomEnabled;
  53436. private _depthOfFieldEnabled;
  53437. private _vlsEnabled;
  53438. private _lensFlareEnabled;
  53439. private _hdrEnabled;
  53440. private _motionBlurEnabled;
  53441. private _fxaaEnabled;
  53442. private _motionBlurSamples;
  53443. private _volumetricLightStepsCount;
  53444. private _samples;
  53445. /**
  53446. * @ignore
  53447. * Specifies if the bloom pipeline is enabled
  53448. */
  53449. BloomEnabled: boolean;
  53450. /**
  53451. * @ignore
  53452. * Specifies if the depth of field pipeline is enabed
  53453. */
  53454. DepthOfFieldEnabled: boolean;
  53455. /**
  53456. * @ignore
  53457. * Specifies if the lens flare pipeline is enabed
  53458. */
  53459. LensFlareEnabled: boolean;
  53460. /**
  53461. * @ignore
  53462. * Specifies if the HDR pipeline is enabled
  53463. */
  53464. HDREnabled: boolean;
  53465. /**
  53466. * @ignore
  53467. * Specifies if the volumetric lights scattering effect is enabled
  53468. */
  53469. VLSEnabled: boolean;
  53470. /**
  53471. * @ignore
  53472. * Specifies if the motion blur effect is enabled
  53473. */
  53474. MotionBlurEnabled: boolean;
  53475. /**
  53476. * Specifies if anti-aliasing is enabled
  53477. */
  53478. fxaaEnabled: boolean;
  53479. /**
  53480. * Specifies the number of steps used to calculate the volumetric lights
  53481. * Typically in interval [50, 200]
  53482. */
  53483. volumetricLightStepsCount: number;
  53484. /**
  53485. * Specifies the number of samples used for the motion blur effect
  53486. * Typically in interval [16, 64]
  53487. */
  53488. motionBlurSamples: number;
  53489. /**
  53490. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53491. */
  53492. samples: number;
  53493. /**
  53494. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53495. * @constructor
  53496. * @param name The rendering pipeline name
  53497. * @param scene The scene linked to this pipeline
  53498. * @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)
  53499. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53500. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53501. */
  53502. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53503. private _buildPipeline;
  53504. private _createDownSampleX4PostProcess;
  53505. private _createBrightPassPostProcess;
  53506. private _createBlurPostProcesses;
  53507. private _createTextureAdderPostProcess;
  53508. private _createVolumetricLightPostProcess;
  53509. private _createLuminancePostProcesses;
  53510. private _createHdrPostProcess;
  53511. private _createLensFlarePostProcess;
  53512. private _createDepthOfFieldPostProcess;
  53513. private _createMotionBlurPostProcess;
  53514. private _getDepthTexture;
  53515. private _disposePostProcesses;
  53516. /**
  53517. * Dispose of the pipeline and stop all post processes
  53518. */
  53519. dispose(): void;
  53520. /**
  53521. * Serialize the rendering pipeline (Used when exporting)
  53522. * @returns the serialized object
  53523. */
  53524. serialize(): any;
  53525. /**
  53526. * Parse the serialized pipeline
  53527. * @param source Source pipeline.
  53528. * @param scene The scene to load the pipeline to.
  53529. * @param rootUrl The URL of the serialized pipeline.
  53530. * @returns An instantiated pipeline from the serialized object.
  53531. */
  53532. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53533. /**
  53534. * Luminance steps
  53535. */
  53536. static LuminanceSteps: number;
  53537. }
  53538. }
  53539. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  53540. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  53541. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  53542. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  53543. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  53544. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  53545. }
  53546. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  53547. import { Camera } from "babylonjs/Cameras/camera";
  53548. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53549. /**
  53550. * PostProcessRenderPipelineManager class
  53551. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53552. */
  53553. export class PostProcessRenderPipelineManager {
  53554. private _renderPipelines;
  53555. /**
  53556. * Initializes a PostProcessRenderPipelineManager
  53557. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53558. */
  53559. constructor();
  53560. /**
  53561. * Adds a pipeline to the manager
  53562. * @param renderPipeline The pipeline to add
  53563. */
  53564. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  53565. /**
  53566. * Attaches a camera to the pipeline
  53567. * @param renderPipelineName The name of the pipeline to attach to
  53568. * @param cameras the camera to attach
  53569. * @param unique if the camera can be attached multiple times to the pipeline
  53570. */
  53571. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  53572. /**
  53573. * Detaches a camera from the pipeline
  53574. * @param renderPipelineName The name of the pipeline to detach from
  53575. * @param cameras the camera to detach
  53576. */
  53577. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  53578. /**
  53579. * Enables an effect by name on a pipeline
  53580. * @param renderPipelineName the name of the pipeline to enable the effect in
  53581. * @param renderEffectName the name of the effect to enable
  53582. * @param cameras the cameras that the effect should be enabled on
  53583. */
  53584. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53585. /**
  53586. * Disables an effect by name on a pipeline
  53587. * @param renderPipelineName the name of the pipeline to disable the effect in
  53588. * @param renderEffectName the name of the effect to disable
  53589. * @param cameras the cameras that the effect should be disabled on
  53590. */
  53591. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  53592. /**
  53593. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  53594. */
  53595. update(): void;
  53596. /** @hidden */
  53597. _rebuild(): void;
  53598. /**
  53599. * Disposes of the manager and pipelines
  53600. */
  53601. dispose(): void;
  53602. }
  53603. }
  53604. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  53605. import { ISceneComponent } from "babylonjs/sceneComponent";
  53606. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53607. import { Scene } from "babylonjs/scene";
  53608. module "babylonjs/scene" {
  53609. interface Scene {
  53610. /** @hidden (Backing field) */
  53611. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53612. /**
  53613. * Gets the postprocess render pipeline manager
  53614. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53615. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  53616. */
  53617. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  53618. }
  53619. }
  53620. /**
  53621. * Defines the Render Pipeline scene component responsible to rendering pipelines
  53622. */
  53623. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  53624. /**
  53625. * The component name helpfull to identify the component in the list of scene components.
  53626. */
  53627. readonly name: string;
  53628. /**
  53629. * The scene the component belongs to.
  53630. */
  53631. scene: Scene;
  53632. /**
  53633. * Creates a new instance of the component for the given scene
  53634. * @param scene Defines the scene to register the component in
  53635. */
  53636. constructor(scene: Scene);
  53637. /**
  53638. * Registers the component in a given scene
  53639. */
  53640. register(): void;
  53641. /**
  53642. * Rebuilds the elements related to this component in case of
  53643. * context lost for instance.
  53644. */
  53645. rebuild(): void;
  53646. /**
  53647. * Disposes the component and the associated ressources
  53648. */
  53649. dispose(): void;
  53650. private _gatherRenderTargets;
  53651. }
  53652. }
  53653. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  53654. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  53655. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  53656. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  53657. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  53658. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  53659. }
  53660. declare module "babylonjs/Shaders/tonemap.fragment" {
  53661. /** @hidden */
  53662. export var tonemapPixelShader: {
  53663. name: string;
  53664. shader: string;
  53665. };
  53666. }
  53667. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  53668. import { Camera } from "babylonjs/Cameras/camera";
  53669. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53670. import "babylonjs/Shaders/tonemap.fragment";
  53671. import { Engine } from "babylonjs/Engines/engine";
  53672. /** Defines operator used for tonemapping */
  53673. export enum TonemappingOperator {
  53674. /** Hable */
  53675. Hable = 0,
  53676. /** Reinhard */
  53677. Reinhard = 1,
  53678. /** HejiDawson */
  53679. HejiDawson = 2,
  53680. /** Photographic */
  53681. Photographic = 3
  53682. }
  53683. /**
  53684. * Defines a post process to apply tone mapping
  53685. */
  53686. export class TonemapPostProcess extends PostProcess {
  53687. private _operator;
  53688. /** Defines the required exposure adjustement */
  53689. exposureAdjustment: number;
  53690. /**
  53691. * Creates a new TonemapPostProcess
  53692. * @param name defines the name of the postprocess
  53693. * @param _operator defines the operator to use
  53694. * @param exposureAdjustment defines the required exposure adjustement
  53695. * @param camera defines the camera to use (can be null)
  53696. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53697. * @param engine defines the hosting engine (can be ignore if camera is set)
  53698. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53699. */
  53700. constructor(name: string, _operator: TonemappingOperator,
  53701. /** Defines the required exposure adjustement */
  53702. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53703. }
  53704. }
  53705. declare module "babylonjs/Shaders/depth.vertex" {
  53706. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53707. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53708. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53709. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53710. /** @hidden */
  53711. export var depthVertexShader: {
  53712. name: string;
  53713. shader: string;
  53714. };
  53715. }
  53716. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  53717. /** @hidden */
  53718. export var volumetricLightScatteringPixelShader: {
  53719. name: string;
  53720. shader: string;
  53721. };
  53722. }
  53723. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  53724. /** @hidden */
  53725. export var volumetricLightScatteringPassPixelShader: {
  53726. name: string;
  53727. shader: string;
  53728. };
  53729. }
  53730. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  53731. import { Vector3 } from "babylonjs/Maths/math";
  53732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53733. import { Mesh } from "babylonjs/Meshes/mesh";
  53734. import { Camera } from "babylonjs/Cameras/camera";
  53735. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53736. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  53737. import { Scene } from "babylonjs/scene";
  53738. import "babylonjs/Meshes/Builders/planeBuilder";
  53739. import "babylonjs/Shaders/depth.vertex";
  53740. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  53741. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  53742. import { Engine } from "babylonjs/Engines/engine";
  53743. /**
  53744. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53745. */
  53746. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53747. private _volumetricLightScatteringPass;
  53748. private _volumetricLightScatteringRTT;
  53749. private _viewPort;
  53750. private _screenCoordinates;
  53751. private _cachedDefines;
  53752. /**
  53753. * If not undefined, the mesh position is computed from the attached node position
  53754. */
  53755. attachedNode: {
  53756. position: Vector3;
  53757. };
  53758. /**
  53759. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53760. */
  53761. customMeshPosition: Vector3;
  53762. /**
  53763. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53764. */
  53765. useCustomMeshPosition: boolean;
  53766. /**
  53767. * If the post-process should inverse the light scattering direction
  53768. */
  53769. invert: boolean;
  53770. /**
  53771. * The internal mesh used by the post-process
  53772. */
  53773. mesh: Mesh;
  53774. /**
  53775. * @hidden
  53776. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53777. */
  53778. useDiffuseColor: boolean;
  53779. /**
  53780. * Array containing the excluded meshes not rendered in the internal pass
  53781. */
  53782. excludedMeshes: AbstractMesh[];
  53783. /**
  53784. * Controls the overall intensity of the post-process
  53785. */
  53786. exposure: number;
  53787. /**
  53788. * Dissipates each sample's contribution in range [0, 1]
  53789. */
  53790. decay: number;
  53791. /**
  53792. * Controls the overall intensity of each sample
  53793. */
  53794. weight: number;
  53795. /**
  53796. * Controls the density of each sample
  53797. */
  53798. density: number;
  53799. /**
  53800. * @constructor
  53801. * @param name The post-process name
  53802. * @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)
  53803. * @param camera The camera that the post-process will be attached to
  53804. * @param mesh The mesh used to create the light scattering
  53805. * @param samples The post-process quality, default 100
  53806. * @param samplingModeThe post-process filtering mode
  53807. * @param engine The babylon engine
  53808. * @param reusable If the post-process is reusable
  53809. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53810. */
  53811. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53812. /**
  53813. * Returns the string "VolumetricLightScatteringPostProcess"
  53814. * @returns "VolumetricLightScatteringPostProcess"
  53815. */
  53816. getClassName(): string;
  53817. private _isReady;
  53818. /**
  53819. * Sets the new light position for light scattering effect
  53820. * @param position The new custom light position
  53821. */
  53822. setCustomMeshPosition(position: Vector3): void;
  53823. /**
  53824. * Returns the light position for light scattering effect
  53825. * @return Vector3 The custom light position
  53826. */
  53827. getCustomMeshPosition(): Vector3;
  53828. /**
  53829. * Disposes the internal assets and detaches the post-process from the camera
  53830. */
  53831. dispose(camera: Camera): void;
  53832. /**
  53833. * Returns the render target texture used by the post-process
  53834. * @return the render target texture used by the post-process
  53835. */
  53836. getPass(): RenderTargetTexture;
  53837. private _meshExcluded;
  53838. private _createPass;
  53839. private _updateMeshScreenCoordinates;
  53840. /**
  53841. * Creates a default mesh for the Volumeric Light Scattering post-process
  53842. * @param name The mesh name
  53843. * @param scene The scene where to create the mesh
  53844. * @return the default mesh
  53845. */
  53846. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53847. }
  53848. }
  53849. declare module "babylonjs/PostProcesses/index" {
  53850. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  53851. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  53852. export * from "babylonjs/PostProcesses/bloomEffect";
  53853. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  53854. export * from "babylonjs/PostProcesses/blurPostProcess";
  53855. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  53856. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  53857. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  53858. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  53859. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  53860. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  53861. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  53862. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  53863. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  53864. export * from "babylonjs/PostProcesses/filterPostProcess";
  53865. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  53866. export * from "babylonjs/PostProcesses/grainPostProcess";
  53867. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  53868. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  53869. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  53870. export * from "babylonjs/PostProcesses/passPostProcess";
  53871. export * from "babylonjs/PostProcesses/postProcess";
  53872. export * from "babylonjs/PostProcesses/postProcessManager";
  53873. export * from "babylonjs/PostProcesses/refractionPostProcess";
  53874. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  53875. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  53876. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  53877. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  53878. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  53879. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  53880. }
  53881. declare module "babylonjs/Probes/index" {
  53882. export * from "babylonjs/Probes/reflectionProbe";
  53883. }
  53884. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  53885. import { Scene } from "babylonjs/scene";
  53886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53887. import { Color3 } from "babylonjs/Maths/math";
  53888. import { SmartArray } from "babylonjs/Misc/smartArray";
  53889. import { ISceneComponent } from "babylonjs/sceneComponent";
  53890. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  53891. import "babylonjs/Meshes/Builders/boxBuilder";
  53892. import "babylonjs/Shaders/color.fragment";
  53893. import "babylonjs/Shaders/color.vertex";
  53894. module "babylonjs/scene" {
  53895. interface Scene {
  53896. /** @hidden (Backing field) */
  53897. _boundingBoxRenderer: BoundingBoxRenderer;
  53898. /** @hidden (Backing field) */
  53899. _forceShowBoundingBoxes: boolean;
  53900. /**
  53901. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53902. */
  53903. forceShowBoundingBoxes: boolean;
  53904. /**
  53905. * Gets the bounding box renderer associated with the scene
  53906. * @returns a BoundingBoxRenderer
  53907. */
  53908. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53909. }
  53910. }
  53911. module "babylonjs/Meshes/abstractMesh" {
  53912. interface AbstractMesh {
  53913. /** @hidden (Backing field) */
  53914. _showBoundingBox: boolean;
  53915. /**
  53916. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53917. */
  53918. showBoundingBox: boolean;
  53919. }
  53920. }
  53921. /**
  53922. * Component responsible of rendering the bounding box of the meshes in a scene.
  53923. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53924. */
  53925. export class BoundingBoxRenderer implements ISceneComponent {
  53926. /**
  53927. * The component name helpfull to identify the component in the list of scene components.
  53928. */
  53929. readonly name: string;
  53930. /**
  53931. * The scene the component belongs to.
  53932. */
  53933. scene: Scene;
  53934. /**
  53935. * Color of the bounding box lines placed in front of an object
  53936. */
  53937. frontColor: Color3;
  53938. /**
  53939. * Color of the bounding box lines placed behind an object
  53940. */
  53941. backColor: Color3;
  53942. /**
  53943. * Defines if the renderer should show the back lines or not
  53944. */
  53945. showBackLines: boolean;
  53946. /**
  53947. * @hidden
  53948. */
  53949. renderList: SmartArray<BoundingBox>;
  53950. private _colorShader;
  53951. private _vertexBuffers;
  53952. private _indexBuffer;
  53953. /**
  53954. * Instantiates a new bounding box renderer in a scene.
  53955. * @param scene the scene the renderer renders in
  53956. */
  53957. constructor(scene: Scene);
  53958. /**
  53959. * Registers the component in a given scene
  53960. */
  53961. register(): void;
  53962. private _evaluateSubMesh;
  53963. private _activeMesh;
  53964. private _prepareRessources;
  53965. private _createIndexBuffer;
  53966. /**
  53967. * Rebuilds the elements related to this component in case of
  53968. * context lost for instance.
  53969. */
  53970. rebuild(): void;
  53971. /**
  53972. * @hidden
  53973. */
  53974. reset(): void;
  53975. /**
  53976. * Render the bounding boxes of a specific rendering group
  53977. * @param renderingGroupId defines the rendering group to render
  53978. */
  53979. render(renderingGroupId: number): void;
  53980. /**
  53981. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53982. * @param mesh Define the mesh to render the occlusion bounding box for
  53983. */
  53984. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53985. /**
  53986. * Dispose and release the resources attached to this renderer.
  53987. */
  53988. dispose(): void;
  53989. }
  53990. }
  53991. declare module "babylonjs/Shaders/depth.fragment" {
  53992. /** @hidden */
  53993. export var depthPixelShader: {
  53994. name: string;
  53995. shader: string;
  53996. };
  53997. }
  53998. declare module "babylonjs/Rendering/depthRenderer" {
  53999. import { Nullable } from "babylonjs/types";
  54000. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54001. import { Scene } from "babylonjs/scene";
  54002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54003. import { Camera } from "babylonjs/Cameras/camera";
  54004. import "babylonjs/Shaders/depth.fragment";
  54005. import "babylonjs/Shaders/depth.vertex";
  54006. /**
  54007. * This represents a depth renderer in Babylon.
  54008. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54009. */
  54010. export class DepthRenderer {
  54011. private _scene;
  54012. private _depthMap;
  54013. private _effect;
  54014. private _cachedDefines;
  54015. private _camera;
  54016. /**
  54017. * Specifiess that the depth renderer will only be used within
  54018. * the camera it is created for.
  54019. * This can help forcing its rendering during the camera processing.
  54020. */
  54021. useOnlyInActiveCamera: boolean;
  54022. /** @hidden */
  54023. static _SceneComponentInitialization: (scene: Scene) => void;
  54024. /**
  54025. * Instantiates a depth renderer
  54026. * @param scene The scene the renderer belongs to
  54027. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54028. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54029. */
  54030. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54031. /**
  54032. * Creates the depth rendering effect and checks if the effect is ready.
  54033. * @param subMesh The submesh to be used to render the depth map of
  54034. * @param useInstances If multiple world instances should be used
  54035. * @returns if the depth renderer is ready to render the depth map
  54036. */
  54037. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54038. /**
  54039. * Gets the texture which the depth map will be written to.
  54040. * @returns The depth map texture
  54041. */
  54042. getDepthMap(): RenderTargetTexture;
  54043. /**
  54044. * Disposes of the depth renderer.
  54045. */
  54046. dispose(): void;
  54047. }
  54048. }
  54049. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  54050. import { Nullable } from "babylonjs/types";
  54051. import { Scene } from "babylonjs/scene";
  54052. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  54053. import { Camera } from "babylonjs/Cameras/camera";
  54054. import { ISceneComponent } from "babylonjs/sceneComponent";
  54055. module "babylonjs/scene" {
  54056. interface Scene {
  54057. /** @hidden (Backing field) */
  54058. _depthRenderer: {
  54059. [id: string]: DepthRenderer;
  54060. };
  54061. /**
  54062. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54063. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54064. * @returns the created depth renderer
  54065. */
  54066. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54067. /**
  54068. * Disables a depth renderer for a given camera
  54069. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54070. */
  54071. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54072. }
  54073. }
  54074. /**
  54075. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54076. * in several rendering techniques.
  54077. */
  54078. export class DepthRendererSceneComponent implements ISceneComponent {
  54079. /**
  54080. * The component name helpfull to identify the component in the list of scene components.
  54081. */
  54082. readonly name: string;
  54083. /**
  54084. * The scene the component belongs to.
  54085. */
  54086. scene: Scene;
  54087. /**
  54088. * Creates a new instance of the component for the given scene
  54089. * @param scene Defines the scene to register the component in
  54090. */
  54091. constructor(scene: Scene);
  54092. /**
  54093. * Registers the component in a given scene
  54094. */
  54095. register(): void;
  54096. /**
  54097. * Rebuilds the elements related to this component in case of
  54098. * context lost for instance.
  54099. */
  54100. rebuild(): void;
  54101. /**
  54102. * Disposes the component and the associated ressources
  54103. */
  54104. dispose(): void;
  54105. private _gatherRenderTargets;
  54106. private _gatherActiveCameraRenderTargets;
  54107. }
  54108. }
  54109. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  54110. import { Nullable } from "babylonjs/types";
  54111. import { Scene } from "babylonjs/scene";
  54112. import { ISceneComponent } from "babylonjs/sceneComponent";
  54113. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  54114. module "babylonjs/scene" {
  54115. interface Scene {
  54116. /** @hidden (Backing field) */
  54117. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54118. /**
  54119. * Gets or Sets the current geometry buffer associated to the scene.
  54120. */
  54121. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54122. /**
  54123. * Enables a GeometryBufferRender and associates it with the scene
  54124. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54125. * @returns the GeometryBufferRenderer
  54126. */
  54127. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54128. /**
  54129. * Disables the GeometryBufferRender associated with the scene
  54130. */
  54131. disableGeometryBufferRenderer(): void;
  54132. }
  54133. }
  54134. /**
  54135. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54136. * in several rendering techniques.
  54137. */
  54138. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54139. /**
  54140. * The component name helpful to identify the component in the list of scene components.
  54141. */
  54142. readonly name: string;
  54143. /**
  54144. * The scene the component belongs to.
  54145. */
  54146. scene: Scene;
  54147. /**
  54148. * Creates a new instance of the component for the given scene
  54149. * @param scene Defines the scene to register the component in
  54150. */
  54151. constructor(scene: Scene);
  54152. /**
  54153. * Registers the component in a given scene
  54154. */
  54155. register(): void;
  54156. /**
  54157. * Rebuilds the elements related to this component in case of
  54158. * context lost for instance.
  54159. */
  54160. rebuild(): void;
  54161. /**
  54162. * Disposes the component and the associated ressources
  54163. */
  54164. dispose(): void;
  54165. private _gatherRenderTargets;
  54166. }
  54167. }
  54168. declare module "babylonjs/Shaders/outline.fragment" {
  54169. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54170. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  54171. /** @hidden */
  54172. export var outlinePixelShader: {
  54173. name: string;
  54174. shader: string;
  54175. };
  54176. }
  54177. declare module "babylonjs/Shaders/outline.vertex" {
  54178. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54179. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54180. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  54181. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54182. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54183. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  54184. /** @hidden */
  54185. export var outlineVertexShader: {
  54186. name: string;
  54187. shader: string;
  54188. };
  54189. }
  54190. declare module "babylonjs/Rendering/outlineRenderer" {
  54191. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54192. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  54193. import { Scene } from "babylonjs/scene";
  54194. import { ISceneComponent } from "babylonjs/sceneComponent";
  54195. import "babylonjs/Shaders/outline.fragment";
  54196. import "babylonjs/Shaders/outline.vertex";
  54197. module "babylonjs/scene" {
  54198. interface Scene {
  54199. /** @hidden */
  54200. _outlineRenderer: OutlineRenderer;
  54201. /**
  54202. * Gets the outline renderer associated with the scene
  54203. * @returns a OutlineRenderer
  54204. */
  54205. getOutlineRenderer(): OutlineRenderer;
  54206. }
  54207. }
  54208. module "babylonjs/Meshes/abstractMesh" {
  54209. interface AbstractMesh {
  54210. /** @hidden (Backing field) */
  54211. _renderOutline: boolean;
  54212. /**
  54213. * Gets or sets a boolean indicating if the outline must be rendered as well
  54214. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54215. */
  54216. renderOutline: boolean;
  54217. /** @hidden (Backing field) */
  54218. _renderOverlay: boolean;
  54219. /**
  54220. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54221. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54222. */
  54223. renderOverlay: boolean;
  54224. }
  54225. }
  54226. /**
  54227. * This class is responsible to draw bothe outline/overlay of meshes.
  54228. * It should not be used directly but through the available method on mesh.
  54229. */
  54230. export class OutlineRenderer implements ISceneComponent {
  54231. /**
  54232. * The name of the component. Each component must have a unique name.
  54233. */
  54234. name: string;
  54235. /**
  54236. * The scene the component belongs to.
  54237. */
  54238. scene: Scene;
  54239. /**
  54240. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54241. */
  54242. zOffset: number;
  54243. private _engine;
  54244. private _effect;
  54245. private _cachedDefines;
  54246. private _savedDepthWrite;
  54247. /**
  54248. * Instantiates a new outline renderer. (There could be only one per scene).
  54249. * @param scene Defines the scene it belongs to
  54250. */
  54251. constructor(scene: Scene);
  54252. /**
  54253. * Register the component to one instance of a scene.
  54254. */
  54255. register(): void;
  54256. /**
  54257. * Rebuilds the elements related to this component in case of
  54258. * context lost for instance.
  54259. */
  54260. rebuild(): void;
  54261. /**
  54262. * Disposes the component and the associated ressources.
  54263. */
  54264. dispose(): void;
  54265. /**
  54266. * Renders the outline in the canvas.
  54267. * @param subMesh Defines the sumesh to render
  54268. * @param batch Defines the batch of meshes in case of instances
  54269. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54270. */
  54271. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54272. /**
  54273. * Returns whether or not the outline renderer is ready for a given submesh.
  54274. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54275. * @param subMesh Defines the submesh to check readyness for
  54276. * @param useInstances Defines wheter wee are trying to render instances or not
  54277. * @returns true if ready otherwise false
  54278. */
  54279. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54280. private _beforeRenderingMesh;
  54281. private _afterRenderingMesh;
  54282. }
  54283. }
  54284. declare module "babylonjs/Rendering/index" {
  54285. export * from "babylonjs/Rendering/boundingBoxRenderer";
  54286. export * from "babylonjs/Rendering/depthRenderer";
  54287. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  54288. export * from "babylonjs/Rendering/edgesRenderer";
  54289. export * from "babylonjs/Rendering/geometryBufferRenderer";
  54290. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  54291. export * from "babylonjs/Rendering/outlineRenderer";
  54292. export * from "babylonjs/Rendering/renderingGroup";
  54293. export * from "babylonjs/Rendering/renderingManager";
  54294. export * from "babylonjs/Rendering/utilityLayerRenderer";
  54295. }
  54296. declare module "babylonjs/Sprites/index" {
  54297. export * from "babylonjs/Sprites/sprite";
  54298. export * from "babylonjs/Sprites/spriteManager";
  54299. export * from "babylonjs/Sprites/spriteSceneComponent";
  54300. }
  54301. declare module "babylonjs/Misc/assetsManager" {
  54302. import { Scene } from "babylonjs/scene";
  54303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54304. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  54305. import { Skeleton } from "babylonjs/Bones/skeleton";
  54306. import { Observable } from "babylonjs/Misc/observable";
  54307. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54308. import { Texture } from "babylonjs/Materials/Textures/texture";
  54309. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54310. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  54311. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  54312. /**
  54313. * Defines the list of states available for a task inside a AssetsManager
  54314. */
  54315. export enum AssetTaskState {
  54316. /**
  54317. * Initialization
  54318. */
  54319. INIT = 0,
  54320. /**
  54321. * Running
  54322. */
  54323. RUNNING = 1,
  54324. /**
  54325. * Done
  54326. */
  54327. DONE = 2,
  54328. /**
  54329. * Error
  54330. */
  54331. ERROR = 3
  54332. }
  54333. /**
  54334. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54335. */
  54336. export abstract class AbstractAssetTask {
  54337. /**
  54338. * Task name
  54339. */ name: string;
  54340. /**
  54341. * Callback called when the task is successful
  54342. */
  54343. onSuccess: (task: any) => void;
  54344. /**
  54345. * Callback called when the task is not successful
  54346. */
  54347. onError: (task: any, message?: string, exception?: any) => void;
  54348. /**
  54349. * Creates a new AssetsManager
  54350. * @param name defines the name of the task
  54351. */
  54352. constructor(
  54353. /**
  54354. * Task name
  54355. */ name: string);
  54356. private _isCompleted;
  54357. private _taskState;
  54358. private _errorObject;
  54359. /**
  54360. * Get if the task is completed
  54361. */
  54362. readonly isCompleted: boolean;
  54363. /**
  54364. * Gets the current state of the task
  54365. */
  54366. readonly taskState: AssetTaskState;
  54367. /**
  54368. * Gets the current error object (if task is in error)
  54369. */
  54370. readonly errorObject: {
  54371. message?: string;
  54372. exception?: any;
  54373. };
  54374. /**
  54375. * Internal only
  54376. * @hidden
  54377. */
  54378. _setErrorObject(message?: string, exception?: any): void;
  54379. /**
  54380. * Execute the current task
  54381. * @param scene defines the scene where you want your assets to be loaded
  54382. * @param onSuccess is a callback called when the task is successfully executed
  54383. * @param onError is a callback called if an error occurs
  54384. */
  54385. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54386. /**
  54387. * Execute the current task
  54388. * @param scene defines the scene where you want your assets to be loaded
  54389. * @param onSuccess is a callback called when the task is successfully executed
  54390. * @param onError is a callback called if an error occurs
  54391. */
  54392. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54393. /**
  54394. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54395. * This can be used with failed tasks that have the reason for failure fixed.
  54396. */
  54397. reset(): void;
  54398. private onErrorCallback;
  54399. private onDoneCallback;
  54400. }
  54401. /**
  54402. * Define the interface used by progress events raised during assets loading
  54403. */
  54404. export interface IAssetsProgressEvent {
  54405. /**
  54406. * Defines the number of remaining tasks to process
  54407. */
  54408. remainingCount: number;
  54409. /**
  54410. * Defines the total number of tasks
  54411. */
  54412. totalCount: number;
  54413. /**
  54414. * Defines the task that was just processed
  54415. */
  54416. task: AbstractAssetTask;
  54417. }
  54418. /**
  54419. * Class used to share progress information about assets loading
  54420. */
  54421. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54422. /**
  54423. * Defines the number of remaining tasks to process
  54424. */
  54425. remainingCount: number;
  54426. /**
  54427. * Defines the total number of tasks
  54428. */
  54429. totalCount: number;
  54430. /**
  54431. * Defines the task that was just processed
  54432. */
  54433. task: AbstractAssetTask;
  54434. /**
  54435. * Creates a AssetsProgressEvent
  54436. * @param remainingCount defines the number of remaining tasks to process
  54437. * @param totalCount defines the total number of tasks
  54438. * @param task defines the task that was just processed
  54439. */
  54440. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54441. }
  54442. /**
  54443. * Define a task used by AssetsManager to load meshes
  54444. */
  54445. export class MeshAssetTask extends AbstractAssetTask {
  54446. /**
  54447. * Defines the name of the task
  54448. */
  54449. name: string;
  54450. /**
  54451. * Defines the list of mesh's names you want to load
  54452. */
  54453. meshesNames: any;
  54454. /**
  54455. * Defines the root url to use as a base to load your meshes and associated resources
  54456. */
  54457. rootUrl: string;
  54458. /**
  54459. * Defines the filename of the scene to load from
  54460. */
  54461. sceneFilename: string;
  54462. /**
  54463. * Gets the list of loaded meshes
  54464. */
  54465. loadedMeshes: Array<AbstractMesh>;
  54466. /**
  54467. * Gets the list of loaded particle systems
  54468. */
  54469. loadedParticleSystems: Array<IParticleSystem>;
  54470. /**
  54471. * Gets the list of loaded skeletons
  54472. */
  54473. loadedSkeletons: Array<Skeleton>;
  54474. /**
  54475. * Gets the list of loaded animation groups
  54476. */
  54477. loadedAnimationGroups: Array<AnimationGroup>;
  54478. /**
  54479. * Callback called when the task is successful
  54480. */
  54481. onSuccess: (task: MeshAssetTask) => void;
  54482. /**
  54483. * Callback called when the task is successful
  54484. */
  54485. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54486. /**
  54487. * Creates a new MeshAssetTask
  54488. * @param name defines the name of the task
  54489. * @param meshesNames defines the list of mesh's names you want to load
  54490. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54491. * @param sceneFilename defines the filename of the scene to load from
  54492. */
  54493. constructor(
  54494. /**
  54495. * Defines the name of the task
  54496. */
  54497. name: string,
  54498. /**
  54499. * Defines the list of mesh's names you want to load
  54500. */
  54501. meshesNames: any,
  54502. /**
  54503. * Defines the root url to use as a base to load your meshes and associated resources
  54504. */
  54505. rootUrl: string,
  54506. /**
  54507. * Defines the filename of the scene to load from
  54508. */
  54509. sceneFilename: string);
  54510. /**
  54511. * Execute the current task
  54512. * @param scene defines the scene where you want your assets to be loaded
  54513. * @param onSuccess is a callback called when the task is successfully executed
  54514. * @param onError is a callback called if an error occurs
  54515. */
  54516. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54517. }
  54518. /**
  54519. * Define a task used by AssetsManager to load text content
  54520. */
  54521. export class TextFileAssetTask extends AbstractAssetTask {
  54522. /**
  54523. * Defines the name of the task
  54524. */
  54525. name: string;
  54526. /**
  54527. * Defines the location of the file to load
  54528. */
  54529. url: string;
  54530. /**
  54531. * Gets the loaded text string
  54532. */
  54533. text: string;
  54534. /**
  54535. * Callback called when the task is successful
  54536. */
  54537. onSuccess: (task: TextFileAssetTask) => void;
  54538. /**
  54539. * Callback called when the task is successful
  54540. */
  54541. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54542. /**
  54543. * Creates a new TextFileAssetTask object
  54544. * @param name defines the name of the task
  54545. * @param url defines the location of the file to load
  54546. */
  54547. constructor(
  54548. /**
  54549. * Defines the name of the task
  54550. */
  54551. name: string,
  54552. /**
  54553. * Defines the location of the file to load
  54554. */
  54555. url: string);
  54556. /**
  54557. * Execute the current task
  54558. * @param scene defines the scene where you want your assets to be loaded
  54559. * @param onSuccess is a callback called when the task is successfully executed
  54560. * @param onError is a callback called if an error occurs
  54561. */
  54562. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54563. }
  54564. /**
  54565. * Define a task used by AssetsManager to load binary data
  54566. */
  54567. export class BinaryFileAssetTask extends AbstractAssetTask {
  54568. /**
  54569. * Defines the name of the task
  54570. */
  54571. name: string;
  54572. /**
  54573. * Defines the location of the file to load
  54574. */
  54575. url: string;
  54576. /**
  54577. * Gets the lodaded data (as an array buffer)
  54578. */
  54579. data: ArrayBuffer;
  54580. /**
  54581. * Callback called when the task is successful
  54582. */
  54583. onSuccess: (task: BinaryFileAssetTask) => void;
  54584. /**
  54585. * Callback called when the task is successful
  54586. */
  54587. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54588. /**
  54589. * Creates a new BinaryFileAssetTask object
  54590. * @param name defines the name of the new task
  54591. * @param url defines the location of the file to load
  54592. */
  54593. constructor(
  54594. /**
  54595. * Defines the name of the task
  54596. */
  54597. name: string,
  54598. /**
  54599. * Defines the location of the file to load
  54600. */
  54601. url: string);
  54602. /**
  54603. * Execute the current task
  54604. * @param scene defines the scene where you want your assets to be loaded
  54605. * @param onSuccess is a callback called when the task is successfully executed
  54606. * @param onError is a callback called if an error occurs
  54607. */
  54608. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54609. }
  54610. /**
  54611. * Define a task used by AssetsManager to load images
  54612. */
  54613. export class ImageAssetTask extends AbstractAssetTask {
  54614. /**
  54615. * Defines the name of the task
  54616. */
  54617. name: string;
  54618. /**
  54619. * Defines the location of the image to load
  54620. */
  54621. url: string;
  54622. /**
  54623. * Gets the loaded images
  54624. */
  54625. image: HTMLImageElement;
  54626. /**
  54627. * Callback called when the task is successful
  54628. */
  54629. onSuccess: (task: ImageAssetTask) => void;
  54630. /**
  54631. * Callback called when the task is successful
  54632. */
  54633. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54634. /**
  54635. * Creates a new ImageAssetTask
  54636. * @param name defines the name of the task
  54637. * @param url defines the location of the image to load
  54638. */
  54639. constructor(
  54640. /**
  54641. * Defines the name of the task
  54642. */
  54643. name: string,
  54644. /**
  54645. * Defines the location of the image to load
  54646. */
  54647. url: string);
  54648. /**
  54649. * Execute the current task
  54650. * @param scene defines the scene where you want your assets to be loaded
  54651. * @param onSuccess is a callback called when the task is successfully executed
  54652. * @param onError is a callback called if an error occurs
  54653. */
  54654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54655. }
  54656. /**
  54657. * Defines the interface used by texture loading tasks
  54658. */
  54659. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54660. /**
  54661. * Gets the loaded texture
  54662. */
  54663. texture: TEX;
  54664. }
  54665. /**
  54666. * Define a task used by AssetsManager to load 2D textures
  54667. */
  54668. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54669. /**
  54670. * Defines the name of the task
  54671. */
  54672. name: string;
  54673. /**
  54674. * Defines the location of the file to load
  54675. */
  54676. url: string;
  54677. /**
  54678. * Defines if mipmap should not be generated (default is false)
  54679. */
  54680. noMipmap?: boolean | undefined;
  54681. /**
  54682. * Defines if texture must be inverted on Y axis (default is false)
  54683. */
  54684. invertY?: boolean | undefined;
  54685. /**
  54686. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54687. */
  54688. samplingMode: number;
  54689. /**
  54690. * Gets the loaded texture
  54691. */
  54692. texture: Texture;
  54693. /**
  54694. * Callback called when the task is successful
  54695. */
  54696. onSuccess: (task: TextureAssetTask) => void;
  54697. /**
  54698. * Callback called when the task is successful
  54699. */
  54700. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54701. /**
  54702. * Creates a new TextureAssetTask object
  54703. * @param name defines the name of the task
  54704. * @param url defines the location of the file to load
  54705. * @param noMipmap defines if mipmap should not be generated (default is false)
  54706. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54707. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54708. */
  54709. constructor(
  54710. /**
  54711. * Defines the name of the task
  54712. */
  54713. name: string,
  54714. /**
  54715. * Defines the location of the file to load
  54716. */
  54717. url: string,
  54718. /**
  54719. * Defines if mipmap should not be generated (default is false)
  54720. */
  54721. noMipmap?: boolean | undefined,
  54722. /**
  54723. * Defines if texture must be inverted on Y axis (default is false)
  54724. */
  54725. invertY?: boolean | undefined,
  54726. /**
  54727. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54728. */
  54729. samplingMode?: number);
  54730. /**
  54731. * Execute the current task
  54732. * @param scene defines the scene where you want your assets to be loaded
  54733. * @param onSuccess is a callback called when the task is successfully executed
  54734. * @param onError is a callback called if an error occurs
  54735. */
  54736. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54737. }
  54738. /**
  54739. * Define a task used by AssetsManager to load cube textures
  54740. */
  54741. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54742. /**
  54743. * Defines the name of the task
  54744. */
  54745. name: string;
  54746. /**
  54747. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54748. */
  54749. url: string;
  54750. /**
  54751. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54752. */
  54753. extensions?: string[] | undefined;
  54754. /**
  54755. * Defines if mipmaps should not be generated (default is false)
  54756. */
  54757. noMipmap?: boolean | undefined;
  54758. /**
  54759. * Defines the explicit list of files (undefined by default)
  54760. */
  54761. files?: string[] | undefined;
  54762. /**
  54763. * Gets the loaded texture
  54764. */
  54765. texture: CubeTexture;
  54766. /**
  54767. * Callback called when the task is successful
  54768. */
  54769. onSuccess: (task: CubeTextureAssetTask) => void;
  54770. /**
  54771. * Callback called when the task is successful
  54772. */
  54773. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54774. /**
  54775. * Creates a new CubeTextureAssetTask
  54776. * @param name defines the name of the task
  54777. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54778. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54779. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54780. * @param files defines the explicit list of files (undefined by default)
  54781. */
  54782. constructor(
  54783. /**
  54784. * Defines the name of the task
  54785. */
  54786. name: string,
  54787. /**
  54788. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54789. */
  54790. url: string,
  54791. /**
  54792. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54793. */
  54794. extensions?: string[] | undefined,
  54795. /**
  54796. * Defines if mipmaps should not be generated (default is false)
  54797. */
  54798. noMipmap?: boolean | undefined,
  54799. /**
  54800. * Defines the explicit list of files (undefined by default)
  54801. */
  54802. files?: string[] | undefined);
  54803. /**
  54804. * Execute the current task
  54805. * @param scene defines the scene where you want your assets to be loaded
  54806. * @param onSuccess is a callback called when the task is successfully executed
  54807. * @param onError is a callback called if an error occurs
  54808. */
  54809. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54810. }
  54811. /**
  54812. * Define a task used by AssetsManager to load HDR cube textures
  54813. */
  54814. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54815. /**
  54816. * Defines the name of the task
  54817. */
  54818. name: string;
  54819. /**
  54820. * Defines the location of the file to load
  54821. */
  54822. url: string;
  54823. /**
  54824. * Defines the desired size (the more it increases the longer the generation will be)
  54825. */
  54826. size: number;
  54827. /**
  54828. * Defines if mipmaps should not be generated (default is false)
  54829. */
  54830. noMipmap: boolean;
  54831. /**
  54832. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54833. */
  54834. generateHarmonics: boolean;
  54835. /**
  54836. * 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)
  54837. */
  54838. gammaSpace: boolean;
  54839. /**
  54840. * Internal Use Only
  54841. */
  54842. reserved: boolean;
  54843. /**
  54844. * Gets the loaded texture
  54845. */
  54846. texture: HDRCubeTexture;
  54847. /**
  54848. * Callback called when the task is successful
  54849. */
  54850. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54851. /**
  54852. * Callback called when the task is successful
  54853. */
  54854. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54855. /**
  54856. * Creates a new HDRCubeTextureAssetTask object
  54857. * @param name defines the name of the task
  54858. * @param url defines the location of the file to load
  54859. * @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.
  54860. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54861. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54862. * @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)
  54863. * @param reserved Internal use only
  54864. */
  54865. constructor(
  54866. /**
  54867. * Defines the name of the task
  54868. */
  54869. name: string,
  54870. /**
  54871. * Defines the location of the file to load
  54872. */
  54873. url: string,
  54874. /**
  54875. * Defines the desired size (the more it increases the longer the generation will be)
  54876. */
  54877. size: number,
  54878. /**
  54879. * Defines if mipmaps should not be generated (default is false)
  54880. */
  54881. noMipmap?: boolean,
  54882. /**
  54883. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54884. */
  54885. generateHarmonics?: boolean,
  54886. /**
  54887. * 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)
  54888. */
  54889. gammaSpace?: boolean,
  54890. /**
  54891. * Internal Use Only
  54892. */
  54893. reserved?: boolean);
  54894. /**
  54895. * Execute the current task
  54896. * @param scene defines the scene where you want your assets to be loaded
  54897. * @param onSuccess is a callback called when the task is successfully executed
  54898. * @param onError is a callback called if an error occurs
  54899. */
  54900. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54901. }
  54902. /**
  54903. * This class can be used to easily import assets into a scene
  54904. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54905. */
  54906. export class AssetsManager {
  54907. private _scene;
  54908. private _isLoading;
  54909. protected _tasks: AbstractAssetTask[];
  54910. protected _waitingTasksCount: number;
  54911. protected _totalTasksCount: number;
  54912. /**
  54913. * Callback called when all tasks are processed
  54914. */
  54915. onFinish: (tasks: AbstractAssetTask[]) => void;
  54916. /**
  54917. * Callback called when a task is successful
  54918. */
  54919. onTaskSuccess: (task: AbstractAssetTask) => void;
  54920. /**
  54921. * Callback called when a task had an error
  54922. */
  54923. onTaskError: (task: AbstractAssetTask) => void;
  54924. /**
  54925. * Callback called when a task is done (whatever the result is)
  54926. */
  54927. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54928. /**
  54929. * Observable called when all tasks are processed
  54930. */
  54931. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54932. /**
  54933. * Observable called when a task had an error
  54934. */
  54935. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54936. /**
  54937. * Observable called when a task is successful
  54938. */
  54939. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54940. /**
  54941. * Observable called when a task is done (whatever the result is)
  54942. */
  54943. onProgressObservable: Observable<IAssetsProgressEvent>;
  54944. /**
  54945. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54946. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54947. */
  54948. useDefaultLoadingScreen: boolean;
  54949. /**
  54950. * Creates a new AssetsManager
  54951. * @param scene defines the scene to work on
  54952. */
  54953. constructor(scene: Scene);
  54954. /**
  54955. * Add a MeshAssetTask to the list of active tasks
  54956. * @param taskName defines the name of the new task
  54957. * @param meshesNames defines the name of meshes to load
  54958. * @param rootUrl defines the root url to use to locate files
  54959. * @param sceneFilename defines the filename of the scene file
  54960. * @returns a new MeshAssetTask object
  54961. */
  54962. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54963. /**
  54964. * Add a TextFileAssetTask to the list of active tasks
  54965. * @param taskName defines the name of the new task
  54966. * @param url defines the url of the file to load
  54967. * @returns a new TextFileAssetTask object
  54968. */
  54969. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54970. /**
  54971. * Add a BinaryFileAssetTask to the list of active tasks
  54972. * @param taskName defines the name of the new task
  54973. * @param url defines the url of the file to load
  54974. * @returns a new BinaryFileAssetTask object
  54975. */
  54976. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54977. /**
  54978. * Add a ImageAssetTask to the list of active tasks
  54979. * @param taskName defines the name of the new task
  54980. * @param url defines the url of the file to load
  54981. * @returns a new ImageAssetTask object
  54982. */
  54983. addImageTask(taskName: string, url: string): ImageAssetTask;
  54984. /**
  54985. * Add a TextureAssetTask to the list of active tasks
  54986. * @param taskName defines the name of the new task
  54987. * @param url defines the url of the file to load
  54988. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54989. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54990. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54991. * @returns a new TextureAssetTask object
  54992. */
  54993. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54994. /**
  54995. * Add a CubeTextureAssetTask to the list of active tasks
  54996. * @param taskName defines the name of the new task
  54997. * @param url defines the url of the file to load
  54998. * @param extensions defines the extension to use to load the cube map (can be null)
  54999. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55000. * @param files defines the list of files to load (can be null)
  55001. * @returns a new CubeTextureAssetTask object
  55002. */
  55003. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  55004. /**
  55005. *
  55006. * Add a HDRCubeTextureAssetTask to the list of active tasks
  55007. * @param taskName defines the name of the new task
  55008. * @param url defines the url of the file to load
  55009. * @param size defines the size you want for the cubemap (can be null)
  55010. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  55011. * @param generateHarmonics defines if you want to automatically generate (true by default)
  55012. * @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)
  55013. * @param reserved Internal use only
  55014. * @returns a new HDRCubeTextureAssetTask object
  55015. */
  55016. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  55017. /**
  55018. * Remove a task from the assets manager.
  55019. * @param task the task to remove
  55020. */
  55021. removeTask(task: AbstractAssetTask): void;
  55022. private _decreaseWaitingTasksCount;
  55023. private _runTask;
  55024. /**
  55025. * Reset the AssetsManager and remove all tasks
  55026. * @return the current instance of the AssetsManager
  55027. */
  55028. reset(): AssetsManager;
  55029. /**
  55030. * Start the loading process
  55031. * @return the current instance of the AssetsManager
  55032. */
  55033. load(): AssetsManager;
  55034. }
  55035. }
  55036. declare module "babylonjs/Misc/deferred" {
  55037. /**
  55038. * Wrapper class for promise with external resolve and reject.
  55039. */
  55040. export class Deferred<T> {
  55041. /**
  55042. * The promise associated with this deferred object.
  55043. */
  55044. readonly promise: Promise<T>;
  55045. private _resolve;
  55046. private _reject;
  55047. /**
  55048. * The resolve method of the promise associated with this deferred object.
  55049. */
  55050. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55051. /**
  55052. * The reject method of the promise associated with this deferred object.
  55053. */
  55054. readonly reject: (reason?: any) => void;
  55055. /**
  55056. * Constructor for this deferred object.
  55057. */
  55058. constructor();
  55059. }
  55060. }
  55061. declare module "babylonjs/Misc/filesInput" {
  55062. import { Engine } from "babylonjs/Engines/engine";
  55063. import { Scene } from "babylonjs/scene";
  55064. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  55065. /**
  55066. * Class used to help managing file picking and drag'n'drop
  55067. */
  55068. export class FilesInput {
  55069. /**
  55070. * List of files ready to be loaded
  55071. */
  55072. static readonly FilesToLoad: {
  55073. [key: string]: File;
  55074. };
  55075. /**
  55076. * Callback called when a file is processed
  55077. */
  55078. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55079. private _engine;
  55080. private _currentScene;
  55081. private _sceneLoadedCallback;
  55082. private _progressCallback;
  55083. private _additionalRenderLoopLogicCallback;
  55084. private _textureLoadingCallback;
  55085. private _startingProcessingFilesCallback;
  55086. private _onReloadCallback;
  55087. private _errorCallback;
  55088. private _elementToMonitor;
  55089. private _sceneFileToLoad;
  55090. private _filesToLoad;
  55091. /**
  55092. * Creates a new FilesInput
  55093. * @param engine defines the rendering engine
  55094. * @param scene defines the hosting scene
  55095. * @param sceneLoadedCallback callback called when scene is loaded
  55096. * @param progressCallback callback called to track progress
  55097. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55098. * @param textureLoadingCallback callback called when a texture is loading
  55099. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55100. * @param onReloadCallback callback called when a reload is requested
  55101. * @param errorCallback callback call if an error occurs
  55102. */
  55103. 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);
  55104. private _dragEnterHandler;
  55105. private _dragOverHandler;
  55106. private _dropHandler;
  55107. /**
  55108. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55109. * @param elementToMonitor defines the DOM element to track
  55110. */
  55111. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55112. /**
  55113. * Release all associated resources
  55114. */
  55115. dispose(): void;
  55116. private renderFunction;
  55117. private drag;
  55118. private drop;
  55119. private _traverseFolder;
  55120. private _processFiles;
  55121. /**
  55122. * Load files from a drop event
  55123. * @param event defines the drop event to use as source
  55124. */
  55125. loadFiles(event: any): void;
  55126. private _processReload;
  55127. /**
  55128. * Reload the current scene from the loaded files
  55129. */
  55130. reload(): void;
  55131. }
  55132. }
  55133. declare module "babylonjs/Misc/HighDynamicRange/index" {
  55134. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  55135. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  55136. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  55137. }
  55138. declare module "babylonjs/Misc/sceneOptimizer" {
  55139. import { Scene, IDisposable } from "babylonjs/scene";
  55140. import { Observable } from "babylonjs/Misc/observable";
  55141. /**
  55142. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55143. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55144. */
  55145. export class SceneOptimization {
  55146. /**
  55147. * Defines the priority of this optimization (0 by default which means first in the list)
  55148. */
  55149. priority: number;
  55150. /**
  55151. * Gets a string describing the action executed by the current optimization
  55152. * @returns description string
  55153. */
  55154. getDescription(): string;
  55155. /**
  55156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55157. * @param scene defines the current scene where to apply this optimization
  55158. * @param optimizer defines the current optimizer
  55159. * @returns true if everything that can be done was applied
  55160. */
  55161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55162. /**
  55163. * Creates the SceneOptimization object
  55164. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55165. * @param desc defines the description associated with the optimization
  55166. */
  55167. constructor(
  55168. /**
  55169. * Defines the priority of this optimization (0 by default which means first in the list)
  55170. */
  55171. priority?: number);
  55172. }
  55173. /**
  55174. * Defines an optimization used to reduce the size of render target textures
  55175. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55176. */
  55177. export class TextureOptimization extends SceneOptimization {
  55178. /**
  55179. * Defines the priority of this optimization (0 by default which means first in the list)
  55180. */
  55181. priority: number;
  55182. /**
  55183. * 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
  55184. */
  55185. maximumSize: number;
  55186. /**
  55187. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55188. */
  55189. step: number;
  55190. /**
  55191. * Gets a string describing the action executed by the current optimization
  55192. * @returns description string
  55193. */
  55194. getDescription(): string;
  55195. /**
  55196. * Creates the TextureOptimization object
  55197. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55198. * @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
  55199. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55200. */
  55201. constructor(
  55202. /**
  55203. * Defines the priority of this optimization (0 by default which means first in the list)
  55204. */
  55205. priority?: number,
  55206. /**
  55207. * 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
  55208. */
  55209. maximumSize?: number,
  55210. /**
  55211. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55212. */
  55213. step?: number);
  55214. /**
  55215. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55216. * @param scene defines the current scene where to apply this optimization
  55217. * @param optimizer defines the current optimizer
  55218. * @returns true if everything that can be done was applied
  55219. */
  55220. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55221. }
  55222. /**
  55223. * Defines an optimization used to increase or decrease the rendering resolution
  55224. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55225. */
  55226. export class HardwareScalingOptimization extends SceneOptimization {
  55227. /**
  55228. * Defines the priority of this optimization (0 by default which means first in the list)
  55229. */
  55230. priority: number;
  55231. /**
  55232. * Defines the maximum scale to use (2 by default)
  55233. */
  55234. maximumScale: number;
  55235. /**
  55236. * Defines the step to use between two passes (0.5 by default)
  55237. */
  55238. step: number;
  55239. private _currentScale;
  55240. private _directionOffset;
  55241. /**
  55242. * Gets a string describing the action executed by the current optimization
  55243. * @return description string
  55244. */
  55245. getDescription(): string;
  55246. /**
  55247. * Creates the HardwareScalingOptimization object
  55248. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55249. * @param maximumScale defines the maximum scale to use (2 by default)
  55250. * @param step defines the step to use between two passes (0.5 by default)
  55251. */
  55252. constructor(
  55253. /**
  55254. * Defines the priority of this optimization (0 by default which means first in the list)
  55255. */
  55256. priority?: number,
  55257. /**
  55258. * Defines the maximum scale to use (2 by default)
  55259. */
  55260. maximumScale?: number,
  55261. /**
  55262. * Defines the step to use between two passes (0.5 by default)
  55263. */
  55264. step?: number);
  55265. /**
  55266. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55267. * @param scene defines the current scene where to apply this optimization
  55268. * @param optimizer defines the current optimizer
  55269. * @returns true if everything that can be done was applied
  55270. */
  55271. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55272. }
  55273. /**
  55274. * Defines an optimization used to remove shadows
  55275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55276. */
  55277. export class ShadowsOptimization extends SceneOptimization {
  55278. /**
  55279. * Gets a string describing the action executed by the current optimization
  55280. * @return description string
  55281. */
  55282. getDescription(): string;
  55283. /**
  55284. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55285. * @param scene defines the current scene where to apply this optimization
  55286. * @param optimizer defines the current optimizer
  55287. * @returns true if everything that can be done was applied
  55288. */
  55289. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55290. }
  55291. /**
  55292. * Defines an optimization used to turn post-processes off
  55293. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55294. */
  55295. export class PostProcessesOptimization extends SceneOptimization {
  55296. /**
  55297. * Gets a string describing the action executed by the current optimization
  55298. * @return description string
  55299. */
  55300. getDescription(): string;
  55301. /**
  55302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55303. * @param scene defines the current scene where to apply this optimization
  55304. * @param optimizer defines the current optimizer
  55305. * @returns true if everything that can be done was applied
  55306. */
  55307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55308. }
  55309. /**
  55310. * Defines an optimization used to turn lens flares off
  55311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55312. */
  55313. export class LensFlaresOptimization extends SceneOptimization {
  55314. /**
  55315. * Gets a string describing the action executed by the current optimization
  55316. * @return description string
  55317. */
  55318. getDescription(): string;
  55319. /**
  55320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55321. * @param scene defines the current scene where to apply this optimization
  55322. * @param optimizer defines the current optimizer
  55323. * @returns true if everything that can be done was applied
  55324. */
  55325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55326. }
  55327. /**
  55328. * Defines an optimization based on user defined callback.
  55329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55330. */
  55331. export class CustomOptimization extends SceneOptimization {
  55332. /**
  55333. * Callback called to apply the custom optimization.
  55334. */
  55335. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55336. /**
  55337. * Callback called to get custom description
  55338. */
  55339. onGetDescription: () => string;
  55340. /**
  55341. * Gets a string describing the action executed by the current optimization
  55342. * @returns description string
  55343. */
  55344. getDescription(): string;
  55345. /**
  55346. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55347. * @param scene defines the current scene where to apply this optimization
  55348. * @param optimizer defines the current optimizer
  55349. * @returns true if everything that can be done was applied
  55350. */
  55351. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55352. }
  55353. /**
  55354. * Defines an optimization used to turn particles off
  55355. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55356. */
  55357. export class ParticlesOptimization extends SceneOptimization {
  55358. /**
  55359. * Gets a string describing the action executed by the current optimization
  55360. * @return description string
  55361. */
  55362. getDescription(): string;
  55363. /**
  55364. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55365. * @param scene defines the current scene where to apply this optimization
  55366. * @param optimizer defines the current optimizer
  55367. * @returns true if everything that can be done was applied
  55368. */
  55369. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55370. }
  55371. /**
  55372. * Defines an optimization used to turn render targets off
  55373. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55374. */
  55375. export class RenderTargetsOptimization extends SceneOptimization {
  55376. /**
  55377. * Gets a string describing the action executed by the current optimization
  55378. * @return description string
  55379. */
  55380. getDescription(): string;
  55381. /**
  55382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55383. * @param scene defines the current scene where to apply this optimization
  55384. * @param optimizer defines the current optimizer
  55385. * @returns true if everything that can be done was applied
  55386. */
  55387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55388. }
  55389. /**
  55390. * Defines an optimization used to merge meshes with compatible materials
  55391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55392. */
  55393. export class MergeMeshesOptimization extends SceneOptimization {
  55394. private static _UpdateSelectionTree;
  55395. /**
  55396. * Gets or sets a boolean which defines if optimization octree has to be updated
  55397. */
  55398. /**
  55399. * Gets or sets a boolean which defines if optimization octree has to be updated
  55400. */
  55401. static UpdateSelectionTree: boolean;
  55402. /**
  55403. * Gets a string describing the action executed by the current optimization
  55404. * @return description string
  55405. */
  55406. getDescription(): string;
  55407. private _canBeMerged;
  55408. /**
  55409. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55410. * @param scene defines the current scene where to apply this optimization
  55411. * @param optimizer defines the current optimizer
  55412. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55413. * @returns true if everything that can be done was applied
  55414. */
  55415. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55416. }
  55417. /**
  55418. * Defines a list of options used by SceneOptimizer
  55419. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55420. */
  55421. export class SceneOptimizerOptions {
  55422. /**
  55423. * Defines the target frame rate to reach (60 by default)
  55424. */
  55425. targetFrameRate: number;
  55426. /**
  55427. * Defines the interval between two checkes (2000ms by default)
  55428. */
  55429. trackerDuration: number;
  55430. /**
  55431. * Gets the list of optimizations to apply
  55432. */
  55433. optimizations: SceneOptimization[];
  55434. /**
  55435. * Creates a new list of options used by SceneOptimizer
  55436. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55437. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55438. */
  55439. constructor(
  55440. /**
  55441. * Defines the target frame rate to reach (60 by default)
  55442. */
  55443. targetFrameRate?: number,
  55444. /**
  55445. * Defines the interval between two checkes (2000ms by default)
  55446. */
  55447. trackerDuration?: number);
  55448. /**
  55449. * Add a new optimization
  55450. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55451. * @returns the current SceneOptimizerOptions
  55452. */
  55453. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55454. /**
  55455. * Add a new custom optimization
  55456. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55457. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55458. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55459. * @returns the current SceneOptimizerOptions
  55460. */
  55461. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55462. /**
  55463. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55464. * @param targetFrameRate defines the target frame rate (60 by default)
  55465. * @returns a SceneOptimizerOptions object
  55466. */
  55467. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55468. /**
  55469. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55470. * @param targetFrameRate defines the target frame rate (60 by default)
  55471. * @returns a SceneOptimizerOptions object
  55472. */
  55473. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55474. /**
  55475. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55476. * @param targetFrameRate defines the target frame rate (60 by default)
  55477. * @returns a SceneOptimizerOptions object
  55478. */
  55479. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55480. }
  55481. /**
  55482. * Class used to run optimizations in order to reach a target frame rate
  55483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55484. */
  55485. export class SceneOptimizer implements IDisposable {
  55486. private _isRunning;
  55487. private _options;
  55488. private _scene;
  55489. private _currentPriorityLevel;
  55490. private _targetFrameRate;
  55491. private _trackerDuration;
  55492. private _currentFrameRate;
  55493. private _sceneDisposeObserver;
  55494. private _improvementMode;
  55495. /**
  55496. * Defines an observable called when the optimizer reaches the target frame rate
  55497. */
  55498. onSuccessObservable: Observable<SceneOptimizer>;
  55499. /**
  55500. * Defines an observable called when the optimizer enables an optimization
  55501. */
  55502. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55503. /**
  55504. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55505. */
  55506. onFailureObservable: Observable<SceneOptimizer>;
  55507. /**
  55508. * Gets a boolean indicating if the optimizer is in improvement mode
  55509. */
  55510. readonly isInImprovementMode: boolean;
  55511. /**
  55512. * Gets the current priority level (0 at start)
  55513. */
  55514. readonly currentPriorityLevel: number;
  55515. /**
  55516. * Gets the current frame rate checked by the SceneOptimizer
  55517. */
  55518. readonly currentFrameRate: number;
  55519. /**
  55520. * Gets or sets the current target frame rate (60 by default)
  55521. */
  55522. /**
  55523. * Gets or sets the current target frame rate (60 by default)
  55524. */
  55525. targetFrameRate: number;
  55526. /**
  55527. * Gets or sets the current interval between two checks (every 2000ms by default)
  55528. */
  55529. /**
  55530. * Gets or sets the current interval between two checks (every 2000ms by default)
  55531. */
  55532. trackerDuration: number;
  55533. /**
  55534. * Gets the list of active optimizations
  55535. */
  55536. readonly optimizations: SceneOptimization[];
  55537. /**
  55538. * Creates a new SceneOptimizer
  55539. * @param scene defines the scene to work on
  55540. * @param options defines the options to use with the SceneOptimizer
  55541. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55542. * @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)
  55543. */
  55544. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55545. /**
  55546. * Stops the current optimizer
  55547. */
  55548. stop(): void;
  55549. /**
  55550. * Reset the optimizer to initial step (current priority level = 0)
  55551. */
  55552. reset(): void;
  55553. /**
  55554. * Start the optimizer. By default it will try to reach a specific framerate
  55555. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55556. */
  55557. start(): void;
  55558. private _checkCurrentState;
  55559. /**
  55560. * Release all resources
  55561. */
  55562. dispose(): void;
  55563. /**
  55564. * Helper function to create a SceneOptimizer with one single line of code
  55565. * @param scene defines the scene to work on
  55566. * @param options defines the options to use with the SceneOptimizer
  55567. * @param onSuccess defines a callback to call on success
  55568. * @param onFailure defines a callback to call on failure
  55569. * @returns the new SceneOptimizer object
  55570. */
  55571. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55572. }
  55573. }
  55574. declare module "babylonjs/Misc/sceneSerializer" {
  55575. import { Scene } from "babylonjs/scene";
  55576. /**
  55577. * Class used to serialize a scene into a string
  55578. */
  55579. export class SceneSerializer {
  55580. /**
  55581. * Clear cache used by a previous serialization
  55582. */
  55583. static ClearCache(): void;
  55584. /**
  55585. * Serialize a scene into a JSON compatible object
  55586. * @param scene defines the scene to serialize
  55587. * @returns a JSON compatible object
  55588. */
  55589. static Serialize(scene: Scene): any;
  55590. /**
  55591. * Serialize a mesh into a JSON compatible object
  55592. * @param toSerialize defines the mesh to serialize
  55593. * @param withParents defines if parents must be serialized as well
  55594. * @param withChildren defines if children must be serialized as well
  55595. * @returns a JSON compatible object
  55596. */
  55597. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55598. }
  55599. }
  55600. declare module "babylonjs/Misc/videoRecorder" {
  55601. import { Nullable } from "babylonjs/types";
  55602. import { Engine } from "babylonjs/Engines/engine";
  55603. /**
  55604. * This represents the different options avilable for the video capture.
  55605. */
  55606. export interface VideoRecorderOptions {
  55607. /** Defines the mime type of the video */
  55608. mimeType: string;
  55609. /** Defines the video the video should be recorded at */
  55610. fps: number;
  55611. /** Defines the chunk size for the recording data */
  55612. recordChunckSize: number;
  55613. }
  55614. /**
  55615. * This can helps recording videos from BabylonJS.
  55616. * This is based on the available WebRTC functionalities of the browser.
  55617. *
  55618. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55619. */
  55620. export class VideoRecorder {
  55621. private static readonly _defaultOptions;
  55622. /**
  55623. * Returns wehther or not the VideoRecorder is available in your browser.
  55624. * @param engine Defines the Babylon Engine to check the support for
  55625. * @returns true if supported otherwise false
  55626. */
  55627. static IsSupported(engine: Engine): boolean;
  55628. private readonly _options;
  55629. private _canvas;
  55630. private _mediaRecorder;
  55631. private _recordedChunks;
  55632. private _fileName;
  55633. private _resolve;
  55634. private _reject;
  55635. /**
  55636. * True wether a recording is already in progress.
  55637. */
  55638. readonly isRecording: boolean;
  55639. /**
  55640. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55641. * a video file.
  55642. * @param engine Defines the BabylonJS Engine you wish to record
  55643. * @param options Defines options that can be used to customized the capture
  55644. */
  55645. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55646. /**
  55647. * Stops the current recording before the default capture timeout passed in the startRecording
  55648. * functions.
  55649. */
  55650. stopRecording(): void;
  55651. /**
  55652. * Starts recording the canvas for a max duration specified in parameters.
  55653. * @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.
  55654. * @param maxDuration Defines the maximum recording time in seconds.
  55655. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55656. * @return a promise callback at the end of the recording with the video data in Blob.
  55657. */
  55658. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55659. /**
  55660. * Releases internal resources used during the recording.
  55661. */
  55662. dispose(): void;
  55663. private _handleDataAvailable;
  55664. private _handleError;
  55665. private _handleStop;
  55666. }
  55667. }
  55668. declare module "babylonjs/Misc/workerPool" {
  55669. import { IDisposable } from "babylonjs/scene";
  55670. /**
  55671. * Helper class to push actions to a pool of workers.
  55672. */
  55673. export class WorkerPool implements IDisposable {
  55674. private _workerInfos;
  55675. private _pendingActions;
  55676. /**
  55677. * Constructor
  55678. * @param workers Array of workers to use for actions
  55679. */
  55680. constructor(workers: Array<Worker>);
  55681. /**
  55682. * Terminates all workers and clears any pending actions.
  55683. */
  55684. dispose(): void;
  55685. /**
  55686. * Pushes an action to the worker pool. If all the workers are active, the action will be
  55687. * pended until a worker has completed its action.
  55688. * @param action The action to perform. Call onComplete when the action is complete.
  55689. */
  55690. push(action: (worker: Worker, onComplete: () => void) => void): void;
  55691. private _execute;
  55692. }
  55693. }
  55694. declare module "babylonjs/Misc/screenshotTools" {
  55695. import { Camera } from "babylonjs/Cameras/camera";
  55696. import { Engine } from "babylonjs/Engines/engine";
  55697. /**
  55698. * Class containing a set of static utilities functions for screenshots
  55699. */
  55700. export class ScreenshotTools {
  55701. /**
  55702. * Captures a screenshot of the current rendering
  55703. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55704. * @param engine defines the rendering engine
  55705. * @param camera defines the source camera
  55706. * @param size This parameter can be set to a single number or to an object with the
  55707. * following (optional) properties: precision, width, height. If a single number is passed,
  55708. * it will be used for both width and height. If an object is passed, the screenshot size
  55709. * will be derived from the parameters. The precision property is a multiplier allowing
  55710. * rendering at a higher or lower resolution
  55711. * @param successCallback defines the callback receives a single parameter which contains the
  55712. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55713. * src parameter of an <img> to display it
  55714. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55715. * Check your browser for supported MIME types
  55716. */
  55717. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55718. /**
  55719. * Generates an image screenshot from the specified camera.
  55720. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55721. * @param engine The engine to use for rendering
  55722. * @param camera The camera to use for rendering
  55723. * @param size This parameter can be set to a single number or to an object with the
  55724. * following (optional) properties: precision, width, height. If a single number is passed,
  55725. * it will be used for both width and height. If an object is passed, the screenshot size
  55726. * will be derived from the parameters. The precision property is a multiplier allowing
  55727. * rendering at a higher or lower resolution
  55728. * @param successCallback The callback receives a single parameter which contains the
  55729. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55730. * src parameter of an <img> to display it
  55731. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55732. * Check your browser for supported MIME types
  55733. * @param samples Texture samples (default: 1)
  55734. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55735. * @param fileName A name for for the downloaded file.
  55736. */
  55737. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55738. }
  55739. }
  55740. declare module "babylonjs/Misc/index" {
  55741. export * from "babylonjs/Misc/andOrNotEvaluator";
  55742. export * from "babylonjs/Misc/assetsManager";
  55743. export * from "babylonjs/Misc/dds";
  55744. export * from "babylonjs/Misc/decorators";
  55745. export * from "babylonjs/Misc/deferred";
  55746. export * from "babylonjs/Misc/environmentTextureTools";
  55747. export * from "babylonjs/Misc/filesInput";
  55748. export * from "babylonjs/Misc/HighDynamicRange/index";
  55749. export * from "babylonjs/Misc/khronosTextureContainer";
  55750. export * from "babylonjs/Misc/observable";
  55751. export * from "babylonjs/Misc/performanceMonitor";
  55752. export * from "babylonjs/Misc/promise";
  55753. export * from "babylonjs/Misc/sceneOptimizer";
  55754. export * from "babylonjs/Misc/sceneSerializer";
  55755. export * from "babylonjs/Misc/smartArray";
  55756. export * from "babylonjs/Misc/stringDictionary";
  55757. export * from "babylonjs/Misc/tags";
  55758. export * from "babylonjs/Misc/textureTools";
  55759. export * from "babylonjs/Misc/tga";
  55760. export * from "babylonjs/Misc/tools";
  55761. export * from "babylonjs/Misc/videoRecorder";
  55762. export * from "babylonjs/Misc/virtualJoystick";
  55763. export * from "babylonjs/Misc/workerPool";
  55764. export * from "babylonjs/Misc/logger";
  55765. export * from "babylonjs/Misc/typeStore";
  55766. export * from "babylonjs/Misc/filesInputStore";
  55767. export * from "babylonjs/Misc/deepCopier";
  55768. export * from "babylonjs/Misc/pivotTools";
  55769. export * from "babylonjs/Misc/precisionDate";
  55770. export * from "babylonjs/Misc/screenshotTools";
  55771. export * from "babylonjs/Misc/typeStore";
  55772. }
  55773. declare module "babylonjs/index" {
  55774. export * from "babylonjs/abstractScene";
  55775. export * from "babylonjs/Actions/index";
  55776. export * from "babylonjs/Animations/index";
  55777. export * from "babylonjs/assetContainer";
  55778. export * from "babylonjs/Audio/index";
  55779. export * from "babylonjs/Behaviors/index";
  55780. export * from "babylonjs/Bones/index";
  55781. export * from "babylonjs/Cameras/index";
  55782. export * from "babylonjs/Collisions/index";
  55783. export * from "babylonjs/Culling/index";
  55784. export * from "babylonjs/Debug/index";
  55785. export * from "babylonjs/Engines/index";
  55786. export * from "babylonjs/Events/index";
  55787. export * from "babylonjs/Gamepads/index";
  55788. export * from "babylonjs/Gizmos/index";
  55789. export * from "babylonjs/Helpers/index";
  55790. export * from "babylonjs/Instrumentation/index";
  55791. export * from "babylonjs/Layers/index";
  55792. export * from "babylonjs/LensFlares/index";
  55793. export * from "babylonjs/Lights/index";
  55794. export * from "babylonjs/Loading/index";
  55795. export * from "babylonjs/Materials/index";
  55796. export * from "babylonjs/Maths/index";
  55797. export * from "babylonjs/Meshes/index";
  55798. export * from "babylonjs/Morph/index";
  55799. export * from "babylonjs/node";
  55800. export * from "babylonjs/Offline/index";
  55801. export * from "babylonjs/Particles/index";
  55802. export * from "babylonjs/Physics/index";
  55803. export * from "babylonjs/PostProcesses/index";
  55804. export * from "babylonjs/Probes/index";
  55805. export * from "babylonjs/Rendering/index";
  55806. export * from "babylonjs/scene";
  55807. export * from "babylonjs/sceneComponent";
  55808. export * from "babylonjs/Sprites/index";
  55809. export * from "babylonjs/States/index";
  55810. export * from "babylonjs/Misc/index";
  55811. export * from "babylonjs/types";
  55812. }
  55813. declare module "babylonjs/Animations/pathCursor" {
  55814. import { Path2, Vector3 } from "babylonjs/Maths/math";
  55815. /**
  55816. * A cursor which tracks a point on a path
  55817. */
  55818. export class PathCursor {
  55819. private path;
  55820. /**
  55821. * Stores path cursor callbacks for when an onchange event is triggered
  55822. */
  55823. private _onchange;
  55824. /**
  55825. * The value of the path cursor
  55826. */
  55827. value: number;
  55828. /**
  55829. * The animation array of the path cursor
  55830. */
  55831. animations: Animation[];
  55832. /**
  55833. * Initializes the path cursor
  55834. * @param path The path to track
  55835. */
  55836. constructor(path: Path2);
  55837. /**
  55838. * Gets the cursor point on the path
  55839. * @returns A point on the path cursor at the cursor location
  55840. */
  55841. getPoint(): Vector3;
  55842. /**
  55843. * Moves the cursor ahead by the step amount
  55844. * @param step The amount to move the cursor forward
  55845. * @returns This path cursor
  55846. */
  55847. moveAhead(step?: number): PathCursor;
  55848. /**
  55849. * Moves the cursor behind by the step amount
  55850. * @param step The amount to move the cursor back
  55851. * @returns This path cursor
  55852. */
  55853. moveBack(step?: number): PathCursor;
  55854. /**
  55855. * Moves the cursor by the step amount
  55856. * If the step amount is greater than one, an exception is thrown
  55857. * @param step The amount to move the cursor
  55858. * @returns This path cursor
  55859. */
  55860. move(step: number): PathCursor;
  55861. /**
  55862. * Ensures that the value is limited between zero and one
  55863. * @returns This path cursor
  55864. */
  55865. private ensureLimits;
  55866. /**
  55867. * Runs onchange callbacks on change (used by the animation engine)
  55868. * @returns This path cursor
  55869. */
  55870. private raiseOnChange;
  55871. /**
  55872. * Executes a function on change
  55873. * @param f A path cursor onchange callback
  55874. * @returns This path cursor
  55875. */
  55876. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55877. }
  55878. }
  55879. declare module "babylonjs/Legacy/legacy" {
  55880. export * from "babylonjs/index";
  55881. }
  55882. declare module "babylonjs/Shaders/blur.fragment" {
  55883. /** @hidden */
  55884. export var blurPixelShader: {
  55885. name: string;
  55886. shader: string;
  55887. };
  55888. }
  55889. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  55890. /** @hidden */
  55891. export var bones300Declaration: {
  55892. name: string;
  55893. shader: string;
  55894. };
  55895. }
  55896. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  55897. /** @hidden */
  55898. export var instances300Declaration: {
  55899. name: string;
  55900. shader: string;
  55901. };
  55902. }
  55903. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  55904. /** @hidden */
  55905. export var pointCloudVertexDeclaration: {
  55906. name: string;
  55907. shader: string;
  55908. };
  55909. }
  55910. // Mixins
  55911. interface Window {
  55912. mozIndexedDB: IDBFactory;
  55913. webkitIndexedDB: IDBFactory;
  55914. msIndexedDB: IDBFactory;
  55915. webkitURL: typeof URL;
  55916. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55917. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55918. WebGLRenderingContext: WebGLRenderingContext;
  55919. MSGesture: MSGesture;
  55920. CANNON: any;
  55921. AudioContext: AudioContext;
  55922. webkitAudioContext: AudioContext;
  55923. PointerEvent: any;
  55924. Math: Math;
  55925. Uint8Array: Uint8ArrayConstructor;
  55926. Float32Array: Float32ArrayConstructor;
  55927. mozURL: typeof URL;
  55928. msURL: typeof URL;
  55929. VRFrameData: any; // WebVR, from specs 1.1
  55930. DracoDecoderModule: any;
  55931. setImmediate(handler: (...args: any[]) => void): number;
  55932. }
  55933. interface Document {
  55934. mozCancelFullScreen(): void;
  55935. msCancelFullScreen(): void;
  55936. webkitCancelFullScreen(): void;
  55937. requestPointerLock(): void;
  55938. exitPointerLock(): void;
  55939. mozFullScreen: boolean;
  55940. msIsFullScreen: boolean;
  55941. readonly webkitIsFullScreen: boolean;
  55942. readonly pointerLockElement: Element;
  55943. mozPointerLockElement: HTMLElement;
  55944. msPointerLockElement: HTMLElement;
  55945. webkitPointerLockElement: HTMLElement;
  55946. }
  55947. interface HTMLCanvasElement {
  55948. requestPointerLock(): void;
  55949. msRequestPointerLock?(): void;
  55950. mozRequestPointerLock?(): void;
  55951. webkitRequestPointerLock?(): void;
  55952. /** Track wether a record is in progress */
  55953. isRecording: boolean;
  55954. /** Capture Stream method defined by some browsers */
  55955. captureStream(fps?: number): MediaStream;
  55956. }
  55957. interface CanvasRenderingContext2D {
  55958. msImageSmoothingEnabled: boolean;
  55959. }
  55960. interface MouseEvent {
  55961. mozMovementX: number;
  55962. mozMovementY: number;
  55963. webkitMovementX: number;
  55964. webkitMovementY: number;
  55965. msMovementX: number;
  55966. msMovementY: number;
  55967. }
  55968. interface Navigator {
  55969. mozGetVRDevices: (any: any) => any;
  55970. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55971. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55972. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55973. webkitGetGamepads(): Gamepad[];
  55974. msGetGamepads(): Gamepad[];
  55975. webkitGamepads(): Gamepad[];
  55976. }
  55977. interface HTMLVideoElement {
  55978. mozSrcObject: any;
  55979. }
  55980. interface Math {
  55981. fround(x: number): number;
  55982. imul(a: number, b: number): number;
  55983. }
  55984. interface WebGLProgram {
  55985. context?: WebGLRenderingContext;
  55986. vertexShader?: WebGLShader;
  55987. fragmentShader?: WebGLShader;
  55988. isParallelCompiled: boolean;
  55989. onCompiled?: () => void;
  55990. }
  55991. interface WebGLRenderingContext {
  55992. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55993. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55994. vertexAttribDivisor(index: number, divisor: number): void;
  55995. createVertexArray(): any;
  55996. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55997. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55998. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55999. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56000. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  56001. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  56002. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  56003. // Queries
  56004. createQuery(): WebGLQuery;
  56005. deleteQuery(query: WebGLQuery): void;
  56006. beginQuery(target: number, query: WebGLQuery): void;
  56007. endQuery(target: number): void;
  56008. getQueryParameter(query: WebGLQuery, pname: number): any;
  56009. getQuery(target: number, pname: number): any;
  56010. MAX_SAMPLES: number;
  56011. RGBA8: number;
  56012. READ_FRAMEBUFFER: number;
  56013. DRAW_FRAMEBUFFER: number;
  56014. UNIFORM_BUFFER: number;
  56015. HALF_FLOAT_OES: number;
  56016. RGBA16F: number;
  56017. RGBA32F: number;
  56018. R32F: number;
  56019. RG32F: number;
  56020. RGB32F: number;
  56021. R16F: number;
  56022. RG16F: number;
  56023. RGB16F: number;
  56024. RED: number;
  56025. RG: number;
  56026. R8: number;
  56027. RG8: number;
  56028. UNSIGNED_INT_24_8: number;
  56029. DEPTH24_STENCIL8: number;
  56030. /* Multiple Render Targets */
  56031. drawBuffers(buffers: number[]): void;
  56032. readBuffer(src: number): void;
  56033. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  56034. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  56035. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  56036. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  56037. // Occlusion Query
  56038. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  56039. ANY_SAMPLES_PASSED: number;
  56040. QUERY_RESULT_AVAILABLE: number;
  56041. QUERY_RESULT: number;
  56042. }
  56043. interface WebGLBuffer {
  56044. references: number;
  56045. capacity: number;
  56046. is32Bits: boolean;
  56047. }
  56048. interface WebGLProgram {
  56049. transformFeedback?: WebGLTransformFeedback | null;
  56050. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  56051. }
  56052. interface EXT_disjoint_timer_query {
  56053. QUERY_COUNTER_BITS_EXT: number;
  56054. TIME_ELAPSED_EXT: number;
  56055. TIMESTAMP_EXT: number;
  56056. GPU_DISJOINT_EXT: number;
  56057. QUERY_RESULT_EXT: number;
  56058. QUERY_RESULT_AVAILABLE_EXT: number;
  56059. queryCounterEXT(query: WebGLQuery, target: number): void;
  56060. createQueryEXT(): WebGLQuery;
  56061. beginQueryEXT(target: number, query: WebGLQuery): void;
  56062. endQueryEXT(target: number): void;
  56063. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  56064. deleteQueryEXT(query: WebGLQuery): void;
  56065. }
  56066. interface WebGLUniformLocation {
  56067. _currentState: any;
  56068. }
  56069. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  56070. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  56071. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  56072. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56073. interface WebGLRenderingContext {
  56074. readonly RASTERIZER_DISCARD: number;
  56075. readonly DEPTH_COMPONENT24: number;
  56076. readonly TEXTURE_3D: number;
  56077. readonly TEXTURE_2D_ARRAY: number;
  56078. readonly TEXTURE_COMPARE_FUNC: number;
  56079. readonly TEXTURE_COMPARE_MODE: number;
  56080. readonly COMPARE_REF_TO_TEXTURE: number;
  56081. readonly TEXTURE_WRAP_R: number;
  56082. readonly HALF_FLOAT: number;
  56083. readonly RGB8: number;
  56084. readonly RED_INTEGER: number;
  56085. readonly RG_INTEGER: number;
  56086. readonly RGB_INTEGER: number;
  56087. readonly RGBA_INTEGER: number;
  56088. readonly R8_SNORM: number;
  56089. readonly RG8_SNORM: number;
  56090. readonly RGB8_SNORM: number;
  56091. readonly RGBA8_SNORM: number;
  56092. readonly R8I: number;
  56093. readonly RG8I: number;
  56094. readonly RGB8I: number;
  56095. readonly RGBA8I: number;
  56096. readonly R8UI: number;
  56097. readonly RG8UI: number;
  56098. readonly RGB8UI: number;
  56099. readonly RGBA8UI: number;
  56100. readonly R16I: number;
  56101. readonly RG16I: number;
  56102. readonly RGB16I: number;
  56103. readonly RGBA16I: number;
  56104. readonly R16UI: number;
  56105. readonly RG16UI: number;
  56106. readonly RGB16UI: number;
  56107. readonly RGBA16UI: number;
  56108. readonly R32I: number;
  56109. readonly RG32I: number;
  56110. readonly RGB32I: number;
  56111. readonly RGBA32I: number;
  56112. readonly R32UI: number;
  56113. readonly RG32UI: number;
  56114. readonly RGB32UI: number;
  56115. readonly RGBA32UI: number;
  56116. readonly RGB10_A2UI: number;
  56117. readonly R11F_G11F_B10F: number;
  56118. readonly RGB9_E5: number;
  56119. readonly RGB10_A2: number;
  56120. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56121. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56122. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56123. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56124. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56125. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56126. 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;
  56127. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56128. readonly TRANSFORM_FEEDBACK: number;
  56129. readonly INTERLEAVED_ATTRIBS: number;
  56130. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56131. createTransformFeedback(): WebGLTransformFeedback;
  56132. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56133. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56134. beginTransformFeedback(primitiveMode: number): void;
  56135. endTransformFeedback(): void;
  56136. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56137. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56138. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56139. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56140. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56141. }
  56142. interface ImageBitmap {
  56143. readonly width: number;
  56144. readonly height: number;
  56145. close(): void;
  56146. }
  56147. interface WebGLQuery extends WebGLObject {
  56148. }
  56149. declare var WebGLQuery: {
  56150. prototype: WebGLQuery;
  56151. new(): WebGLQuery;
  56152. };
  56153. interface WebGLSampler extends WebGLObject {
  56154. }
  56155. declare var WebGLSampler: {
  56156. prototype: WebGLSampler;
  56157. new(): WebGLSampler;
  56158. };
  56159. interface WebGLSync extends WebGLObject {
  56160. }
  56161. declare var WebGLSync: {
  56162. prototype: WebGLSync;
  56163. new(): WebGLSync;
  56164. };
  56165. interface WebGLTransformFeedback extends WebGLObject {
  56166. }
  56167. declare var WebGLTransformFeedback: {
  56168. prototype: WebGLTransformFeedback;
  56169. new(): WebGLTransformFeedback;
  56170. };
  56171. interface WebGLVertexArrayObject extends WebGLObject {
  56172. }
  56173. declare var WebGLVertexArrayObject: {
  56174. prototype: WebGLVertexArrayObject;
  56175. new(): WebGLVertexArrayObject;
  56176. };
  56177. // Type definitions for WebVR API
  56178. // Project: https://w3c.github.io/webvr/
  56179. // Definitions by: six a <https://github.com/lostfictions>
  56180. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56181. interface VRDisplay extends EventTarget {
  56182. /**
  56183. * Dictionary of capabilities describing the VRDisplay.
  56184. */
  56185. readonly capabilities: VRDisplayCapabilities;
  56186. /**
  56187. * z-depth defining the far plane of the eye view frustum
  56188. * enables mapping of values in the render target depth
  56189. * attachment to scene coordinates. Initially set to 10000.0.
  56190. */
  56191. depthFar: number;
  56192. /**
  56193. * z-depth defining the near plane of the eye view frustum
  56194. * enables mapping of values in the render target depth
  56195. * attachment to scene coordinates. Initially set to 0.01.
  56196. */
  56197. depthNear: number;
  56198. /**
  56199. * An identifier for this distinct VRDisplay. Used as an
  56200. * association point in the Gamepad API.
  56201. */
  56202. readonly displayId: number;
  56203. /**
  56204. * A display name, a user-readable name identifying it.
  56205. */
  56206. readonly displayName: string;
  56207. readonly isConnected: boolean;
  56208. readonly isPresenting: boolean;
  56209. /**
  56210. * If this VRDisplay supports room-scale experiences, the optional
  56211. * stage attribute contains details on the room-scale parameters.
  56212. */
  56213. readonly stageParameters: VRStageParameters | null;
  56214. /**
  56215. * Passing the value returned by `requestAnimationFrame` to
  56216. * `cancelAnimationFrame` will unregister the callback.
  56217. * @param handle Define the hanle of the request to cancel
  56218. */
  56219. cancelAnimationFrame(handle: number): void;
  56220. /**
  56221. * Stops presenting to the VRDisplay.
  56222. * @returns a promise to know when it stopped
  56223. */
  56224. exitPresent(): Promise<void>;
  56225. /**
  56226. * Return the current VREyeParameters for the given eye.
  56227. * @param whichEye Define the eye we want the parameter for
  56228. * @returns the eye parameters
  56229. */
  56230. getEyeParameters(whichEye: string): VREyeParameters;
  56231. /**
  56232. * Populates the passed VRFrameData with the information required to render
  56233. * the current frame.
  56234. * @param frameData Define the data structure to populate
  56235. * @returns true if ok otherwise false
  56236. */
  56237. getFrameData(frameData: VRFrameData): boolean;
  56238. /**
  56239. * Get the layers currently being presented.
  56240. * @returns the list of VR layers
  56241. */
  56242. getLayers(): VRLayer[];
  56243. /**
  56244. * Return a VRPose containing the future predicted pose of the VRDisplay
  56245. * when the current frame will be presented. The value returned will not
  56246. * change until JavaScript has returned control to the browser.
  56247. *
  56248. * The VRPose will contain the position, orientation, velocity,
  56249. * and acceleration of each of these properties.
  56250. * @returns the pose object
  56251. */
  56252. getPose(): VRPose;
  56253. /**
  56254. * Return the current instantaneous pose of the VRDisplay, with no
  56255. * prediction applied.
  56256. * @returns the current instantaneous pose
  56257. */
  56258. getImmediatePose(): VRPose;
  56259. /**
  56260. * The callback passed to `requestAnimationFrame` will be called
  56261. * any time a new frame should be rendered. When the VRDisplay is
  56262. * presenting the callback will be called at the native refresh
  56263. * rate of the HMD. When not presenting this function acts
  56264. * identically to how window.requestAnimationFrame acts. Content should
  56265. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56266. * asynchronously from other displays and at differing refresh rates.
  56267. * @param callback Define the eaction to run next frame
  56268. * @returns the request handle it
  56269. */
  56270. requestAnimationFrame(callback: FrameRequestCallback): number;
  56271. /**
  56272. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56273. * Repeat calls while already presenting will update the VRLayers being displayed.
  56274. * @param layers Define the list of layer to present
  56275. * @returns a promise to know when the request has been fulfilled
  56276. */
  56277. requestPresent(layers: VRLayer[]): Promise<void>;
  56278. /**
  56279. * Reset the pose for this display, treating its current position and
  56280. * orientation as the "origin/zero" values. VRPose.position,
  56281. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56282. * updated when calling resetPose(). This should be called in only
  56283. * sitting-space experiences.
  56284. */
  56285. resetPose(): void;
  56286. /**
  56287. * The VRLayer provided to the VRDisplay will be captured and presented
  56288. * in the HMD. Calling this function has the same effect on the source
  56289. * canvas as any other operation that uses its source image, and canvases
  56290. * created without preserveDrawingBuffer set to true will be cleared.
  56291. * @param pose Define the pose to submit
  56292. */
  56293. submitFrame(pose?: VRPose): void;
  56294. }
  56295. declare var VRDisplay: {
  56296. prototype: VRDisplay;
  56297. new(): VRDisplay;
  56298. };
  56299. interface VRLayer {
  56300. leftBounds?: number[] | Float32Array | null;
  56301. rightBounds?: number[] | Float32Array | null;
  56302. source?: HTMLCanvasElement | null;
  56303. }
  56304. interface VRDisplayCapabilities {
  56305. readonly canPresent: boolean;
  56306. readonly hasExternalDisplay: boolean;
  56307. readonly hasOrientation: boolean;
  56308. readonly hasPosition: boolean;
  56309. readonly maxLayers: number;
  56310. }
  56311. interface VREyeParameters {
  56312. /** @deprecated */
  56313. readonly fieldOfView: VRFieldOfView;
  56314. readonly offset: Float32Array;
  56315. readonly renderHeight: number;
  56316. readonly renderWidth: number;
  56317. }
  56318. interface VRFieldOfView {
  56319. readonly downDegrees: number;
  56320. readonly leftDegrees: number;
  56321. readonly rightDegrees: number;
  56322. readonly upDegrees: number;
  56323. }
  56324. interface VRFrameData {
  56325. readonly leftProjectionMatrix: Float32Array;
  56326. readonly leftViewMatrix: Float32Array;
  56327. readonly pose: VRPose;
  56328. readonly rightProjectionMatrix: Float32Array;
  56329. readonly rightViewMatrix: Float32Array;
  56330. readonly timestamp: number;
  56331. }
  56332. interface VRPose {
  56333. readonly angularAcceleration: Float32Array | null;
  56334. readonly angularVelocity: Float32Array | null;
  56335. readonly linearAcceleration: Float32Array | null;
  56336. readonly linearVelocity: Float32Array | null;
  56337. readonly orientation: Float32Array | null;
  56338. readonly position: Float32Array | null;
  56339. readonly timestamp: number;
  56340. }
  56341. interface VRStageParameters {
  56342. sittingToStandingTransform?: Float32Array;
  56343. sizeX?: number;
  56344. sizeY?: number;
  56345. }
  56346. interface Navigator {
  56347. getVRDisplays(): Promise<VRDisplay[]>;
  56348. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56349. }
  56350. interface Window {
  56351. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56352. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56353. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56354. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56355. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56356. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56357. }
  56358. interface Gamepad {
  56359. readonly displayId: number;
  56360. }
  56361. interface XRDevice {
  56362. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56363. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56364. }
  56365. interface XRSession {
  56366. getInputSources(): Array<any>;
  56367. baseLayer: XRWebGLLayer;
  56368. requestFrameOfReference(type: string): Promise<void>;
  56369. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56370. end(): Promise<void>;
  56371. requestAnimationFrame: Function;
  56372. addEventListener: Function;
  56373. }
  56374. interface XRSessionCreationOptions {
  56375. outputContext?: WebGLRenderingContext | null;
  56376. immersive?: boolean;
  56377. environmentIntegration?: boolean;
  56378. }
  56379. interface XRLayer {
  56380. getViewport: Function;
  56381. framebufferWidth: number;
  56382. framebufferHeight: number;
  56383. }
  56384. interface XRView {
  56385. projectionMatrix: Float32Array;
  56386. }
  56387. interface XRFrame {
  56388. getDevicePose: Function;
  56389. getInputPose: Function;
  56390. views: Array<XRView>;
  56391. baseLayer: XRLayer;
  56392. }
  56393. interface XRFrameOfReference {
  56394. }
  56395. interface XRWebGLLayer extends XRLayer {
  56396. framebuffer: WebGLFramebuffer;
  56397. }
  56398. declare var XRWebGLLayer: {
  56399. prototype: XRWebGLLayer;
  56400. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56401. };
  56402. declare module "babylonjs" {
  56403. export * from "babylonjs/Legacy/legacy";
  56404. }
  56405. declare module BABYLON {
  56406. /** Alias type for value that can be null */
  56407. export type Nullable<T> = T | null;
  56408. /**
  56409. * Alias type for number that are floats
  56410. * @ignorenaming
  56411. */
  56412. export type float = number;
  56413. /**
  56414. * Alias type for number that are doubles.
  56415. * @ignorenaming
  56416. */
  56417. export type double = number;
  56418. /**
  56419. * Alias type for number that are integer
  56420. * @ignorenaming
  56421. */
  56422. export type int = number;
  56423. /** Alias type for number array or Float32Array */
  56424. export type FloatArray = number[] | Float32Array;
  56425. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  56426. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  56427. /**
  56428. * Alias for types that can be used by a Buffer or VertexBuffer.
  56429. */
  56430. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  56431. /**
  56432. * Alias type for primitive types
  56433. * @ignorenaming
  56434. */
  56435. type Primitive = undefined | null | boolean | string | number | Function;
  56436. /**
  56437. * Type modifier to make all the properties of an object Readonly
  56438. */
  56439. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  56440. /**
  56441. * Type modifier to make all the properties of an object Readonly recursively
  56442. */
  56443. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  56444. /** @hidden */
  56445. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  56446. }
  56447. /** @hidden */
  56448. /** @hidden */
  56449. type DeepImmutableObject<T> = {
  56450. readonly [K in keyof T]: DeepImmutable<T[K]>;
  56451. };
  56452. }
  56453. declare module BABYLON {
  56454. /**
  56455. * Class containing a set of static utilities functions for arrays.
  56456. */
  56457. export class ArrayTools {
  56458. /**
  56459. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56460. * @param size the number of element to construct and put in the array
  56461. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  56462. * @returns a new array filled with new objects
  56463. */
  56464. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  56465. }
  56466. }
  56467. declare module BABYLON {
  56468. /**
  56469. * Scalar computation library
  56470. */
  56471. export class Scalar {
  56472. /**
  56473. * Two pi constants convenient for computation.
  56474. */
  56475. static TwoPi: number;
  56476. /**
  56477. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56478. * @param a number
  56479. * @param b number
  56480. * @param epsilon (default = 1.401298E-45)
  56481. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  56482. */
  56483. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  56484. /**
  56485. * Returns a string : the upper case translation of the number i to hexadecimal.
  56486. * @param i number
  56487. * @returns the upper case translation of the number i to hexadecimal.
  56488. */
  56489. static ToHex(i: number): string;
  56490. /**
  56491. * Returns -1 if value is negative and +1 is value is positive.
  56492. * @param value the value
  56493. * @returns the value itself if it's equal to zero.
  56494. */
  56495. static Sign(value: number): number;
  56496. /**
  56497. * Returns the value itself if it's between min and max.
  56498. * Returns min if the value is lower than min.
  56499. * Returns max if the value is greater than max.
  56500. * @param value the value to clmap
  56501. * @param min the min value to clamp to (default: 0)
  56502. * @param max the max value to clamp to (default: 1)
  56503. * @returns the clamped value
  56504. */
  56505. static Clamp(value: number, min?: number, max?: number): number;
  56506. /**
  56507. * the log2 of value.
  56508. * @param value the value to compute log2 of
  56509. * @returns the log2 of value.
  56510. */
  56511. static Log2(value: number): number;
  56512. /**
  56513. * Loops the value, so that it is never larger than length and never smaller than 0.
  56514. *
  56515. * This is similar to the modulo operator but it works with floating point numbers.
  56516. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  56517. * With t = 5 and length = 2.5, the result would be 0.0.
  56518. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  56519. * @param value the value
  56520. * @param length the length
  56521. * @returns the looped value
  56522. */
  56523. static Repeat(value: number, length: number): number;
  56524. /**
  56525. * Normalize the value between 0.0 and 1.0 using min and max values
  56526. * @param value value to normalize
  56527. * @param min max to normalize between
  56528. * @param max min to normalize between
  56529. * @returns the normalized value
  56530. */
  56531. static Normalize(value: number, min: number, max: number): number;
  56532. /**
  56533. * Denormalize the value from 0.0 and 1.0 using min and max values
  56534. * @param normalized value to denormalize
  56535. * @param min max to denormalize between
  56536. * @param max min to denormalize between
  56537. * @returns the denormalized value
  56538. */
  56539. static Denormalize(normalized: number, min: number, max: number): number;
  56540. /**
  56541. * Calculates the shortest difference between two given angles given in degrees.
  56542. * @param current current angle in degrees
  56543. * @param target target angle in degrees
  56544. * @returns the delta
  56545. */
  56546. static DeltaAngle(current: number, target: number): number;
  56547. /**
  56548. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  56549. * @param tx value
  56550. * @param length length
  56551. * @returns The returned value will move back and forth between 0 and length
  56552. */
  56553. static PingPong(tx: number, length: number): number;
  56554. /**
  56555. * Interpolates between min and max with smoothing at the limits.
  56556. *
  56557. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  56558. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  56559. * @param from from
  56560. * @param to to
  56561. * @param tx value
  56562. * @returns the smooth stepped value
  56563. */
  56564. static SmoothStep(from: number, to: number, tx: number): number;
  56565. /**
  56566. * Moves a value current towards target.
  56567. *
  56568. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  56569. * Negative values of maxDelta pushes the value away from target.
  56570. * @param current current value
  56571. * @param target target value
  56572. * @param maxDelta max distance to move
  56573. * @returns resulting value
  56574. */
  56575. static MoveTowards(current: number, target: number, maxDelta: number): number;
  56576. /**
  56577. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56578. *
  56579. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  56580. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  56581. * @param current current value
  56582. * @param target target value
  56583. * @param maxDelta max distance to move
  56584. * @returns resulting angle
  56585. */
  56586. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  56587. /**
  56588. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  56589. * @param start start value
  56590. * @param end target value
  56591. * @param amount amount to lerp between
  56592. * @returns the lerped value
  56593. */
  56594. static Lerp(start: number, end: number, amount: number): number;
  56595. /**
  56596. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  56597. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  56598. * @param start start value
  56599. * @param end target value
  56600. * @param amount amount to lerp between
  56601. * @returns the lerped value
  56602. */
  56603. static LerpAngle(start: number, end: number, amount: number): number;
  56604. /**
  56605. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  56606. * @param a start value
  56607. * @param b target value
  56608. * @param value value between a and b
  56609. * @returns the inverseLerp value
  56610. */
  56611. static InverseLerp(a: number, b: number, value: number): number;
  56612. /**
  56613. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  56614. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  56615. * @param value1 spline value
  56616. * @param tangent1 spline value
  56617. * @param value2 spline value
  56618. * @param tangent2 spline value
  56619. * @param amount input value
  56620. * @returns hermite result
  56621. */
  56622. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  56623. /**
  56624. * Returns a random float number between and min and max values
  56625. * @param min min value of random
  56626. * @param max max value of random
  56627. * @returns random value
  56628. */
  56629. static RandomRange(min: number, max: number): number;
  56630. /**
  56631. * This function returns percentage of a number in a given range.
  56632. *
  56633. * RangeToPercent(40,20,60) will return 0.5 (50%)
  56634. * RangeToPercent(34,0,100) will return 0.34 (34%)
  56635. * @param number to convert to percentage
  56636. * @param min min range
  56637. * @param max max range
  56638. * @returns the percentage
  56639. */
  56640. static RangeToPercent(number: number, min: number, max: number): number;
  56641. /**
  56642. * This function returns number that corresponds to the percentage in a given range.
  56643. *
  56644. * PercentToRange(0.34,0,100) will return 34.
  56645. * @param percent to convert to number
  56646. * @param min min range
  56647. * @param max max range
  56648. * @returns the number
  56649. */
  56650. static PercentToRange(percent: number, min: number, max: number): number;
  56651. /**
  56652. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  56653. * @param angle The angle to normalize in radian.
  56654. * @return The converted angle.
  56655. */
  56656. static NormalizeRadians(angle: number): number;
  56657. }
  56658. }
  56659. declare module BABYLON {
  56660. /**
  56661. * Constant used to convert a value to gamma space
  56662. * @ignorenaming
  56663. */
  56664. export const ToGammaSpace: number;
  56665. /**
  56666. * Constant used to convert a value to linear space
  56667. * @ignorenaming
  56668. */
  56669. export const ToLinearSpace = 2.2;
  56670. /**
  56671. * Constant used to define the minimal number value in Babylon.js
  56672. * @ignorenaming
  56673. */
  56674. export const Epsilon = 0.001;
  56675. /**
  56676. * Class used to hold a RBG color
  56677. */
  56678. export class Color3 {
  56679. /**
  56680. * Defines the red component (between 0 and 1, default is 0)
  56681. */
  56682. r: number;
  56683. /**
  56684. * Defines the green component (between 0 and 1, default is 0)
  56685. */
  56686. g: number;
  56687. /**
  56688. * Defines the blue component (between 0 and 1, default is 0)
  56689. */
  56690. b: number;
  56691. /**
  56692. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  56693. * @param r defines the red component (between 0 and 1, default is 0)
  56694. * @param g defines the green component (between 0 and 1, default is 0)
  56695. * @param b defines the blue component (between 0 and 1, default is 0)
  56696. */
  56697. constructor(
  56698. /**
  56699. * Defines the red component (between 0 and 1, default is 0)
  56700. */
  56701. r?: number,
  56702. /**
  56703. * Defines the green component (between 0 and 1, default is 0)
  56704. */
  56705. g?: number,
  56706. /**
  56707. * Defines the blue component (between 0 and 1, default is 0)
  56708. */
  56709. b?: number);
  56710. /**
  56711. * Creates a string with the Color3 current values
  56712. * @returns the string representation of the Color3 object
  56713. */
  56714. toString(): string;
  56715. /**
  56716. * Returns the string "Color3"
  56717. * @returns "Color3"
  56718. */
  56719. getClassName(): string;
  56720. /**
  56721. * Compute the Color3 hash code
  56722. * @returns an unique number that can be used to hash Color3 objects
  56723. */
  56724. getHashCode(): number;
  56725. /**
  56726. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  56727. * @param array defines the array where to store the r,g,b components
  56728. * @param index defines an optional index in the target array to define where to start storing values
  56729. * @returns the current Color3 object
  56730. */
  56731. toArray(array: FloatArray, index?: number): Color3;
  56732. /**
  56733. * Returns a new Color4 object from the current Color3 and the given alpha
  56734. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  56735. * @returns a new Color4 object
  56736. */
  56737. toColor4(alpha?: number): Color4;
  56738. /**
  56739. * Returns a new array populated with 3 numeric elements : red, green and blue values
  56740. * @returns the new array
  56741. */
  56742. asArray(): number[];
  56743. /**
  56744. * Returns the luminance value
  56745. * @returns a float value
  56746. */
  56747. toLuminance(): number;
  56748. /**
  56749. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  56750. * @param otherColor defines the second operand
  56751. * @returns the new Color3 object
  56752. */
  56753. multiply(otherColor: DeepImmutable<Color3>): Color3;
  56754. /**
  56755. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  56756. * @param otherColor defines the second operand
  56757. * @param result defines the Color3 object where to store the result
  56758. * @returns the current Color3
  56759. */
  56760. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56761. /**
  56762. * Determines equality between Color3 objects
  56763. * @param otherColor defines the second operand
  56764. * @returns true if the rgb values are equal to the given ones
  56765. */
  56766. equals(otherColor: DeepImmutable<Color3>): boolean;
  56767. /**
  56768. * Determines equality between the current Color3 object and a set of r,b,g values
  56769. * @param r defines the red component to check
  56770. * @param g defines the green component to check
  56771. * @param b defines the blue component to check
  56772. * @returns true if the rgb values are equal to the given ones
  56773. */
  56774. equalsFloats(r: number, g: number, b: number): boolean;
  56775. /**
  56776. * Multiplies in place each rgb value by scale
  56777. * @param scale defines the scaling factor
  56778. * @returns the updated Color3
  56779. */
  56780. scale(scale: number): Color3;
  56781. /**
  56782. * Multiplies the rgb values by scale and stores the result into "result"
  56783. * @param scale defines the scaling factor
  56784. * @param result defines the Color3 object where to store the result
  56785. * @returns the unmodified current Color3
  56786. */
  56787. scaleToRef(scale: number, result: Color3): Color3;
  56788. /**
  56789. * Scale the current Color3 values by a factor and add the result to a given Color3
  56790. * @param scale defines the scale factor
  56791. * @param result defines color to store the result into
  56792. * @returns the unmodified current Color3
  56793. */
  56794. scaleAndAddToRef(scale: number, result: Color3): Color3;
  56795. /**
  56796. * Clamps the rgb values by the min and max values and stores the result into "result"
  56797. * @param min defines minimum clamping value (default is 0)
  56798. * @param max defines maximum clamping value (default is 1)
  56799. * @param result defines color to store the result into
  56800. * @returns the original Color3
  56801. */
  56802. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  56803. /**
  56804. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  56805. * @param otherColor defines the second operand
  56806. * @returns the new Color3
  56807. */
  56808. add(otherColor: DeepImmutable<Color3>): Color3;
  56809. /**
  56810. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  56811. * @param otherColor defines the second operand
  56812. * @param result defines Color3 object to store the result into
  56813. * @returns the unmodified current Color3
  56814. */
  56815. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56816. /**
  56817. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  56818. * @param otherColor defines the second operand
  56819. * @returns the new Color3
  56820. */
  56821. subtract(otherColor: DeepImmutable<Color3>): Color3;
  56822. /**
  56823. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  56824. * @param otherColor defines the second operand
  56825. * @param result defines Color3 object to store the result into
  56826. * @returns the unmodified current Color3
  56827. */
  56828. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  56829. /**
  56830. * Copy the current object
  56831. * @returns a new Color3 copied the current one
  56832. */
  56833. clone(): Color3;
  56834. /**
  56835. * Copies the rgb values from the source in the current Color3
  56836. * @param source defines the source Color3 object
  56837. * @returns the updated Color3 object
  56838. */
  56839. copyFrom(source: DeepImmutable<Color3>): Color3;
  56840. /**
  56841. * Updates the Color3 rgb values from the given floats
  56842. * @param r defines the red component to read from
  56843. * @param g defines the green component to read from
  56844. * @param b defines the blue component to read from
  56845. * @returns the current Color3 object
  56846. */
  56847. copyFromFloats(r: number, g: number, b: number): Color3;
  56848. /**
  56849. * Updates the Color3 rgb values from the given floats
  56850. * @param r defines the red component to read from
  56851. * @param g defines the green component to read from
  56852. * @param b defines the blue component to read from
  56853. * @returns the current Color3 object
  56854. */
  56855. set(r: number, g: number, b: number): Color3;
  56856. /**
  56857. * Compute the Color3 hexadecimal code as a string
  56858. * @returns a string containing the hexadecimal representation of the Color3 object
  56859. */
  56860. toHexString(): string;
  56861. /**
  56862. * Computes a new Color3 converted from the current one to linear space
  56863. * @returns a new Color3 object
  56864. */
  56865. toLinearSpace(): Color3;
  56866. /**
  56867. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  56868. * @param convertedColor defines the Color3 object where to store the linear space version
  56869. * @returns the unmodified Color3
  56870. */
  56871. toLinearSpaceToRef(convertedColor: Color3): Color3;
  56872. /**
  56873. * Computes a new Color3 converted from the current one to gamma space
  56874. * @returns a new Color3 object
  56875. */
  56876. toGammaSpace(): Color3;
  56877. /**
  56878. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  56879. * @param convertedColor defines the Color3 object where to store the gamma space version
  56880. * @returns the unmodified Color3
  56881. */
  56882. toGammaSpaceToRef(convertedColor: Color3): Color3;
  56883. private static _BlackReadOnly;
  56884. /**
  56885. * Creates a new Color3 from the string containing valid hexadecimal values
  56886. * @param hex defines a string containing valid hexadecimal values
  56887. * @returns a new Color3 object
  56888. */
  56889. static FromHexString(hex: string): Color3;
  56890. /**
  56891. * Creates a new Vector3 from the starting index of the given array
  56892. * @param array defines the source array
  56893. * @param offset defines an offset in the source array
  56894. * @returns a new Color3 object
  56895. */
  56896. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  56897. /**
  56898. * Creates a new Color3 from integer values (< 256)
  56899. * @param r defines the red component to read from (value between 0 and 255)
  56900. * @param g defines the green component to read from (value between 0 and 255)
  56901. * @param b defines the blue component to read from (value between 0 and 255)
  56902. * @returns a new Color3 object
  56903. */
  56904. static FromInts(r: number, g: number, b: number): Color3;
  56905. /**
  56906. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56907. * @param start defines the start Color3 value
  56908. * @param end defines the end Color3 value
  56909. * @param amount defines the gradient value between start and end
  56910. * @returns a new Color3 object
  56911. */
  56912. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  56913. /**
  56914. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  56915. * @param left defines the start value
  56916. * @param right defines the end value
  56917. * @param amount defines the gradient factor
  56918. * @param result defines the Color3 object where to store the result
  56919. */
  56920. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  56921. /**
  56922. * Returns a Color3 value containing a red color
  56923. * @returns a new Color3 object
  56924. */
  56925. static Red(): Color3;
  56926. /**
  56927. * Returns a Color3 value containing a green color
  56928. * @returns a new Color3 object
  56929. */
  56930. static Green(): Color3;
  56931. /**
  56932. * Returns a Color3 value containing a blue color
  56933. * @returns a new Color3 object
  56934. */
  56935. static Blue(): Color3;
  56936. /**
  56937. * Returns a Color3 value containing a black color
  56938. * @returns a new Color3 object
  56939. */
  56940. static Black(): Color3;
  56941. /**
  56942. * Gets a Color3 value containing a black color that must not be updated
  56943. */
  56944. static readonly BlackReadOnly: DeepImmutable<Color3>;
  56945. /**
  56946. * Returns a Color3 value containing a white color
  56947. * @returns a new Color3 object
  56948. */
  56949. static White(): Color3;
  56950. /**
  56951. * Returns a Color3 value containing a purple color
  56952. * @returns a new Color3 object
  56953. */
  56954. static Purple(): Color3;
  56955. /**
  56956. * Returns a Color3 value containing a magenta color
  56957. * @returns a new Color3 object
  56958. */
  56959. static Magenta(): Color3;
  56960. /**
  56961. * Returns a Color3 value containing a yellow color
  56962. * @returns a new Color3 object
  56963. */
  56964. static Yellow(): Color3;
  56965. /**
  56966. * Returns a Color3 value containing a gray color
  56967. * @returns a new Color3 object
  56968. */
  56969. static Gray(): Color3;
  56970. /**
  56971. * Returns a Color3 value containing a teal color
  56972. * @returns a new Color3 object
  56973. */
  56974. static Teal(): Color3;
  56975. /**
  56976. * Returns a Color3 value containing a random color
  56977. * @returns a new Color3 object
  56978. */
  56979. static Random(): Color3;
  56980. }
  56981. /**
  56982. * Class used to hold a RBGA color
  56983. */
  56984. export class Color4 {
  56985. /**
  56986. * Defines the red component (between 0 and 1, default is 0)
  56987. */
  56988. r: number;
  56989. /**
  56990. * Defines the green component (between 0 and 1, default is 0)
  56991. */
  56992. g: number;
  56993. /**
  56994. * Defines the blue component (between 0 and 1, default is 0)
  56995. */
  56996. b: number;
  56997. /**
  56998. * Defines the alpha component (between 0 and 1, default is 1)
  56999. */
  57000. a: number;
  57001. /**
  57002. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  57003. * @param r defines the red component (between 0 and 1, default is 0)
  57004. * @param g defines the green component (between 0 and 1, default is 0)
  57005. * @param b defines the blue component (between 0 and 1, default is 0)
  57006. * @param a defines the alpha component (between 0 and 1, default is 1)
  57007. */
  57008. constructor(
  57009. /**
  57010. * Defines the red component (between 0 and 1, default is 0)
  57011. */
  57012. r?: number,
  57013. /**
  57014. * Defines the green component (between 0 and 1, default is 0)
  57015. */
  57016. g?: number,
  57017. /**
  57018. * Defines the blue component (between 0 and 1, default is 0)
  57019. */
  57020. b?: number,
  57021. /**
  57022. * Defines the alpha component (between 0 and 1, default is 1)
  57023. */
  57024. a?: number);
  57025. /**
  57026. * Adds in place the given Color4 values to the current Color4 object
  57027. * @param right defines the second operand
  57028. * @returns the current updated Color4 object
  57029. */
  57030. addInPlace(right: DeepImmutable<Color4>): Color4;
  57031. /**
  57032. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  57033. * @returns the new array
  57034. */
  57035. asArray(): number[];
  57036. /**
  57037. * Stores from the starting index in the given array the Color4 successive values
  57038. * @param array defines the array where to store the r,g,b components
  57039. * @param index defines an optional index in the target array to define where to start storing values
  57040. * @returns the current Color4 object
  57041. */
  57042. toArray(array: number[], index?: number): Color4;
  57043. /**
  57044. * Determines equality between Color4 objects
  57045. * @param otherColor defines the second operand
  57046. * @returns true if the rgba values are equal to the given ones
  57047. */
  57048. equals(otherColor: DeepImmutable<Color4>): boolean;
  57049. /**
  57050. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  57051. * @param right defines the second operand
  57052. * @returns a new Color4 object
  57053. */
  57054. add(right: DeepImmutable<Color4>): Color4;
  57055. /**
  57056. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  57057. * @param right defines the second operand
  57058. * @returns a new Color4 object
  57059. */
  57060. subtract(right: DeepImmutable<Color4>): Color4;
  57061. /**
  57062. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  57063. * @param right defines the second operand
  57064. * @param result defines the Color4 object where to store the result
  57065. * @returns the current Color4 object
  57066. */
  57067. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  57068. /**
  57069. * Creates a new Color4 with the current Color4 values multiplied by scale
  57070. * @param scale defines the scaling factor to apply
  57071. * @returns a new Color4 object
  57072. */
  57073. scale(scale: number): Color4;
  57074. /**
  57075. * Multiplies the current Color4 values by scale and stores the result in "result"
  57076. * @param scale defines the scaling factor to apply
  57077. * @param result defines the Color4 object where to store the result
  57078. * @returns the current unmodified Color4
  57079. */
  57080. scaleToRef(scale: number, result: Color4): Color4;
  57081. /**
  57082. * Scale the current Color4 values by a factor and add the result to a given Color4
  57083. * @param scale defines the scale factor
  57084. * @param result defines the Color4 object where to store the result
  57085. * @returns the unmodified current Color4
  57086. */
  57087. scaleAndAddToRef(scale: number, result: Color4): Color4;
  57088. /**
  57089. * Clamps the rgb values by the min and max values and stores the result into "result"
  57090. * @param min defines minimum clamping value (default is 0)
  57091. * @param max defines maximum clamping value (default is 1)
  57092. * @param result defines color to store the result into.
  57093. * @returns the cuurent Color4
  57094. */
  57095. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  57096. /**
  57097. * Multipy an Color4 value by another and return a new Color4 object
  57098. * @param color defines the Color4 value to multiply by
  57099. * @returns a new Color4 object
  57100. */
  57101. multiply(color: Color4): Color4;
  57102. /**
  57103. * Multipy a Color4 value by another and push the result in a reference value
  57104. * @param color defines the Color4 value to multiply by
  57105. * @param result defines the Color4 to fill the result in
  57106. * @returns the result Color4
  57107. */
  57108. multiplyToRef(color: Color4, result: Color4): Color4;
  57109. /**
  57110. * Creates a string with the Color4 current values
  57111. * @returns the string representation of the Color4 object
  57112. */
  57113. toString(): string;
  57114. /**
  57115. * Returns the string "Color4"
  57116. * @returns "Color4"
  57117. */
  57118. getClassName(): string;
  57119. /**
  57120. * Compute the Color4 hash code
  57121. * @returns an unique number that can be used to hash Color4 objects
  57122. */
  57123. getHashCode(): number;
  57124. /**
  57125. * Creates a new Color4 copied from the current one
  57126. * @returns a new Color4 object
  57127. */
  57128. clone(): Color4;
  57129. /**
  57130. * Copies the given Color4 values into the current one
  57131. * @param source defines the source Color4 object
  57132. * @returns the current updated Color4 object
  57133. */
  57134. copyFrom(source: Color4): Color4;
  57135. /**
  57136. * Copies the given float values into the current one
  57137. * @param r defines the red component to read from
  57138. * @param g defines the green component to read from
  57139. * @param b defines the blue component to read from
  57140. * @param a defines the alpha component to read from
  57141. * @returns the current updated Color4 object
  57142. */
  57143. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  57144. /**
  57145. * Copies the given float values into the current one
  57146. * @param r defines the red component to read from
  57147. * @param g defines the green component to read from
  57148. * @param b defines the blue component to read from
  57149. * @param a defines the alpha component to read from
  57150. * @returns the current updated Color4 object
  57151. */
  57152. set(r: number, g: number, b: number, a: number): Color4;
  57153. /**
  57154. * Compute the Color4 hexadecimal code as a string
  57155. * @returns a string containing the hexadecimal representation of the Color4 object
  57156. */
  57157. toHexString(): string;
  57158. /**
  57159. * Computes a new Color4 converted from the current one to linear space
  57160. * @returns a new Color4 object
  57161. */
  57162. toLinearSpace(): Color4;
  57163. /**
  57164. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  57165. * @param convertedColor defines the Color4 object where to store the linear space version
  57166. * @returns the unmodified Color4
  57167. */
  57168. toLinearSpaceToRef(convertedColor: Color4): Color4;
  57169. /**
  57170. * Computes a new Color4 converted from the current one to gamma space
  57171. * @returns a new Color4 object
  57172. */
  57173. toGammaSpace(): Color4;
  57174. /**
  57175. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  57176. * @param convertedColor defines the Color4 object where to store the gamma space version
  57177. * @returns the unmodified Color4
  57178. */
  57179. toGammaSpaceToRef(convertedColor: Color4): Color4;
  57180. /**
  57181. * Creates a new Color4 from the string containing valid hexadecimal values
  57182. * @param hex defines a string containing valid hexadecimal values
  57183. * @returns a new Color4 object
  57184. */
  57185. static FromHexString(hex: string): Color4;
  57186. /**
  57187. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57188. * @param left defines the start value
  57189. * @param right defines the end value
  57190. * @param amount defines the gradient factor
  57191. * @returns a new Color4 object
  57192. */
  57193. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  57194. /**
  57195. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  57196. * @param left defines the start value
  57197. * @param right defines the end value
  57198. * @param amount defines the gradient factor
  57199. * @param result defines the Color4 object where to store data
  57200. */
  57201. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  57202. /**
  57203. * Creates a new Color4 from a Color3 and an alpha value
  57204. * @param color3 defines the source Color3 to read from
  57205. * @param alpha defines the alpha component (1.0 by default)
  57206. * @returns a new Color4 object
  57207. */
  57208. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  57209. /**
  57210. * Creates a new Color4 from the starting index element of the given array
  57211. * @param array defines the source array to read from
  57212. * @param offset defines the offset in the source array
  57213. * @returns a new Color4 object
  57214. */
  57215. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  57216. /**
  57217. * Creates a new Color3 from integer values (< 256)
  57218. * @param r defines the red component to read from (value between 0 and 255)
  57219. * @param g defines the green component to read from (value between 0 and 255)
  57220. * @param b defines the blue component to read from (value between 0 and 255)
  57221. * @param a defines the alpha component to read from (value between 0 and 255)
  57222. * @returns a new Color3 object
  57223. */
  57224. static FromInts(r: number, g: number, b: number, a: number): Color4;
  57225. /**
  57226. * Check the content of a given array and convert it to an array containing RGBA data
  57227. * If the original array was already containing count * 4 values then it is returned directly
  57228. * @param colors defines the array to check
  57229. * @param count defines the number of RGBA data to expect
  57230. * @returns an array containing count * 4 values (RGBA)
  57231. */
  57232. static CheckColors4(colors: number[], count: number): number[];
  57233. }
  57234. /**
  57235. * Class representing a vector containing 2 coordinates
  57236. */
  57237. export class Vector2 {
  57238. /** defines the first coordinate */
  57239. x: number;
  57240. /** defines the second coordinate */
  57241. y: number;
  57242. /**
  57243. * Creates a new Vector2 from the given x and y coordinates
  57244. * @param x defines the first coordinate
  57245. * @param y defines the second coordinate
  57246. */
  57247. constructor(
  57248. /** defines the first coordinate */
  57249. x?: number,
  57250. /** defines the second coordinate */
  57251. y?: number);
  57252. /**
  57253. * Gets a string with the Vector2 coordinates
  57254. * @returns a string with the Vector2 coordinates
  57255. */
  57256. toString(): string;
  57257. /**
  57258. * Gets class name
  57259. * @returns the string "Vector2"
  57260. */
  57261. getClassName(): string;
  57262. /**
  57263. * Gets current vector hash code
  57264. * @returns the Vector2 hash code as a number
  57265. */
  57266. getHashCode(): number;
  57267. /**
  57268. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  57269. * @param array defines the source array
  57270. * @param index defines the offset in source array
  57271. * @returns the current Vector2
  57272. */
  57273. toArray(array: FloatArray, index?: number): Vector2;
  57274. /**
  57275. * Copy the current vector to an array
  57276. * @returns a new array with 2 elements: the Vector2 coordinates.
  57277. */
  57278. asArray(): number[];
  57279. /**
  57280. * Sets the Vector2 coordinates with the given Vector2 coordinates
  57281. * @param source defines the source Vector2
  57282. * @returns the current updated Vector2
  57283. */
  57284. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  57285. /**
  57286. * Sets the Vector2 coordinates with the given floats
  57287. * @param x defines the first coordinate
  57288. * @param y defines the second coordinate
  57289. * @returns the current updated Vector2
  57290. */
  57291. copyFromFloats(x: number, y: number): Vector2;
  57292. /**
  57293. * Sets the Vector2 coordinates with the given floats
  57294. * @param x defines the first coordinate
  57295. * @param y defines the second coordinate
  57296. * @returns the current updated Vector2
  57297. */
  57298. set(x: number, y: number): Vector2;
  57299. /**
  57300. * Add another vector with the current one
  57301. * @param otherVector defines the other vector
  57302. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  57303. */
  57304. add(otherVector: DeepImmutable<Vector2>): Vector2;
  57305. /**
  57306. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  57307. * @param otherVector defines the other vector
  57308. * @param result defines the target vector
  57309. * @returns the unmodified current Vector2
  57310. */
  57311. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57312. /**
  57313. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  57314. * @param otherVector defines the other vector
  57315. * @returns the current updated Vector2
  57316. */
  57317. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57318. /**
  57319. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  57320. * @param otherVector defines the other vector
  57321. * @returns a new Vector2
  57322. */
  57323. addVector3(otherVector: Vector3): Vector2;
  57324. /**
  57325. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  57326. * @param otherVector defines the other vector
  57327. * @returns a new Vector2
  57328. */
  57329. subtract(otherVector: Vector2): Vector2;
  57330. /**
  57331. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  57332. * @param otherVector defines the other vector
  57333. * @param result defines the target vector
  57334. * @returns the unmodified current Vector2
  57335. */
  57336. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57337. /**
  57338. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  57339. * @param otherVector defines the other vector
  57340. * @returns the current updated Vector2
  57341. */
  57342. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57343. /**
  57344. * Multiplies in place the current Vector2 coordinates by the given ones
  57345. * @param otherVector defines the other vector
  57346. * @returns the current updated Vector2
  57347. */
  57348. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57349. /**
  57350. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  57351. * @param otherVector defines the other vector
  57352. * @returns a new Vector2
  57353. */
  57354. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  57355. /**
  57356. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  57357. * @param otherVector defines the other vector
  57358. * @param result defines the target vector
  57359. * @returns the unmodified current Vector2
  57360. */
  57361. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57362. /**
  57363. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  57364. * @param x defines the first coordinate
  57365. * @param y defines the second coordinate
  57366. * @returns a new Vector2
  57367. */
  57368. multiplyByFloats(x: number, y: number): Vector2;
  57369. /**
  57370. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  57371. * @param otherVector defines the other vector
  57372. * @returns a new Vector2
  57373. */
  57374. divide(otherVector: Vector2): Vector2;
  57375. /**
  57376. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  57377. * @param otherVector defines the other vector
  57378. * @param result defines the target vector
  57379. * @returns the unmodified current Vector2
  57380. */
  57381. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  57382. /**
  57383. * Divides the current Vector2 coordinates by the given ones
  57384. * @param otherVector defines the other vector
  57385. * @returns the current updated Vector2
  57386. */
  57387. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  57388. /**
  57389. * Gets a new Vector2 with current Vector2 negated coordinates
  57390. * @returns a new Vector2
  57391. */
  57392. negate(): Vector2;
  57393. /**
  57394. * Multiply the Vector2 coordinates by scale
  57395. * @param scale defines the scaling factor
  57396. * @returns the current updated Vector2
  57397. */
  57398. scaleInPlace(scale: number): Vector2;
  57399. /**
  57400. * Returns a new Vector2 scaled by "scale" from the current Vector2
  57401. * @param scale defines the scaling factor
  57402. * @returns a new Vector2
  57403. */
  57404. scale(scale: number): Vector2;
  57405. /**
  57406. * Scale the current Vector2 values by a factor to a given Vector2
  57407. * @param scale defines the scale factor
  57408. * @param result defines the Vector2 object where to store the result
  57409. * @returns the unmodified current Vector2
  57410. */
  57411. scaleToRef(scale: number, result: Vector2): Vector2;
  57412. /**
  57413. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  57414. * @param scale defines the scale factor
  57415. * @param result defines the Vector2 object where to store the result
  57416. * @returns the unmodified current Vector2
  57417. */
  57418. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  57419. /**
  57420. * Gets a boolean if two vectors are equals
  57421. * @param otherVector defines the other vector
  57422. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  57423. */
  57424. equals(otherVector: DeepImmutable<Vector2>): boolean;
  57425. /**
  57426. * Gets a boolean if two vectors are equals (using an epsilon value)
  57427. * @param otherVector defines the other vector
  57428. * @param epsilon defines the minimal distance to consider equality
  57429. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  57430. */
  57431. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  57432. /**
  57433. * Gets a new Vector2 from current Vector2 floored values
  57434. * @returns a new Vector2
  57435. */
  57436. floor(): Vector2;
  57437. /**
  57438. * Gets a new Vector2 from current Vector2 floored values
  57439. * @returns a new Vector2
  57440. */
  57441. fract(): Vector2;
  57442. /**
  57443. * Gets the length of the vector
  57444. * @returns the vector length (float)
  57445. */
  57446. length(): number;
  57447. /**
  57448. * Gets the vector squared length
  57449. * @returns the vector squared length (float)
  57450. */
  57451. lengthSquared(): number;
  57452. /**
  57453. * Normalize the vector
  57454. * @returns the current updated Vector2
  57455. */
  57456. normalize(): Vector2;
  57457. /**
  57458. * Gets a new Vector2 copied from the Vector2
  57459. * @returns a new Vector2
  57460. */
  57461. clone(): Vector2;
  57462. /**
  57463. * Gets a new Vector2(0, 0)
  57464. * @returns a new Vector2
  57465. */
  57466. static Zero(): Vector2;
  57467. /**
  57468. * Gets a new Vector2(1, 1)
  57469. * @returns a new Vector2
  57470. */
  57471. static One(): Vector2;
  57472. /**
  57473. * Gets a new Vector2 set from the given index element of the given array
  57474. * @param array defines the data source
  57475. * @param offset defines the offset in the data source
  57476. * @returns a new Vector2
  57477. */
  57478. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  57479. /**
  57480. * Sets "result" from the given index element of the given array
  57481. * @param array defines the data source
  57482. * @param offset defines the offset in the data source
  57483. * @param result defines the target vector
  57484. */
  57485. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  57486. /**
  57487. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  57488. * @param value1 defines 1st point of control
  57489. * @param value2 defines 2nd point of control
  57490. * @param value3 defines 3rd point of control
  57491. * @param value4 defines 4th point of control
  57492. * @param amount defines the interpolation factor
  57493. * @returns a new Vector2
  57494. */
  57495. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  57496. /**
  57497. * 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".
  57498. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  57499. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  57500. * @param value defines the value to clamp
  57501. * @param min defines the lower limit
  57502. * @param max defines the upper limit
  57503. * @returns a new Vector2
  57504. */
  57505. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  57506. /**
  57507. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  57508. * @param value1 defines the 1st control point
  57509. * @param tangent1 defines the outgoing tangent
  57510. * @param value2 defines the 2nd control point
  57511. * @param tangent2 defines the incoming tangent
  57512. * @param amount defines the interpolation factor
  57513. * @returns a new Vector2
  57514. */
  57515. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  57516. /**
  57517. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  57518. * @param start defines the start vector
  57519. * @param end defines the end vector
  57520. * @param amount defines the interpolation factor
  57521. * @returns a new Vector2
  57522. */
  57523. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  57524. /**
  57525. * Gets the dot product of the vector "left" and the vector "right"
  57526. * @param left defines first vector
  57527. * @param right defines second vector
  57528. * @returns the dot product (float)
  57529. */
  57530. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  57531. /**
  57532. * Returns a new Vector2 equal to the normalized given vector
  57533. * @param vector defines the vector to normalize
  57534. * @returns a new Vector2
  57535. */
  57536. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  57537. /**
  57538. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  57539. * @param left defines 1st vector
  57540. * @param right defines 2nd vector
  57541. * @returns a new Vector2
  57542. */
  57543. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57544. /**
  57545. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  57546. * @param left defines 1st vector
  57547. * @param right defines 2nd vector
  57548. * @returns a new Vector2
  57549. */
  57550. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  57551. /**
  57552. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  57553. * @param vector defines the vector to transform
  57554. * @param transformation defines the matrix to apply
  57555. * @returns a new Vector2
  57556. */
  57557. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  57558. /**
  57559. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  57560. * @param vector defines the vector to transform
  57561. * @param transformation defines the matrix to apply
  57562. * @param result defines the target vector
  57563. */
  57564. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  57565. /**
  57566. * Determines if a given vector is included in a triangle
  57567. * @param p defines the vector to test
  57568. * @param p0 defines 1st triangle point
  57569. * @param p1 defines 2nd triangle point
  57570. * @param p2 defines 3rd triangle point
  57571. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  57572. */
  57573. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  57574. /**
  57575. * Gets the distance between the vectors "value1" and "value2"
  57576. * @param value1 defines first vector
  57577. * @param value2 defines second vector
  57578. * @returns the distance between vectors
  57579. */
  57580. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57581. /**
  57582. * Returns the squared distance between the vectors "value1" and "value2"
  57583. * @param value1 defines first vector
  57584. * @param value2 defines second vector
  57585. * @returns the squared distance between vectors
  57586. */
  57587. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  57588. /**
  57589. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  57590. * @param value1 defines first vector
  57591. * @param value2 defines second vector
  57592. * @returns a new Vector2
  57593. */
  57594. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  57595. /**
  57596. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  57597. * @param p defines the middle point
  57598. * @param segA defines one point of the segment
  57599. * @param segB defines the other point of the segment
  57600. * @returns the shortest distance
  57601. */
  57602. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  57603. }
  57604. /**
  57605. * Classed used to store (x,y,z) vector representation
  57606. * A Vector3 is the main object used in 3D geometry
  57607. * It can represent etiher the coordinates of a point the space, either a direction
  57608. * Reminder: js uses a left handed forward facing system
  57609. */
  57610. export class Vector3 {
  57611. /**
  57612. * Defines the first coordinates (on X axis)
  57613. */
  57614. x: number;
  57615. /**
  57616. * Defines the second coordinates (on Y axis)
  57617. */
  57618. y: number;
  57619. /**
  57620. * Defines the third coordinates (on Z axis)
  57621. */
  57622. z: number;
  57623. private static _UpReadOnly;
  57624. /**
  57625. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  57626. * @param x defines the first coordinates (on X axis)
  57627. * @param y defines the second coordinates (on Y axis)
  57628. * @param z defines the third coordinates (on Z axis)
  57629. */
  57630. constructor(
  57631. /**
  57632. * Defines the first coordinates (on X axis)
  57633. */
  57634. x?: number,
  57635. /**
  57636. * Defines the second coordinates (on Y axis)
  57637. */
  57638. y?: number,
  57639. /**
  57640. * Defines the third coordinates (on Z axis)
  57641. */
  57642. z?: number);
  57643. /**
  57644. * Creates a string representation of the Vector3
  57645. * @returns a string with the Vector3 coordinates.
  57646. */
  57647. toString(): string;
  57648. /**
  57649. * Gets the class name
  57650. * @returns the string "Vector3"
  57651. */
  57652. getClassName(): string;
  57653. /**
  57654. * Creates the Vector3 hash code
  57655. * @returns a number which tends to be unique between Vector3 instances
  57656. */
  57657. getHashCode(): number;
  57658. /**
  57659. * Creates an array containing three elements : the coordinates of the Vector3
  57660. * @returns a new array of numbers
  57661. */
  57662. asArray(): number[];
  57663. /**
  57664. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  57665. * @param array defines the destination array
  57666. * @param index defines the offset in the destination array
  57667. * @returns the current Vector3
  57668. */
  57669. toArray(array: FloatArray, index?: number): Vector3;
  57670. /**
  57671. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  57672. * @returns a new Quaternion object, computed from the Vector3 coordinates
  57673. */
  57674. toQuaternion(): Quaternion;
  57675. /**
  57676. * Adds the given vector to the current Vector3
  57677. * @param otherVector defines the second operand
  57678. * @returns the current updated Vector3
  57679. */
  57680. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57681. /**
  57682. * Adds the given coordinates to the current Vector3
  57683. * @param x defines the x coordinate of the operand
  57684. * @param y defines the y coordinate of the operand
  57685. * @param z defines the z coordinate of the operand
  57686. * @returns the current updated Vector3
  57687. */
  57688. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57689. /**
  57690. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  57691. * @param otherVector defines the second operand
  57692. * @returns the resulting Vector3
  57693. */
  57694. add(otherVector: DeepImmutable<Vector3>): Vector3;
  57695. /**
  57696. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  57697. * @param otherVector defines the second operand
  57698. * @param result defines the Vector3 object where to store the result
  57699. * @returns the current Vector3
  57700. */
  57701. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57702. /**
  57703. * Subtract the given vector from the current Vector3
  57704. * @param otherVector defines the second operand
  57705. * @returns the current updated Vector3
  57706. */
  57707. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57708. /**
  57709. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  57710. * @param otherVector defines the second operand
  57711. * @returns the resulting Vector3
  57712. */
  57713. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  57714. /**
  57715. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  57716. * @param otherVector defines the second operand
  57717. * @param result defines the Vector3 object where to store the result
  57718. * @returns the current Vector3
  57719. */
  57720. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57721. /**
  57722. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  57723. * @param x defines the x coordinate of the operand
  57724. * @param y defines the y coordinate of the operand
  57725. * @param z defines the z coordinate of the operand
  57726. * @returns the resulting Vector3
  57727. */
  57728. subtractFromFloats(x: number, y: number, z: number): Vector3;
  57729. /**
  57730. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  57731. * @param x defines the x coordinate of the operand
  57732. * @param y defines the y coordinate of the operand
  57733. * @param z defines the z coordinate of the operand
  57734. * @param result defines the Vector3 object where to store the result
  57735. * @returns the current Vector3
  57736. */
  57737. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  57738. /**
  57739. * Gets a new Vector3 set with the current Vector3 negated coordinates
  57740. * @returns a new Vector3
  57741. */
  57742. negate(): Vector3;
  57743. /**
  57744. * Multiplies the Vector3 coordinates by the float "scale"
  57745. * @param scale defines the multiplier factor
  57746. * @returns the current updated Vector3
  57747. */
  57748. scaleInPlace(scale: number): Vector3;
  57749. /**
  57750. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  57751. * @param scale defines the multiplier factor
  57752. * @returns a new Vector3
  57753. */
  57754. scale(scale: number): Vector3;
  57755. /**
  57756. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  57757. * @param scale defines the multiplier factor
  57758. * @param result defines the Vector3 object where to store the result
  57759. * @returns the current Vector3
  57760. */
  57761. scaleToRef(scale: number, result: Vector3): Vector3;
  57762. /**
  57763. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  57764. * @param scale defines the scale factor
  57765. * @param result defines the Vector3 object where to store the result
  57766. * @returns the unmodified current Vector3
  57767. */
  57768. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  57769. /**
  57770. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  57771. * @param otherVector defines the second operand
  57772. * @returns true if both vectors are equals
  57773. */
  57774. equals(otherVector: DeepImmutable<Vector3>): boolean;
  57775. /**
  57776. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  57777. * @param otherVector defines the second operand
  57778. * @param epsilon defines the minimal distance to define values as equals
  57779. * @returns true if both vectors are distant less than epsilon
  57780. */
  57781. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  57782. /**
  57783. * Returns true if the current Vector3 coordinates equals the given floats
  57784. * @param x defines the x coordinate of the operand
  57785. * @param y defines the y coordinate of the operand
  57786. * @param z defines the z coordinate of the operand
  57787. * @returns true if both vectors are equals
  57788. */
  57789. equalsToFloats(x: number, y: number, z: number): boolean;
  57790. /**
  57791. * Multiplies the current Vector3 coordinates by the given ones
  57792. * @param otherVector defines the second operand
  57793. * @returns the current updated Vector3
  57794. */
  57795. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  57796. /**
  57797. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  57798. * @param otherVector defines the second operand
  57799. * @returns the new Vector3
  57800. */
  57801. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  57802. /**
  57803. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  57804. * @param otherVector defines the second operand
  57805. * @param result defines the Vector3 object where to store the result
  57806. * @returns the current Vector3
  57807. */
  57808. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57809. /**
  57810. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  57811. * @param x defines the x coordinate of the operand
  57812. * @param y defines the y coordinate of the operand
  57813. * @param z defines the z coordinate of the operand
  57814. * @returns the new Vector3
  57815. */
  57816. multiplyByFloats(x: number, y: number, z: number): Vector3;
  57817. /**
  57818. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  57819. * @param otherVector defines the second operand
  57820. * @returns the new Vector3
  57821. */
  57822. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  57823. /**
  57824. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  57825. * @param otherVector defines the second operand
  57826. * @param result defines the Vector3 object where to store the result
  57827. * @returns the current Vector3
  57828. */
  57829. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  57830. /**
  57831. * Divides the current Vector3 coordinates by the given ones.
  57832. * @param otherVector defines the second operand
  57833. * @returns the current updated Vector3
  57834. */
  57835. divideInPlace(otherVector: Vector3): Vector3;
  57836. /**
  57837. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  57838. * @param other defines the second operand
  57839. * @returns the current updated Vector3
  57840. */
  57841. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57842. /**
  57843. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  57844. * @param other defines the second operand
  57845. * @returns the current updated Vector3
  57846. */
  57847. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  57848. /**
  57849. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  57850. * @param x defines the x coordinate of the operand
  57851. * @param y defines the y coordinate of the operand
  57852. * @param z defines the z coordinate of the operand
  57853. * @returns the current updated Vector3
  57854. */
  57855. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57856. /**
  57857. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  57858. * @param x defines the x coordinate of the operand
  57859. * @param y defines the y coordinate of the operand
  57860. * @param z defines the z coordinate of the operand
  57861. * @returns the current updated Vector3
  57862. */
  57863. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  57864. /**
  57865. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  57866. * Check if is non uniform within a certain amount of decimal places to account for this
  57867. * @param epsilon the amount the values can differ
  57868. * @returns if the the vector is non uniform to a certain number of decimal places
  57869. */
  57870. isNonUniformWithinEpsilon(epsilon: number): boolean;
  57871. /**
  57872. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  57873. */
  57874. readonly isNonUniform: boolean;
  57875. /**
  57876. * Gets a new Vector3 from current Vector3 floored values
  57877. * @returns a new Vector3
  57878. */
  57879. floor(): Vector3;
  57880. /**
  57881. * Gets a new Vector3 from current Vector3 floored values
  57882. * @returns a new Vector3
  57883. */
  57884. fract(): Vector3;
  57885. /**
  57886. * Gets the length of the Vector3
  57887. * @returns the length of the Vecto3
  57888. */
  57889. length(): number;
  57890. /**
  57891. * Gets the squared length of the Vector3
  57892. * @returns squared length of the Vector3
  57893. */
  57894. lengthSquared(): number;
  57895. /**
  57896. * Normalize the current Vector3.
  57897. * Please note that this is an in place operation.
  57898. * @returns the current updated Vector3
  57899. */
  57900. normalize(): Vector3;
  57901. /**
  57902. * Reorders the x y z properties of the vector in place
  57903. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  57904. * @returns the current updated vector
  57905. */
  57906. reorderInPlace(order: string): this;
  57907. /**
  57908. * Rotates the vector around 0,0,0 by a quaternion
  57909. * @param quaternion the rotation quaternion
  57910. * @param result vector to store the result
  57911. * @returns the resulting vector
  57912. */
  57913. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  57914. /**
  57915. * Rotates a vector around a given point
  57916. * @param quaternion the rotation quaternion
  57917. * @param point the point to rotate around
  57918. * @param result vector to store the result
  57919. * @returns the resulting vector
  57920. */
  57921. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  57922. /**
  57923. * Normalize the current Vector3 with the given input length.
  57924. * Please note that this is an in place operation.
  57925. * @param len the length of the vector
  57926. * @returns the current updated Vector3
  57927. */
  57928. normalizeFromLength(len: number): Vector3;
  57929. /**
  57930. * Normalize the current Vector3 to a new vector
  57931. * @returns the new Vector3
  57932. */
  57933. normalizeToNew(): Vector3;
  57934. /**
  57935. * Normalize the current Vector3 to the reference
  57936. * @param reference define the Vector3 to update
  57937. * @returns the updated Vector3
  57938. */
  57939. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  57940. /**
  57941. * Creates a new Vector3 copied from the current Vector3
  57942. * @returns the new Vector3
  57943. */
  57944. clone(): Vector3;
  57945. /**
  57946. * Copies the given vector coordinates to the current Vector3 ones
  57947. * @param source defines the source Vector3
  57948. * @returns the current updated Vector3
  57949. */
  57950. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  57951. /**
  57952. * Copies the given floats to the current Vector3 coordinates
  57953. * @param x defines the x coordinate of the operand
  57954. * @param y defines the y coordinate of the operand
  57955. * @param z defines the z coordinate of the operand
  57956. * @returns the current updated Vector3
  57957. */
  57958. copyFromFloats(x: number, y: number, z: number): Vector3;
  57959. /**
  57960. * Copies the given floats to the current Vector3 coordinates
  57961. * @param x defines the x coordinate of the operand
  57962. * @param y defines the y coordinate of the operand
  57963. * @param z defines the z coordinate of the operand
  57964. * @returns the current updated Vector3
  57965. */
  57966. set(x: number, y: number, z: number): Vector3;
  57967. /**
  57968. * Copies the given float to the current Vector3 coordinates
  57969. * @param v defines the x, y and z coordinates of the operand
  57970. * @returns the current updated Vector3
  57971. */
  57972. setAll(v: number): Vector3;
  57973. /**
  57974. * Get the clip factor between two vectors
  57975. * @param vector0 defines the first operand
  57976. * @param vector1 defines the second operand
  57977. * @param axis defines the axis to use
  57978. * @param size defines the size along the axis
  57979. * @returns the clip factor
  57980. */
  57981. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  57982. /**
  57983. * Get angle between two vectors
  57984. * @param vector0 angle between vector0 and vector1
  57985. * @param vector1 angle between vector0 and vector1
  57986. * @param normal direction of the normal
  57987. * @return the angle between vector0 and vector1
  57988. */
  57989. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  57990. /**
  57991. * Returns a new Vector3 set from the index "offset" of the given array
  57992. * @param array defines the source array
  57993. * @param offset defines the offset in the source array
  57994. * @returns the new Vector3
  57995. */
  57996. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  57997. /**
  57998. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  57999. * This function is deprecated. Use FromArray instead
  58000. * @param array defines the source array
  58001. * @param offset defines the offset in the source array
  58002. * @returns the new Vector3
  58003. */
  58004. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  58005. /**
  58006. * Sets the given vector "result" with the element values from the index "offset" of the given array
  58007. * @param array defines the source array
  58008. * @param offset defines the offset in the source array
  58009. * @param result defines the Vector3 where to store the result
  58010. */
  58011. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  58012. /**
  58013. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  58014. * This function is deprecated. Use FromArrayToRef instead.
  58015. * @param array defines the source array
  58016. * @param offset defines the offset in the source array
  58017. * @param result defines the Vector3 where to store the result
  58018. */
  58019. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  58020. /**
  58021. * Sets the given vector "result" with the given floats.
  58022. * @param x defines the x coordinate of the source
  58023. * @param y defines the y coordinate of the source
  58024. * @param z defines the z coordinate of the source
  58025. * @param result defines the Vector3 where to store the result
  58026. */
  58027. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  58028. /**
  58029. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  58030. * @returns a new empty Vector3
  58031. */
  58032. static Zero(): Vector3;
  58033. /**
  58034. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  58035. * @returns a new unit Vector3
  58036. */
  58037. static One(): Vector3;
  58038. /**
  58039. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  58040. * @returns a new up Vector3
  58041. */
  58042. static Up(): Vector3;
  58043. /**
  58044. * Gets a up Vector3 that must not be updated
  58045. */
  58046. static readonly UpReadOnly: DeepImmutable<Vector3>;
  58047. /**
  58048. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  58049. * @returns a new down Vector3
  58050. */
  58051. static Down(): Vector3;
  58052. /**
  58053. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  58054. * @returns a new forward Vector3
  58055. */
  58056. static Forward(): Vector3;
  58057. /**
  58058. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  58059. * @returns a new forward Vector3
  58060. */
  58061. static Backward(): Vector3;
  58062. /**
  58063. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  58064. * @returns a new right Vector3
  58065. */
  58066. static Right(): Vector3;
  58067. /**
  58068. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  58069. * @returns a new left Vector3
  58070. */
  58071. static Left(): Vector3;
  58072. /**
  58073. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  58074. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58075. * @param vector defines the Vector3 to transform
  58076. * @param transformation defines the transformation matrix
  58077. * @returns the transformed Vector3
  58078. */
  58079. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58080. /**
  58081. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  58082. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  58083. * @param vector defines the Vector3 to transform
  58084. * @param transformation defines the transformation matrix
  58085. * @param result defines the Vector3 where to store the result
  58086. */
  58087. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58088. /**
  58089. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  58090. * This method computes tranformed coordinates only, not transformed direction vectors
  58091. * @param x define the x coordinate of the source vector
  58092. * @param y define the y coordinate of the source vector
  58093. * @param z define the z coordinate of the source vector
  58094. * @param transformation defines the transformation matrix
  58095. * @param result defines the Vector3 where to store the result
  58096. */
  58097. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58098. /**
  58099. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  58100. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58101. * @param vector defines the Vector3 to transform
  58102. * @param transformation defines the transformation matrix
  58103. * @returns the new Vector3
  58104. */
  58105. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  58106. /**
  58107. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  58108. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58109. * @param vector defines the Vector3 to transform
  58110. * @param transformation defines the transformation matrix
  58111. * @param result defines the Vector3 where to store the result
  58112. */
  58113. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58114. /**
  58115. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  58116. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  58117. * @param x define the x coordinate of the source vector
  58118. * @param y define the y coordinate of the source vector
  58119. * @param z define the z coordinate of the source vector
  58120. * @param transformation defines the transformation matrix
  58121. * @param result defines the Vector3 where to store the result
  58122. */
  58123. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  58124. /**
  58125. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  58126. * @param value1 defines the first control point
  58127. * @param value2 defines the second control point
  58128. * @param value3 defines the third control point
  58129. * @param value4 defines the fourth control point
  58130. * @param amount defines the amount on the spline to use
  58131. * @returns the new Vector3
  58132. */
  58133. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  58134. /**
  58135. * 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"
  58136. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58137. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58138. * @param value defines the current value
  58139. * @param min defines the lower range value
  58140. * @param max defines the upper range value
  58141. * @returns the new Vector3
  58142. */
  58143. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  58144. /**
  58145. * 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"
  58146. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  58147. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  58148. * @param value defines the current value
  58149. * @param min defines the lower range value
  58150. * @param max defines the upper range value
  58151. * @param result defines the Vector3 where to store the result
  58152. */
  58153. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  58154. /**
  58155. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  58156. * @param value1 defines the first control point
  58157. * @param tangent1 defines the first tangent vector
  58158. * @param value2 defines the second control point
  58159. * @param tangent2 defines the second tangent vector
  58160. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  58161. * @returns the new Vector3
  58162. */
  58163. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  58164. /**
  58165. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  58166. * @param start defines the start value
  58167. * @param end defines the end value
  58168. * @param amount max defines amount between both (between 0 and 1)
  58169. * @returns the new Vector3
  58170. */
  58171. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  58172. /**
  58173. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  58174. * @param start defines the start value
  58175. * @param end defines the end value
  58176. * @param amount max defines amount between both (between 0 and 1)
  58177. * @param result defines the Vector3 where to store the result
  58178. */
  58179. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  58180. /**
  58181. * Returns the dot product (float) between the vectors "left" and "right"
  58182. * @param left defines the left operand
  58183. * @param right defines the right operand
  58184. * @returns the dot product
  58185. */
  58186. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  58187. /**
  58188. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  58189. * The cross product is then orthogonal to both "left" and "right"
  58190. * @param left defines the left operand
  58191. * @param right defines the right operand
  58192. * @returns the cross product
  58193. */
  58194. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58195. /**
  58196. * Sets the given vector "result" with the cross product of "left" and "right"
  58197. * The cross product is then orthogonal to both "left" and "right"
  58198. * @param left defines the left operand
  58199. * @param right defines the right operand
  58200. * @param result defines the Vector3 where to store the result
  58201. */
  58202. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  58203. /**
  58204. * Returns a new Vector3 as the normalization of the given vector
  58205. * @param vector defines the Vector3 to normalize
  58206. * @returns the new Vector3
  58207. */
  58208. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  58209. /**
  58210. * Sets the given vector "result" with the normalization of the given first vector
  58211. * @param vector defines the Vector3 to normalize
  58212. * @param result defines the Vector3 where to store the result
  58213. */
  58214. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  58215. /**
  58216. * Project a Vector3 onto screen space
  58217. * @param vector defines the Vector3 to project
  58218. * @param world defines the world matrix to use
  58219. * @param transform defines the transform (view x projection) matrix to use
  58220. * @param viewport defines the screen viewport to use
  58221. * @returns the new Vector3
  58222. */
  58223. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  58224. /** @hidden */
  58225. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  58226. /**
  58227. * Unproject from screen space to object space
  58228. * @param source defines the screen space Vector3 to use
  58229. * @param viewportWidth defines the current width of the viewport
  58230. * @param viewportHeight defines the current height of the viewport
  58231. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58232. * @param transform defines the transform (view x projection) matrix to use
  58233. * @returns the new Vector3
  58234. */
  58235. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  58236. /**
  58237. * Unproject from screen space to object space
  58238. * @param source defines the screen space Vector3 to use
  58239. * @param viewportWidth defines the current width of the viewport
  58240. * @param viewportHeight defines the current height of the viewport
  58241. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58242. * @param view defines the view matrix to use
  58243. * @param projection defines the projection matrix to use
  58244. * @returns the new Vector3
  58245. */
  58246. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  58247. /**
  58248. * Unproject from screen space to object space
  58249. * @param source defines the screen space Vector3 to use
  58250. * @param viewportWidth defines the current width of the viewport
  58251. * @param viewportHeight defines the current height of the viewport
  58252. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58253. * @param view defines the view matrix to use
  58254. * @param projection defines the projection matrix to use
  58255. * @param result defines the Vector3 where to store the result
  58256. */
  58257. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58258. /**
  58259. * Unproject from screen space to object space
  58260. * @param sourceX defines the screen space x coordinate to use
  58261. * @param sourceY defines the screen space y coordinate to use
  58262. * @param sourceZ defines the screen space z coordinate to use
  58263. * @param viewportWidth defines the current width of the viewport
  58264. * @param viewportHeight defines the current height of the viewport
  58265. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  58266. * @param view defines the view matrix to use
  58267. * @param projection defines the projection matrix to use
  58268. * @param result defines the Vector3 where to store the result
  58269. */
  58270. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  58271. /**
  58272. * Gets the minimal coordinate values between two Vector3
  58273. * @param left defines the first operand
  58274. * @param right defines the second operand
  58275. * @returns the new Vector3
  58276. */
  58277. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58278. /**
  58279. * Gets the maximal coordinate values between two Vector3
  58280. * @param left defines the first operand
  58281. * @param right defines the second operand
  58282. * @returns the new Vector3
  58283. */
  58284. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  58285. /**
  58286. * Returns the distance between the vectors "value1" and "value2"
  58287. * @param value1 defines the first operand
  58288. * @param value2 defines the second operand
  58289. * @returns the distance
  58290. */
  58291. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58292. /**
  58293. * Returns the squared distance between the vectors "value1" and "value2"
  58294. * @param value1 defines the first operand
  58295. * @param value2 defines the second operand
  58296. * @returns the squared distance
  58297. */
  58298. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  58299. /**
  58300. * Returns a new Vector3 located at the center between "value1" and "value2"
  58301. * @param value1 defines the first operand
  58302. * @param value2 defines the second operand
  58303. * @returns the new Vector3
  58304. */
  58305. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  58306. /**
  58307. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  58308. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  58309. * to something in order to rotate it from its local system to the given target system
  58310. * Note: axis1, axis2 and axis3 are normalized during this operation
  58311. * @param axis1 defines the first axis
  58312. * @param axis2 defines the second axis
  58313. * @param axis3 defines the third axis
  58314. * @returns a new Vector3
  58315. */
  58316. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  58317. /**
  58318. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  58319. * @param axis1 defines the first axis
  58320. * @param axis2 defines the second axis
  58321. * @param axis3 defines the third axis
  58322. * @param ref defines the Vector3 where to store the result
  58323. */
  58324. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  58325. }
  58326. /**
  58327. * Vector4 class created for EulerAngle class conversion to Quaternion
  58328. */
  58329. export class Vector4 {
  58330. /** x value of the vector */
  58331. x: number;
  58332. /** y value of the vector */
  58333. y: number;
  58334. /** z value of the vector */
  58335. z: number;
  58336. /** w value of the vector */
  58337. w: number;
  58338. /**
  58339. * Creates a Vector4 object from the given floats.
  58340. * @param x x value of the vector
  58341. * @param y y value of the vector
  58342. * @param z z value of the vector
  58343. * @param w w value of the vector
  58344. */
  58345. constructor(
  58346. /** x value of the vector */
  58347. x: number,
  58348. /** y value of the vector */
  58349. y: number,
  58350. /** z value of the vector */
  58351. z: number,
  58352. /** w value of the vector */
  58353. w: number);
  58354. /**
  58355. * Returns the string with the Vector4 coordinates.
  58356. * @returns a string containing all the vector values
  58357. */
  58358. toString(): string;
  58359. /**
  58360. * Returns the string "Vector4".
  58361. * @returns "Vector4"
  58362. */
  58363. getClassName(): string;
  58364. /**
  58365. * Returns the Vector4 hash code.
  58366. * @returns a unique hash code
  58367. */
  58368. getHashCode(): number;
  58369. /**
  58370. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  58371. * @returns the resulting array
  58372. */
  58373. asArray(): number[];
  58374. /**
  58375. * Populates the given array from the given index with the Vector4 coordinates.
  58376. * @param array array to populate
  58377. * @param index index of the array to start at (default: 0)
  58378. * @returns the Vector4.
  58379. */
  58380. toArray(array: FloatArray, index?: number): Vector4;
  58381. /**
  58382. * Adds the given vector to the current Vector4.
  58383. * @param otherVector the vector to add
  58384. * @returns the updated Vector4.
  58385. */
  58386. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58387. /**
  58388. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  58389. * @param otherVector the vector to add
  58390. * @returns the resulting vector
  58391. */
  58392. add(otherVector: DeepImmutable<Vector4>): Vector4;
  58393. /**
  58394. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  58395. * @param otherVector the vector to add
  58396. * @param result the vector to store the result
  58397. * @returns the current Vector4.
  58398. */
  58399. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58400. /**
  58401. * Subtract in place the given vector from the current Vector4.
  58402. * @param otherVector the vector to subtract
  58403. * @returns the updated Vector4.
  58404. */
  58405. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58406. /**
  58407. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  58408. * @param otherVector the vector to add
  58409. * @returns the new vector with the result
  58410. */
  58411. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  58412. /**
  58413. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  58414. * @param otherVector the vector to subtract
  58415. * @param result the vector to store the result
  58416. * @returns the current Vector4.
  58417. */
  58418. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58419. /**
  58420. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58421. */
  58422. /**
  58423. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58424. * @param x value to subtract
  58425. * @param y value to subtract
  58426. * @param z value to subtract
  58427. * @param w value to subtract
  58428. * @returns new vector containing the result
  58429. */
  58430. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58431. /**
  58432. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  58433. * @param x value to subtract
  58434. * @param y value to subtract
  58435. * @param z value to subtract
  58436. * @param w value to subtract
  58437. * @param result the vector to store the result in
  58438. * @returns the current Vector4.
  58439. */
  58440. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  58441. /**
  58442. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  58443. * @returns a new vector with the negated values
  58444. */
  58445. negate(): Vector4;
  58446. /**
  58447. * Multiplies the current Vector4 coordinates by scale (float).
  58448. * @param scale the number to scale with
  58449. * @returns the updated Vector4.
  58450. */
  58451. scaleInPlace(scale: number): Vector4;
  58452. /**
  58453. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  58454. * @param scale the number to scale with
  58455. * @returns a new vector with the result
  58456. */
  58457. scale(scale: number): Vector4;
  58458. /**
  58459. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  58460. * @param scale the number to scale with
  58461. * @param result a vector to store the result in
  58462. * @returns the current Vector4.
  58463. */
  58464. scaleToRef(scale: number, result: Vector4): Vector4;
  58465. /**
  58466. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  58467. * @param scale defines the scale factor
  58468. * @param result defines the Vector4 object where to store the result
  58469. * @returns the unmodified current Vector4
  58470. */
  58471. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  58472. /**
  58473. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  58474. * @param otherVector the vector to compare against
  58475. * @returns true if they are equal
  58476. */
  58477. equals(otherVector: DeepImmutable<Vector4>): boolean;
  58478. /**
  58479. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  58480. * @param otherVector vector to compare against
  58481. * @param epsilon (Default: very small number)
  58482. * @returns true if they are equal
  58483. */
  58484. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  58485. /**
  58486. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  58487. * @param x x value to compare against
  58488. * @param y y value to compare against
  58489. * @param z z value to compare against
  58490. * @param w w value to compare against
  58491. * @returns true if equal
  58492. */
  58493. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  58494. /**
  58495. * Multiplies in place the current Vector4 by the given one.
  58496. * @param otherVector vector to multiple with
  58497. * @returns the updated Vector4.
  58498. */
  58499. multiplyInPlace(otherVector: Vector4): Vector4;
  58500. /**
  58501. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  58502. * @param otherVector vector to multiple with
  58503. * @returns resulting new vector
  58504. */
  58505. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  58506. /**
  58507. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  58508. * @param otherVector vector to multiple with
  58509. * @param result vector to store the result
  58510. * @returns the current Vector4.
  58511. */
  58512. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58513. /**
  58514. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  58515. * @param x x value multiply with
  58516. * @param y y value multiply with
  58517. * @param z z value multiply with
  58518. * @param w w value multiply with
  58519. * @returns resulting new vector
  58520. */
  58521. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  58522. /**
  58523. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  58524. * @param otherVector vector to devide with
  58525. * @returns resulting new vector
  58526. */
  58527. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  58528. /**
  58529. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  58530. * @param otherVector vector to devide with
  58531. * @param result vector to store the result
  58532. * @returns the current Vector4.
  58533. */
  58534. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  58535. /**
  58536. * Divides the current Vector3 coordinates by the given ones.
  58537. * @param otherVector vector to devide with
  58538. * @returns the updated Vector3.
  58539. */
  58540. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  58541. /**
  58542. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  58543. * @param other defines the second operand
  58544. * @returns the current updated Vector4
  58545. */
  58546. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58547. /**
  58548. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  58549. * @param other defines the second operand
  58550. * @returns the current updated Vector4
  58551. */
  58552. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  58553. /**
  58554. * Gets a new Vector4 from current Vector4 floored values
  58555. * @returns a new Vector4
  58556. */
  58557. floor(): Vector4;
  58558. /**
  58559. * Gets a new Vector4 from current Vector3 floored values
  58560. * @returns a new Vector4
  58561. */
  58562. fract(): Vector4;
  58563. /**
  58564. * Returns the Vector4 length (float).
  58565. * @returns the length
  58566. */
  58567. length(): number;
  58568. /**
  58569. * Returns the Vector4 squared length (float).
  58570. * @returns the length squared
  58571. */
  58572. lengthSquared(): number;
  58573. /**
  58574. * Normalizes in place the Vector4.
  58575. * @returns the updated Vector4.
  58576. */
  58577. normalize(): Vector4;
  58578. /**
  58579. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  58580. * @returns this converted to a new vector3
  58581. */
  58582. toVector3(): Vector3;
  58583. /**
  58584. * Returns a new Vector4 copied from the current one.
  58585. * @returns the new cloned vector
  58586. */
  58587. clone(): Vector4;
  58588. /**
  58589. * Updates the current Vector4 with the given one coordinates.
  58590. * @param source the source vector to copy from
  58591. * @returns the updated Vector4.
  58592. */
  58593. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  58594. /**
  58595. * Updates the current Vector4 coordinates with the given floats.
  58596. * @param x float to copy from
  58597. * @param y float to copy from
  58598. * @param z float to copy from
  58599. * @param w float to copy from
  58600. * @returns the updated Vector4.
  58601. */
  58602. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  58603. /**
  58604. * Updates the current Vector4 coordinates with the given floats.
  58605. * @param x float to set from
  58606. * @param y float to set from
  58607. * @param z float to set from
  58608. * @param w float to set from
  58609. * @returns the updated Vector4.
  58610. */
  58611. set(x: number, y: number, z: number, w: number): Vector4;
  58612. /**
  58613. * Copies the given float to the current Vector3 coordinates
  58614. * @param v defines the x, y, z and w coordinates of the operand
  58615. * @returns the current updated Vector3
  58616. */
  58617. setAll(v: number): Vector4;
  58618. /**
  58619. * Returns a new Vector4 set from the starting index of the given array.
  58620. * @param array the array to pull values from
  58621. * @param offset the offset into the array to start at
  58622. * @returns the new vector
  58623. */
  58624. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  58625. /**
  58626. * Updates the given vector "result" from the starting index of the given array.
  58627. * @param array the array to pull values from
  58628. * @param offset the offset into the array to start at
  58629. * @param result the vector to store the result in
  58630. */
  58631. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  58632. /**
  58633. * Updates the given vector "result" from the starting index of the given Float32Array.
  58634. * @param array the array to pull values from
  58635. * @param offset the offset into the array to start at
  58636. * @param result the vector to store the result in
  58637. */
  58638. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  58639. /**
  58640. * Updates the given vector "result" coordinates from the given floats.
  58641. * @param x float to set from
  58642. * @param y float to set from
  58643. * @param z float to set from
  58644. * @param w float to set from
  58645. * @param result the vector to the floats in
  58646. */
  58647. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  58648. /**
  58649. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  58650. * @returns the new vector
  58651. */
  58652. static Zero(): Vector4;
  58653. /**
  58654. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  58655. * @returns the new vector
  58656. */
  58657. static One(): Vector4;
  58658. /**
  58659. * Returns a new normalized Vector4 from the given one.
  58660. * @param vector the vector to normalize
  58661. * @returns the vector
  58662. */
  58663. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  58664. /**
  58665. * Updates the given vector "result" from the normalization of the given one.
  58666. * @param vector the vector to normalize
  58667. * @param result the vector to store the result in
  58668. */
  58669. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  58670. /**
  58671. * Returns a vector with the minimum values from the left and right vectors
  58672. * @param left left vector to minimize
  58673. * @param right right vector to minimize
  58674. * @returns a new vector with the minimum of the left and right vector values
  58675. */
  58676. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58677. /**
  58678. * Returns a vector with the maximum values from the left and right vectors
  58679. * @param left left vector to maximize
  58680. * @param right right vector to maximize
  58681. * @returns a new vector with the maximum of the left and right vector values
  58682. */
  58683. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  58684. /**
  58685. * Returns the distance (float) between the vectors "value1" and "value2".
  58686. * @param value1 value to calulate the distance between
  58687. * @param value2 value to calulate the distance between
  58688. * @return the distance between the two vectors
  58689. */
  58690. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58691. /**
  58692. * Returns the squared distance (float) between the vectors "value1" and "value2".
  58693. * @param value1 value to calulate the distance between
  58694. * @param value2 value to calulate the distance between
  58695. * @return the distance between the two vectors squared
  58696. */
  58697. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  58698. /**
  58699. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  58700. * @param value1 value to calulate the center between
  58701. * @param value2 value to calulate the center between
  58702. * @return the center between the two vectors
  58703. */
  58704. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  58705. /**
  58706. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  58707. * This methods computes transformed normalized direction vectors only.
  58708. * @param vector the vector to transform
  58709. * @param transformation the transformation matrix to apply
  58710. * @returns the new vector
  58711. */
  58712. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  58713. /**
  58714. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  58715. * This methods computes transformed normalized direction vectors only.
  58716. * @param vector the vector to transform
  58717. * @param transformation the transformation matrix to apply
  58718. * @param result the vector to store the result in
  58719. */
  58720. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58721. /**
  58722. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  58723. * This methods computes transformed normalized direction vectors only.
  58724. * @param x value to transform
  58725. * @param y value to transform
  58726. * @param z value to transform
  58727. * @param w value to transform
  58728. * @param transformation the transformation matrix to apply
  58729. * @param result the vector to store the results in
  58730. */
  58731. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  58732. /**
  58733. * Creates a new Vector4 from a Vector3
  58734. * @param source defines the source data
  58735. * @param w defines the 4th component (default is 0)
  58736. * @returns a new Vector4
  58737. */
  58738. static FromVector3(source: Vector3, w?: number): Vector4;
  58739. }
  58740. /**
  58741. * Interface for the size containing width and height
  58742. */
  58743. export interface ISize {
  58744. /**
  58745. * Width
  58746. */
  58747. width: number;
  58748. /**
  58749. * Heighht
  58750. */
  58751. height: number;
  58752. }
  58753. /**
  58754. * Size containing widht and height
  58755. */
  58756. export class Size implements ISize {
  58757. /**
  58758. * Width
  58759. */
  58760. width: number;
  58761. /**
  58762. * Height
  58763. */
  58764. height: number;
  58765. /**
  58766. * Creates a Size object from the given width and height (floats).
  58767. * @param width width of the new size
  58768. * @param height height of the new size
  58769. */
  58770. constructor(width: number, height: number);
  58771. /**
  58772. * Returns a string with the Size width and height
  58773. * @returns a string with the Size width and height
  58774. */
  58775. toString(): string;
  58776. /**
  58777. * "Size"
  58778. * @returns the string "Size"
  58779. */
  58780. getClassName(): string;
  58781. /**
  58782. * Returns the Size hash code.
  58783. * @returns a hash code for a unique width and height
  58784. */
  58785. getHashCode(): number;
  58786. /**
  58787. * Updates the current size from the given one.
  58788. * @param src the given size
  58789. */
  58790. copyFrom(src: Size): void;
  58791. /**
  58792. * Updates in place the current Size from the given floats.
  58793. * @param width width of the new size
  58794. * @param height height of the new size
  58795. * @returns the updated Size.
  58796. */
  58797. copyFromFloats(width: number, height: number): Size;
  58798. /**
  58799. * Updates in place the current Size from the given floats.
  58800. * @param width width to set
  58801. * @param height height to set
  58802. * @returns the updated Size.
  58803. */
  58804. set(width: number, height: number): Size;
  58805. /**
  58806. * Multiplies the width and height by numbers
  58807. * @param w factor to multiple the width by
  58808. * @param h factor to multiple the height by
  58809. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  58810. */
  58811. multiplyByFloats(w: number, h: number): Size;
  58812. /**
  58813. * Clones the size
  58814. * @returns a new Size copied from the given one.
  58815. */
  58816. clone(): Size;
  58817. /**
  58818. * True if the current Size and the given one width and height are strictly equal.
  58819. * @param other the other size to compare against
  58820. * @returns True if the current Size and the given one width and height are strictly equal.
  58821. */
  58822. equals(other: Size): boolean;
  58823. /**
  58824. * The surface of the Size : width * height (float).
  58825. */
  58826. readonly surface: number;
  58827. /**
  58828. * Create a new size of zero
  58829. * @returns a new Size set to (0.0, 0.0)
  58830. */
  58831. static Zero(): Size;
  58832. /**
  58833. * Sums the width and height of two sizes
  58834. * @param otherSize size to add to this size
  58835. * @returns a new Size set as the addition result of the current Size and the given one.
  58836. */
  58837. add(otherSize: Size): Size;
  58838. /**
  58839. * Subtracts the width and height of two
  58840. * @param otherSize size to subtract to this size
  58841. * @returns a new Size set as the subtraction result of the given one from the current Size.
  58842. */
  58843. subtract(otherSize: Size): Size;
  58844. /**
  58845. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  58846. * @param start starting size to lerp between
  58847. * @param end end size to lerp between
  58848. * @param amount amount to lerp between the start and end values
  58849. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  58850. */
  58851. static Lerp(start: Size, end: Size, amount: number): Size;
  58852. }
  58853. /**
  58854. * Class used to store quaternion data
  58855. * @see https://en.wikipedia.org/wiki/Quaternion
  58856. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  58857. */
  58858. export class Quaternion {
  58859. /** defines the first component (0 by default) */
  58860. x: number;
  58861. /** defines the second component (0 by default) */
  58862. y: number;
  58863. /** defines the third component (0 by default) */
  58864. z: number;
  58865. /** defines the fourth component (1.0 by default) */
  58866. w: number;
  58867. /**
  58868. * Creates a new Quaternion from the given floats
  58869. * @param x defines the first component (0 by default)
  58870. * @param y defines the second component (0 by default)
  58871. * @param z defines the third component (0 by default)
  58872. * @param w defines the fourth component (1.0 by default)
  58873. */
  58874. constructor(
  58875. /** defines the first component (0 by default) */
  58876. x?: number,
  58877. /** defines the second component (0 by default) */
  58878. y?: number,
  58879. /** defines the third component (0 by default) */
  58880. z?: number,
  58881. /** defines the fourth component (1.0 by default) */
  58882. w?: number);
  58883. /**
  58884. * Gets a string representation for the current quaternion
  58885. * @returns a string with the Quaternion coordinates
  58886. */
  58887. toString(): string;
  58888. /**
  58889. * Gets the class name of the quaternion
  58890. * @returns the string "Quaternion"
  58891. */
  58892. getClassName(): string;
  58893. /**
  58894. * Gets a hash code for this quaternion
  58895. * @returns the quaternion hash code
  58896. */
  58897. getHashCode(): number;
  58898. /**
  58899. * Copy the quaternion to an array
  58900. * @returns a new array populated with 4 elements from the quaternion coordinates
  58901. */
  58902. asArray(): number[];
  58903. /**
  58904. * Check if two quaternions are equals
  58905. * @param otherQuaternion defines the second operand
  58906. * @return true if the current quaternion and the given one coordinates are strictly equals
  58907. */
  58908. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  58909. /**
  58910. * Clone the current quaternion
  58911. * @returns a new quaternion copied from the current one
  58912. */
  58913. clone(): Quaternion;
  58914. /**
  58915. * Copy a quaternion to the current one
  58916. * @param other defines the other quaternion
  58917. * @returns the updated current quaternion
  58918. */
  58919. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  58920. /**
  58921. * Updates the current quaternion with the given float coordinates
  58922. * @param x defines the x coordinate
  58923. * @param y defines the y coordinate
  58924. * @param z defines the z coordinate
  58925. * @param w defines the w coordinate
  58926. * @returns the updated current quaternion
  58927. */
  58928. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  58929. /**
  58930. * Updates the current quaternion from the given float coordinates
  58931. * @param x defines the x coordinate
  58932. * @param y defines the y coordinate
  58933. * @param z defines the z coordinate
  58934. * @param w defines the w coordinate
  58935. * @returns the updated current quaternion
  58936. */
  58937. set(x: number, y: number, z: number, w: number): Quaternion;
  58938. /**
  58939. * Adds two quaternions
  58940. * @param other defines the second operand
  58941. * @returns a new quaternion as the addition result of the given one and the current quaternion
  58942. */
  58943. add(other: DeepImmutable<Quaternion>): Quaternion;
  58944. /**
  58945. * Add a quaternion to the current one
  58946. * @param other defines the quaternion to add
  58947. * @returns the current quaternion
  58948. */
  58949. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  58950. /**
  58951. * Subtract two quaternions
  58952. * @param other defines the second operand
  58953. * @returns a new quaternion as the subtraction result of the given one from the current one
  58954. */
  58955. subtract(other: Quaternion): Quaternion;
  58956. /**
  58957. * Multiplies the current quaternion by a scale factor
  58958. * @param value defines the scale factor
  58959. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  58960. */
  58961. scale(value: number): Quaternion;
  58962. /**
  58963. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  58964. * @param scale defines the scale factor
  58965. * @param result defines the Quaternion object where to store the result
  58966. * @returns the unmodified current quaternion
  58967. */
  58968. scaleToRef(scale: number, result: Quaternion): Quaternion;
  58969. /**
  58970. * Multiplies in place the current quaternion by a scale factor
  58971. * @param value defines the scale factor
  58972. * @returns the current modified quaternion
  58973. */
  58974. scaleInPlace(value: number): Quaternion;
  58975. /**
  58976. * Scale the current quaternion values by a factor and add the result to a given quaternion
  58977. * @param scale defines the scale factor
  58978. * @param result defines the Quaternion object where to store the result
  58979. * @returns the unmodified current quaternion
  58980. */
  58981. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  58982. /**
  58983. * Multiplies two quaternions
  58984. * @param q1 defines the second operand
  58985. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  58986. */
  58987. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  58988. /**
  58989. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  58990. * @param q1 defines the second operand
  58991. * @param result defines the target quaternion
  58992. * @returns the current quaternion
  58993. */
  58994. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  58995. /**
  58996. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  58997. * @param q1 defines the second operand
  58998. * @returns the currentupdated quaternion
  58999. */
  59000. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  59001. /**
  59002. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  59003. * @param ref defines the target quaternion
  59004. * @returns the current quaternion
  59005. */
  59006. conjugateToRef(ref: Quaternion): Quaternion;
  59007. /**
  59008. * Conjugates in place (1-q) the current quaternion
  59009. * @returns the current updated quaternion
  59010. */
  59011. conjugateInPlace(): Quaternion;
  59012. /**
  59013. * Conjugates in place (1-q) the current quaternion
  59014. * @returns a new quaternion
  59015. */
  59016. conjugate(): Quaternion;
  59017. /**
  59018. * Gets length of current quaternion
  59019. * @returns the quaternion length (float)
  59020. */
  59021. length(): number;
  59022. /**
  59023. * Normalize in place the current quaternion
  59024. * @returns the current updated quaternion
  59025. */
  59026. normalize(): Quaternion;
  59027. /**
  59028. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  59029. * @param order is a reserved parameter and is ignore for now
  59030. * @returns a new Vector3 containing the Euler angles
  59031. */
  59032. toEulerAngles(order?: string): Vector3;
  59033. /**
  59034. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  59035. * @param result defines the vector which will be filled with the Euler angles
  59036. * @param order is a reserved parameter and is ignore for now
  59037. * @returns the current unchanged quaternion
  59038. */
  59039. toEulerAnglesToRef(result: Vector3): Quaternion;
  59040. /**
  59041. * Updates the given rotation matrix with the current quaternion values
  59042. * @param result defines the target matrix
  59043. * @returns the current unchanged quaternion
  59044. */
  59045. toRotationMatrix(result: Matrix): Quaternion;
  59046. /**
  59047. * Updates the current quaternion from the given rotation matrix values
  59048. * @param matrix defines the source matrix
  59049. * @returns the current updated quaternion
  59050. */
  59051. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59052. /**
  59053. * Creates a new quaternion from a rotation matrix
  59054. * @param matrix defines the source matrix
  59055. * @returns a new quaternion created from the given rotation matrix values
  59056. */
  59057. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  59058. /**
  59059. * Updates the given quaternion with the given rotation matrix values
  59060. * @param matrix defines the source matrix
  59061. * @param result defines the target quaternion
  59062. */
  59063. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  59064. /**
  59065. * Returns the dot product (float) between the quaternions "left" and "right"
  59066. * @param left defines the left operand
  59067. * @param right defines the right operand
  59068. * @returns the dot product
  59069. */
  59070. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  59071. /**
  59072. * Checks if the two quaternions are close to each other
  59073. * @param quat0 defines the first quaternion to check
  59074. * @param quat1 defines the second quaternion to check
  59075. * @returns true if the two quaternions are close to each other
  59076. */
  59077. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  59078. /**
  59079. * Creates an empty quaternion
  59080. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  59081. */
  59082. static Zero(): Quaternion;
  59083. /**
  59084. * Inverse a given quaternion
  59085. * @param q defines the source quaternion
  59086. * @returns a new quaternion as the inverted current quaternion
  59087. */
  59088. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  59089. /**
  59090. * Inverse a given quaternion
  59091. * @param q defines the source quaternion
  59092. * @param result the quaternion the result will be stored in
  59093. * @returns the result quaternion
  59094. */
  59095. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  59096. /**
  59097. * Creates an identity quaternion
  59098. * @returns the identity quaternion
  59099. */
  59100. static Identity(): Quaternion;
  59101. /**
  59102. * Gets a boolean indicating if the given quaternion is identity
  59103. * @param quaternion defines the quaternion to check
  59104. * @returns true if the quaternion is identity
  59105. */
  59106. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  59107. /**
  59108. * Creates a quaternion from a rotation around an axis
  59109. * @param axis defines the axis to use
  59110. * @param angle defines the angle to use
  59111. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  59112. */
  59113. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  59114. /**
  59115. * Creates a rotation around an axis and stores it into the given quaternion
  59116. * @param axis defines the axis to use
  59117. * @param angle defines the angle to use
  59118. * @param result defines the target quaternion
  59119. * @returns the target quaternion
  59120. */
  59121. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  59122. /**
  59123. * Creates a new quaternion from data stored into an array
  59124. * @param array defines the data source
  59125. * @param offset defines the offset in the source array where the data starts
  59126. * @returns a new quaternion
  59127. */
  59128. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  59129. /**
  59130. * Create a quaternion from Euler rotation angles
  59131. * @param x Pitch
  59132. * @param y Yaw
  59133. * @param z Roll
  59134. * @returns the new Quaternion
  59135. */
  59136. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  59137. /**
  59138. * Updates a quaternion from Euler rotation angles
  59139. * @param x Pitch
  59140. * @param y Yaw
  59141. * @param z Roll
  59142. * @param result the quaternion to store the result
  59143. * @returns the updated quaternion
  59144. */
  59145. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  59146. /**
  59147. * Create a quaternion from Euler rotation vector
  59148. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59149. * @returns the new Quaternion
  59150. */
  59151. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  59152. /**
  59153. * Updates a quaternion from Euler rotation vector
  59154. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  59155. * @param result the quaternion to store the result
  59156. * @returns the updated quaternion
  59157. */
  59158. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  59159. /**
  59160. * Creates a new quaternion from the given Euler float angles (y, x, z)
  59161. * @param yaw defines the rotation around Y axis
  59162. * @param pitch defines the rotation around X axis
  59163. * @param roll defines the rotation around Z axis
  59164. * @returns the new quaternion
  59165. */
  59166. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  59167. /**
  59168. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  59169. * @param yaw defines the rotation around Y axis
  59170. * @param pitch defines the rotation around X axis
  59171. * @param roll defines the rotation around Z axis
  59172. * @param result defines the target quaternion
  59173. */
  59174. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  59175. /**
  59176. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  59177. * @param alpha defines the rotation around first axis
  59178. * @param beta defines the rotation around second axis
  59179. * @param gamma defines the rotation around third axis
  59180. * @returns the new quaternion
  59181. */
  59182. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  59183. /**
  59184. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  59185. * @param alpha defines the rotation around first axis
  59186. * @param beta defines the rotation around second axis
  59187. * @param gamma defines the rotation around third axis
  59188. * @param result defines the target quaternion
  59189. */
  59190. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  59191. /**
  59192. * 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)
  59193. * @param axis1 defines the first axis
  59194. * @param axis2 defines the second axis
  59195. * @param axis3 defines the third axis
  59196. * @returns the new quaternion
  59197. */
  59198. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  59199. /**
  59200. * 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
  59201. * @param axis1 defines the first axis
  59202. * @param axis2 defines the second axis
  59203. * @param axis3 defines the third axis
  59204. * @param ref defines the target quaternion
  59205. */
  59206. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  59207. /**
  59208. * Interpolates between two quaternions
  59209. * @param left defines first quaternion
  59210. * @param right defines second quaternion
  59211. * @param amount defines the gradient to use
  59212. * @returns the new interpolated quaternion
  59213. */
  59214. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59215. /**
  59216. * Interpolates between two quaternions and stores it into a target quaternion
  59217. * @param left defines first quaternion
  59218. * @param right defines second quaternion
  59219. * @param amount defines the gradient to use
  59220. * @param result defines the target quaternion
  59221. */
  59222. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  59223. /**
  59224. * Interpolate between two quaternions using Hermite interpolation
  59225. * @param value1 defines first quaternion
  59226. * @param tangent1 defines the incoming tangent
  59227. * @param value2 defines second quaternion
  59228. * @param tangent2 defines the outgoing tangent
  59229. * @param amount defines the target quaternion
  59230. * @returns the new interpolated quaternion
  59231. */
  59232. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  59233. }
  59234. /**
  59235. * Class used to store matrix data (4x4)
  59236. */
  59237. export class Matrix {
  59238. private static _updateFlagSeed;
  59239. private static _identityReadOnly;
  59240. private _isIdentity;
  59241. private _isIdentityDirty;
  59242. private _isIdentity3x2;
  59243. private _isIdentity3x2Dirty;
  59244. /**
  59245. * Gets the update flag of the matrix which is an unique number for the matrix.
  59246. * It will be incremented every time the matrix data change.
  59247. * You can use it to speed the comparison between two versions of the same matrix.
  59248. */
  59249. updateFlag: number;
  59250. private readonly _m;
  59251. /**
  59252. * Gets the internal data of the matrix
  59253. */
  59254. readonly m: DeepImmutable<Float32Array>;
  59255. /** @hidden */
  59256. _markAsUpdated(): void;
  59257. /** @hidden */
  59258. private _updateIdentityStatus;
  59259. /**
  59260. * Creates an empty matrix (filled with zeros)
  59261. */
  59262. constructor();
  59263. /**
  59264. * Check if the current matrix is identity
  59265. * @returns true is the matrix is the identity matrix
  59266. */
  59267. isIdentity(): boolean;
  59268. /**
  59269. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  59270. * @returns true is the matrix is the identity matrix
  59271. */
  59272. isIdentityAs3x2(): boolean;
  59273. /**
  59274. * Gets the determinant of the matrix
  59275. * @returns the matrix determinant
  59276. */
  59277. determinant(): number;
  59278. /**
  59279. * Returns the matrix as a Float32Array
  59280. * @returns the matrix underlying array
  59281. */
  59282. toArray(): DeepImmutable<Float32Array>;
  59283. /**
  59284. * Returns the matrix as a Float32Array
  59285. * @returns the matrix underlying array.
  59286. */
  59287. asArray(): DeepImmutable<Float32Array>;
  59288. /**
  59289. * Inverts the current matrix in place
  59290. * @returns the current inverted matrix
  59291. */
  59292. invert(): Matrix;
  59293. /**
  59294. * Sets all the matrix elements to zero
  59295. * @returns the current matrix
  59296. */
  59297. reset(): Matrix;
  59298. /**
  59299. * Adds the current matrix with a second one
  59300. * @param other defines the matrix to add
  59301. * @returns a new matrix as the addition of the current matrix and the given one
  59302. */
  59303. add(other: DeepImmutable<Matrix>): Matrix;
  59304. /**
  59305. * Sets the given matrix "result" to the addition of the current matrix and the given one
  59306. * @param other defines the matrix to add
  59307. * @param result defines the target matrix
  59308. * @returns the current matrix
  59309. */
  59310. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59311. /**
  59312. * Adds in place the given matrix to the current matrix
  59313. * @param other defines the second operand
  59314. * @returns the current updated matrix
  59315. */
  59316. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  59317. /**
  59318. * Sets the given matrix to the current inverted Matrix
  59319. * @param other defines the target matrix
  59320. * @returns the unmodified current matrix
  59321. */
  59322. invertToRef(other: Matrix): Matrix;
  59323. /**
  59324. * add a value at the specified position in the current Matrix
  59325. * @param index the index of the value within the matrix. between 0 and 15.
  59326. * @param value the value to be added
  59327. * @returns the current updated matrix
  59328. */
  59329. addAtIndex(index: number, value: number): Matrix;
  59330. /**
  59331. * mutiply the specified position in the current Matrix by a value
  59332. * @param index the index of the value within the matrix. between 0 and 15.
  59333. * @param value the value to be added
  59334. * @returns the current updated matrix
  59335. */
  59336. multiplyAtIndex(index: number, value: number): Matrix;
  59337. /**
  59338. * Inserts the translation vector (using 3 floats) in the current matrix
  59339. * @param x defines the 1st component of the translation
  59340. * @param y defines the 2nd component of the translation
  59341. * @param z defines the 3rd component of the translation
  59342. * @returns the current updated matrix
  59343. */
  59344. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  59345. /**
  59346. * Inserts the translation vector in the current matrix
  59347. * @param vector3 defines the translation to insert
  59348. * @returns the current updated matrix
  59349. */
  59350. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  59351. /**
  59352. * Gets the translation value of the current matrix
  59353. * @returns a new Vector3 as the extracted translation from the matrix
  59354. */
  59355. getTranslation(): Vector3;
  59356. /**
  59357. * Fill a Vector3 with the extracted translation from the matrix
  59358. * @param result defines the Vector3 where to store the translation
  59359. * @returns the current matrix
  59360. */
  59361. getTranslationToRef(result: Vector3): Matrix;
  59362. /**
  59363. * Remove rotation and scaling part from the matrix
  59364. * @returns the updated matrix
  59365. */
  59366. removeRotationAndScaling(): Matrix;
  59367. /**
  59368. * Multiply two matrices
  59369. * @param other defines the second operand
  59370. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  59371. */
  59372. multiply(other: DeepImmutable<Matrix>): Matrix;
  59373. /**
  59374. * Copy the current matrix from the given one
  59375. * @param other defines the source matrix
  59376. * @returns the current updated matrix
  59377. */
  59378. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  59379. /**
  59380. * Populates the given array from the starting index with the current matrix values
  59381. * @param array defines the target array
  59382. * @param offset defines the offset in the target array where to start storing values
  59383. * @returns the current matrix
  59384. */
  59385. copyToArray(array: Float32Array, offset?: number): Matrix;
  59386. /**
  59387. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  59388. * @param other defines the second operand
  59389. * @param result defines the matrix where to store the multiplication
  59390. * @returns the current matrix
  59391. */
  59392. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  59393. /**
  59394. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  59395. * @param other defines the second operand
  59396. * @param result defines the array where to store the multiplication
  59397. * @param offset defines the offset in the target array where to start storing values
  59398. * @returns the current matrix
  59399. */
  59400. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  59401. /**
  59402. * Check equality between this matrix and a second one
  59403. * @param value defines the second matrix to compare
  59404. * @returns true is the current matrix and the given one values are strictly equal
  59405. */
  59406. equals(value: DeepImmutable<Matrix>): boolean;
  59407. /**
  59408. * Clone the current matrix
  59409. * @returns a new matrix from the current matrix
  59410. */
  59411. clone(): Matrix;
  59412. /**
  59413. * Returns the name of the current matrix class
  59414. * @returns the string "Matrix"
  59415. */
  59416. getClassName(): string;
  59417. /**
  59418. * Gets the hash code of the current matrix
  59419. * @returns the hash code
  59420. */
  59421. getHashCode(): number;
  59422. /**
  59423. * Decomposes the current Matrix into a translation, rotation and scaling components
  59424. * @param scale defines the scale vector3 given as a reference to update
  59425. * @param rotation defines the rotation quaternion given as a reference to update
  59426. * @param translation defines the translation vector3 given as a reference to update
  59427. * @returns true if operation was successful
  59428. */
  59429. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  59430. /**
  59431. * Gets specific row of the matrix
  59432. * @param index defines the number of the row to get
  59433. * @returns the index-th row of the current matrix as a new Vector4
  59434. */
  59435. getRow(index: number): Nullable<Vector4>;
  59436. /**
  59437. * Sets the index-th row of the current matrix to the vector4 values
  59438. * @param index defines the number of the row to set
  59439. * @param row defines the target vector4
  59440. * @returns the updated current matrix
  59441. */
  59442. setRow(index: number, row: Vector4): Matrix;
  59443. /**
  59444. * Compute the transpose of the matrix
  59445. * @returns the new transposed matrix
  59446. */
  59447. transpose(): Matrix;
  59448. /**
  59449. * Compute the transpose of the matrix and store it in a given matrix
  59450. * @param result defines the target matrix
  59451. * @returns the current matrix
  59452. */
  59453. transposeToRef(result: Matrix): Matrix;
  59454. /**
  59455. * Sets the index-th row of the current matrix with the given 4 x float values
  59456. * @param index defines the row index
  59457. * @param x defines the x component to set
  59458. * @param y defines the y component to set
  59459. * @param z defines the z component to set
  59460. * @param w defines the w component to set
  59461. * @returns the updated current matrix
  59462. */
  59463. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  59464. /**
  59465. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  59466. * @param scale defines the scale factor
  59467. * @returns a new matrix
  59468. */
  59469. scale(scale: number): Matrix;
  59470. /**
  59471. * Scale the current matrix values by a factor to a given result matrix
  59472. * @param scale defines the scale factor
  59473. * @param result defines the matrix to store the result
  59474. * @returns the current matrix
  59475. */
  59476. scaleToRef(scale: number, result: Matrix): Matrix;
  59477. /**
  59478. * Scale the current matrix values by a factor and add the result to a given matrix
  59479. * @param scale defines the scale factor
  59480. * @param result defines the Matrix to store the result
  59481. * @returns the current matrix
  59482. */
  59483. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  59484. /**
  59485. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  59486. * @param ref matrix to store the result
  59487. */
  59488. toNormalMatrix(ref: Matrix): void;
  59489. /**
  59490. * Gets only rotation part of the current matrix
  59491. * @returns a new matrix sets to the extracted rotation matrix from the current one
  59492. */
  59493. getRotationMatrix(): Matrix;
  59494. /**
  59495. * Extracts the rotation matrix from the current one and sets it as the given "result"
  59496. * @param result defines the target matrix to store data to
  59497. * @returns the current matrix
  59498. */
  59499. getRotationMatrixToRef(result: Matrix): Matrix;
  59500. /**
  59501. * Toggles model matrix from being right handed to left handed in place and vice versa
  59502. */
  59503. toggleModelMatrixHandInPlace(): void;
  59504. /**
  59505. * Toggles projection matrix from being right handed to left handed in place and vice versa
  59506. */
  59507. toggleProjectionMatrixHandInPlace(): void;
  59508. /**
  59509. * Creates a matrix from an array
  59510. * @param array defines the source array
  59511. * @param offset defines an offset in the source array
  59512. * @returns a new Matrix set from the starting index of the given array
  59513. */
  59514. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  59515. /**
  59516. * Copy the content of an array into a given matrix
  59517. * @param array defines the source array
  59518. * @param offset defines an offset in the source array
  59519. * @param result defines the target matrix
  59520. */
  59521. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  59522. /**
  59523. * Stores an array into a matrix after having multiplied each component by a given factor
  59524. * @param array defines the source array
  59525. * @param offset defines the offset in the source array
  59526. * @param scale defines the scaling factor
  59527. * @param result defines the target matrix
  59528. */
  59529. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  59530. /**
  59531. * Gets an identity matrix that must not be updated
  59532. */
  59533. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  59534. /**
  59535. * Stores a list of values (16) inside a given matrix
  59536. * @param initialM11 defines 1st value of 1st row
  59537. * @param initialM12 defines 2nd value of 1st row
  59538. * @param initialM13 defines 3rd value of 1st row
  59539. * @param initialM14 defines 4th value of 1st row
  59540. * @param initialM21 defines 1st value of 2nd row
  59541. * @param initialM22 defines 2nd value of 2nd row
  59542. * @param initialM23 defines 3rd value of 2nd row
  59543. * @param initialM24 defines 4th value of 2nd row
  59544. * @param initialM31 defines 1st value of 3rd row
  59545. * @param initialM32 defines 2nd value of 3rd row
  59546. * @param initialM33 defines 3rd value of 3rd row
  59547. * @param initialM34 defines 4th value of 3rd row
  59548. * @param initialM41 defines 1st value of 4th row
  59549. * @param initialM42 defines 2nd value of 4th row
  59550. * @param initialM43 defines 3rd value of 4th row
  59551. * @param initialM44 defines 4th value of 4th row
  59552. * @param result defines the target matrix
  59553. */
  59554. 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;
  59555. /**
  59556. * Creates new matrix from a list of values (16)
  59557. * @param initialM11 defines 1st value of 1st row
  59558. * @param initialM12 defines 2nd value of 1st row
  59559. * @param initialM13 defines 3rd value of 1st row
  59560. * @param initialM14 defines 4th value of 1st row
  59561. * @param initialM21 defines 1st value of 2nd row
  59562. * @param initialM22 defines 2nd value of 2nd row
  59563. * @param initialM23 defines 3rd value of 2nd row
  59564. * @param initialM24 defines 4th value of 2nd row
  59565. * @param initialM31 defines 1st value of 3rd row
  59566. * @param initialM32 defines 2nd value of 3rd row
  59567. * @param initialM33 defines 3rd value of 3rd row
  59568. * @param initialM34 defines 4th value of 3rd row
  59569. * @param initialM41 defines 1st value of 4th row
  59570. * @param initialM42 defines 2nd value of 4th row
  59571. * @param initialM43 defines 3rd value of 4th row
  59572. * @param initialM44 defines 4th value of 4th row
  59573. * @returns the new matrix
  59574. */
  59575. 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;
  59576. /**
  59577. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59578. * @param scale defines the scale vector3
  59579. * @param rotation defines the rotation quaternion
  59580. * @param translation defines the translation vector3
  59581. * @returns a new matrix
  59582. */
  59583. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  59584. /**
  59585. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  59586. * @param scale defines the scale vector3
  59587. * @param rotation defines the rotation quaternion
  59588. * @param translation defines the translation vector3
  59589. * @param result defines the target matrix
  59590. */
  59591. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  59592. /**
  59593. * Creates a new identity matrix
  59594. * @returns a new identity matrix
  59595. */
  59596. static Identity(): Matrix;
  59597. /**
  59598. * Creates a new identity matrix and stores the result in a given matrix
  59599. * @param result defines the target matrix
  59600. */
  59601. static IdentityToRef(result: Matrix): void;
  59602. /**
  59603. * Creates a new zero matrix
  59604. * @returns a new zero matrix
  59605. */
  59606. static Zero(): Matrix;
  59607. /**
  59608. * Creates a new rotation matrix for "angle" radians around the X axis
  59609. * @param angle defines the angle (in radians) to use
  59610. * @return the new matrix
  59611. */
  59612. static RotationX(angle: number): Matrix;
  59613. /**
  59614. * Creates a new matrix as the invert of a given matrix
  59615. * @param source defines the source matrix
  59616. * @returns the new matrix
  59617. */
  59618. static Invert(source: DeepImmutable<Matrix>): Matrix;
  59619. /**
  59620. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  59621. * @param angle defines the angle (in radians) to use
  59622. * @param result defines the target matrix
  59623. */
  59624. static RotationXToRef(angle: number, result: Matrix): void;
  59625. /**
  59626. * Creates a new rotation matrix for "angle" radians around the Y axis
  59627. * @param angle defines the angle (in radians) to use
  59628. * @return the new matrix
  59629. */
  59630. static RotationY(angle: number): Matrix;
  59631. /**
  59632. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  59633. * @param angle defines the angle (in radians) to use
  59634. * @param result defines the target matrix
  59635. */
  59636. static RotationYToRef(angle: number, result: Matrix): void;
  59637. /**
  59638. * Creates a new rotation matrix for "angle" radians around the Z axis
  59639. * @param angle defines the angle (in radians) to use
  59640. * @return the new matrix
  59641. */
  59642. static RotationZ(angle: number): Matrix;
  59643. /**
  59644. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  59645. * @param angle defines the angle (in radians) to use
  59646. * @param result defines the target matrix
  59647. */
  59648. static RotationZToRef(angle: number, result: Matrix): void;
  59649. /**
  59650. * Creates a new rotation matrix for "angle" radians around the given axis
  59651. * @param axis defines the axis to use
  59652. * @param angle defines the angle (in radians) to use
  59653. * @return the new matrix
  59654. */
  59655. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  59656. /**
  59657. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  59658. * @param axis defines the axis to use
  59659. * @param angle defines the angle (in radians) to use
  59660. * @param result defines the target matrix
  59661. */
  59662. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  59663. /**
  59664. * Creates a rotation matrix
  59665. * @param yaw defines the yaw angle in radians (Y axis)
  59666. * @param pitch defines the pitch angle in radians (X axis)
  59667. * @param roll defines the roll angle in radians (X axis)
  59668. * @returns the new rotation matrix
  59669. */
  59670. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  59671. /**
  59672. * Creates a rotation matrix and stores it in a given matrix
  59673. * @param yaw defines the yaw angle in radians (Y axis)
  59674. * @param pitch defines the pitch angle in radians (X axis)
  59675. * @param roll defines the roll angle in radians (X axis)
  59676. * @param result defines the target matrix
  59677. */
  59678. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  59679. /**
  59680. * Creates a scaling matrix
  59681. * @param x defines the scale factor on X axis
  59682. * @param y defines the scale factor on Y axis
  59683. * @param z defines the scale factor on Z axis
  59684. * @returns the new matrix
  59685. */
  59686. static Scaling(x: number, y: number, z: number): Matrix;
  59687. /**
  59688. * Creates a scaling matrix and stores it in a given matrix
  59689. * @param x defines the scale factor on X axis
  59690. * @param y defines the scale factor on Y axis
  59691. * @param z defines the scale factor on Z axis
  59692. * @param result defines the target matrix
  59693. */
  59694. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  59695. /**
  59696. * Creates a translation matrix
  59697. * @param x defines the translation on X axis
  59698. * @param y defines the translation on Y axis
  59699. * @param z defines the translationon Z axis
  59700. * @returns the new matrix
  59701. */
  59702. static Translation(x: number, y: number, z: number): Matrix;
  59703. /**
  59704. * Creates a translation matrix and stores it in a given matrix
  59705. * @param x defines the translation on X axis
  59706. * @param y defines the translation on Y axis
  59707. * @param z defines the translationon Z axis
  59708. * @param result defines the target matrix
  59709. */
  59710. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  59711. /**
  59712. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59713. * @param startValue defines the start value
  59714. * @param endValue defines the end value
  59715. * @param gradient defines the gradient factor
  59716. * @returns the new matrix
  59717. */
  59718. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59719. /**
  59720. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  59721. * @param startValue defines the start value
  59722. * @param endValue defines the end value
  59723. * @param gradient defines the gradient factor
  59724. * @param result defines the Matrix object where to store data
  59725. */
  59726. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59727. /**
  59728. * Builds a new matrix whose values are computed by:
  59729. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59730. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59731. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59732. * @param startValue defines the first matrix
  59733. * @param endValue defines the second matrix
  59734. * @param gradient defines the gradient between the two matrices
  59735. * @returns the new matrix
  59736. */
  59737. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  59738. /**
  59739. * Update a matrix to values which are computed by:
  59740. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  59741. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  59742. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  59743. * @param startValue defines the first matrix
  59744. * @param endValue defines the second matrix
  59745. * @param gradient defines the gradient between the two matrices
  59746. * @param result defines the target matrix
  59747. */
  59748. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  59749. /**
  59750. * 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"
  59751. * This function works in left handed mode
  59752. * @param eye defines the final position of the entity
  59753. * @param target defines where the entity should look at
  59754. * @param up defines the up vector for the entity
  59755. * @returns the new matrix
  59756. */
  59757. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59758. /**
  59759. * 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".
  59760. * This function works in left handed mode
  59761. * @param eye defines the final position of the entity
  59762. * @param target defines where the entity should look at
  59763. * @param up defines the up vector for the entity
  59764. * @param result defines the target matrix
  59765. */
  59766. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59767. /**
  59768. * 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"
  59769. * This function works in right handed mode
  59770. * @param eye defines the final position of the entity
  59771. * @param target defines where the entity should look at
  59772. * @param up defines the up vector for the entity
  59773. * @returns the new matrix
  59774. */
  59775. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  59776. /**
  59777. * 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".
  59778. * This function works in right handed mode
  59779. * @param eye defines the final position of the entity
  59780. * @param target defines where the entity should look at
  59781. * @param up defines the up vector for the entity
  59782. * @param result defines the target matrix
  59783. */
  59784. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  59785. /**
  59786. * Create a left-handed orthographic projection matrix
  59787. * @param width defines the viewport width
  59788. * @param height defines the viewport height
  59789. * @param znear defines the near clip plane
  59790. * @param zfar defines the far clip plane
  59791. * @returns a new matrix as a left-handed orthographic projection matrix
  59792. */
  59793. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59794. /**
  59795. * Store a left-handed orthographic projection to a given matrix
  59796. * @param width defines the viewport width
  59797. * @param height defines the viewport height
  59798. * @param znear defines the near clip plane
  59799. * @param zfar defines the far clip plane
  59800. * @param result defines the target matrix
  59801. */
  59802. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  59803. /**
  59804. * Create a left-handed orthographic projection matrix
  59805. * @param left defines the viewport left coordinate
  59806. * @param right defines the viewport right coordinate
  59807. * @param bottom defines the viewport bottom coordinate
  59808. * @param top defines the viewport top coordinate
  59809. * @param znear defines the near clip plane
  59810. * @param zfar defines the far clip plane
  59811. * @returns a new matrix as a left-handed orthographic projection matrix
  59812. */
  59813. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59814. /**
  59815. * Stores a left-handed orthographic projection into a given matrix
  59816. * @param left defines the viewport left coordinate
  59817. * @param right defines the viewport right coordinate
  59818. * @param bottom defines the viewport bottom coordinate
  59819. * @param top defines the viewport top coordinate
  59820. * @param znear defines the near clip plane
  59821. * @param zfar defines the far clip plane
  59822. * @param result defines the target matrix
  59823. */
  59824. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59825. /**
  59826. * Creates a right-handed orthographic projection matrix
  59827. * @param left defines the viewport left coordinate
  59828. * @param right defines the viewport right coordinate
  59829. * @param bottom defines the viewport bottom coordinate
  59830. * @param top defines the viewport top coordinate
  59831. * @param znear defines the near clip plane
  59832. * @param zfar defines the far clip plane
  59833. * @returns a new matrix as a right-handed orthographic projection matrix
  59834. */
  59835. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  59836. /**
  59837. * Stores a right-handed orthographic projection into a given matrix
  59838. * @param left defines the viewport left coordinate
  59839. * @param right defines the viewport right coordinate
  59840. * @param bottom defines the viewport bottom coordinate
  59841. * @param top defines the viewport top coordinate
  59842. * @param znear defines the near clip plane
  59843. * @param zfar defines the far clip plane
  59844. * @param result defines the target matrix
  59845. */
  59846. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  59847. /**
  59848. * Creates a left-handed perspective projection matrix
  59849. * @param width defines the viewport width
  59850. * @param height defines the viewport height
  59851. * @param znear defines the near clip plane
  59852. * @param zfar defines the far clip plane
  59853. * @returns a new matrix as a left-handed perspective projection matrix
  59854. */
  59855. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  59856. /**
  59857. * Creates a left-handed perspective projection matrix
  59858. * @param fov defines the horizontal field of view
  59859. * @param aspect defines the aspect ratio
  59860. * @param znear defines the near clip plane
  59861. * @param zfar defines the far clip plane
  59862. * @returns a new matrix as a left-handed perspective projection matrix
  59863. */
  59864. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59865. /**
  59866. * Stores a left-handed perspective projection into a given matrix
  59867. * @param fov defines the horizontal field of view
  59868. * @param aspect defines the aspect ratio
  59869. * @param znear defines the near clip plane
  59870. * @param zfar defines the far clip plane
  59871. * @param result defines the target matrix
  59872. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59873. */
  59874. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59875. /**
  59876. * Creates a right-handed perspective projection matrix
  59877. * @param fov defines the horizontal field of view
  59878. * @param aspect defines the aspect ratio
  59879. * @param znear defines the near clip plane
  59880. * @param zfar defines the far clip plane
  59881. * @returns a new matrix as a right-handed perspective projection matrix
  59882. */
  59883. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  59884. /**
  59885. * Stores a right-handed perspective projection into a given matrix
  59886. * @param fov defines the horizontal field of view
  59887. * @param aspect defines the aspect ratio
  59888. * @param znear defines the near clip plane
  59889. * @param zfar defines the far clip plane
  59890. * @param result defines the target matrix
  59891. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  59892. */
  59893. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  59894. /**
  59895. * Stores a perspective projection for WebVR info a given matrix
  59896. * @param fov defines the field of view
  59897. * @param znear defines the near clip plane
  59898. * @param zfar defines the far clip plane
  59899. * @param result defines the target matrix
  59900. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  59901. */
  59902. static PerspectiveFovWebVRToRef(fov: {
  59903. upDegrees: number;
  59904. downDegrees: number;
  59905. leftDegrees: number;
  59906. rightDegrees: number;
  59907. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  59908. /**
  59909. * Computes a complete transformation matrix
  59910. * @param viewport defines the viewport to use
  59911. * @param world defines the world matrix
  59912. * @param view defines the view matrix
  59913. * @param projection defines the projection matrix
  59914. * @param zmin defines the near clip plane
  59915. * @param zmax defines the far clip plane
  59916. * @returns the transformation matrix
  59917. */
  59918. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  59919. /**
  59920. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  59921. * @param matrix defines the matrix to use
  59922. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  59923. */
  59924. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  59925. /**
  59926. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  59927. * @param matrix defines the matrix to use
  59928. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  59929. */
  59930. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  59931. /**
  59932. * Compute the transpose of a given matrix
  59933. * @param matrix defines the matrix to transpose
  59934. * @returns the new matrix
  59935. */
  59936. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  59937. /**
  59938. * Compute the transpose of a matrix and store it in a target matrix
  59939. * @param matrix defines the matrix to transpose
  59940. * @param result defines the target matrix
  59941. */
  59942. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  59943. /**
  59944. * Computes a reflection matrix from a plane
  59945. * @param plane defines the reflection plane
  59946. * @returns a new matrix
  59947. */
  59948. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  59949. /**
  59950. * Computes a reflection matrix from a plane
  59951. * @param plane defines the reflection plane
  59952. * @param result defines the target matrix
  59953. */
  59954. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  59955. /**
  59956. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  59957. * @param xaxis defines the value of the 1st axis
  59958. * @param yaxis defines the value of the 2nd axis
  59959. * @param zaxis defines the value of the 3rd axis
  59960. * @param result defines the target matrix
  59961. */
  59962. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  59963. /**
  59964. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  59965. * @param quat defines the quaternion to use
  59966. * @param result defines the target matrix
  59967. */
  59968. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  59969. }
  59970. /**
  59971. * Represens a plane by the equation ax + by + cz + d = 0
  59972. */
  59973. export class Plane {
  59974. /**
  59975. * Normal of the plane (a,b,c)
  59976. */
  59977. normal: Vector3;
  59978. /**
  59979. * d component of the plane
  59980. */
  59981. d: number;
  59982. /**
  59983. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  59984. * @param a a component of the plane
  59985. * @param b b component of the plane
  59986. * @param c c component of the plane
  59987. * @param d d component of the plane
  59988. */
  59989. constructor(a: number, b: number, c: number, d: number);
  59990. /**
  59991. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  59992. */
  59993. asArray(): number[];
  59994. /**
  59995. * @returns a new plane copied from the current Plane.
  59996. */
  59997. clone(): Plane;
  59998. /**
  59999. * @returns the string "Plane".
  60000. */
  60001. getClassName(): string;
  60002. /**
  60003. * @returns the Plane hash code.
  60004. */
  60005. getHashCode(): number;
  60006. /**
  60007. * Normalize the current Plane in place.
  60008. * @returns the updated Plane.
  60009. */
  60010. normalize(): Plane;
  60011. /**
  60012. * Applies a transformation the plane and returns the result
  60013. * @param transformation the transformation matrix to be applied to the plane
  60014. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  60015. */
  60016. transform(transformation: DeepImmutable<Matrix>): Plane;
  60017. /**
  60018. * Calcualtte the dot product between the point and the plane normal
  60019. * @param point point to calculate the dot product with
  60020. * @returns the dot product (float) of the point coordinates and the plane normal.
  60021. */
  60022. dotCoordinate(point: DeepImmutable<Vector3>): number;
  60023. /**
  60024. * Updates the current Plane from the plane defined by the three given points.
  60025. * @param point1 one of the points used to contruct the plane
  60026. * @param point2 one of the points used to contruct the plane
  60027. * @param point3 one of the points used to contruct the plane
  60028. * @returns the updated Plane.
  60029. */
  60030. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60031. /**
  60032. * Checks if the plane is facing a given direction
  60033. * @param direction the direction to check if the plane is facing
  60034. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  60035. * @returns True is the vector "direction" is the same side than the plane normal.
  60036. */
  60037. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  60038. /**
  60039. * Calculates the distance to a point
  60040. * @param point point to calculate distance to
  60041. * @returns the signed distance (float) from the given point to the Plane.
  60042. */
  60043. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  60044. /**
  60045. * Creates a plane from an array
  60046. * @param array the array to create a plane from
  60047. * @returns a new Plane from the given array.
  60048. */
  60049. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  60050. /**
  60051. * Creates a plane from three points
  60052. * @param point1 point used to create the plane
  60053. * @param point2 point used to create the plane
  60054. * @param point3 point used to create the plane
  60055. * @returns a new Plane defined by the three given points.
  60056. */
  60057. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  60058. /**
  60059. * Creates a plane from an origin point and a normal
  60060. * @param origin origin of the plane to be constructed
  60061. * @param normal normal of the plane to be constructed
  60062. * @returns a new Plane the normal vector to this plane at the given origin point.
  60063. * Note : the vector "normal" is updated because normalized.
  60064. */
  60065. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  60066. /**
  60067. * Calculates the distance from a plane and a point
  60068. * @param origin origin of the plane to be constructed
  60069. * @param normal normal of the plane to be constructed
  60070. * @param point point to calculate distance to
  60071. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  60072. */
  60073. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  60074. }
  60075. /**
  60076. * Class used to represent a viewport on screen
  60077. */
  60078. export class Viewport {
  60079. /** viewport left coordinate */
  60080. x: number;
  60081. /** viewport top coordinate */
  60082. y: number;
  60083. /**viewport width */
  60084. width: number;
  60085. /** viewport height */
  60086. height: number;
  60087. /**
  60088. * Creates a Viewport object located at (x, y) and sized (width, height)
  60089. * @param x defines viewport left coordinate
  60090. * @param y defines viewport top coordinate
  60091. * @param width defines the viewport width
  60092. * @param height defines the viewport height
  60093. */
  60094. constructor(
  60095. /** viewport left coordinate */
  60096. x: number,
  60097. /** viewport top coordinate */
  60098. y: number,
  60099. /**viewport width */
  60100. width: number,
  60101. /** viewport height */
  60102. height: number);
  60103. /**
  60104. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  60105. * @param renderWidth defines the rendering width
  60106. * @param renderHeight defines the rendering height
  60107. * @returns a new Viewport
  60108. */
  60109. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  60110. /**
  60111. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  60112. * @param renderWidth defines the rendering width
  60113. * @param renderHeight defines the rendering height
  60114. * @param ref defines the target viewport
  60115. * @returns the current viewport
  60116. */
  60117. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  60118. /**
  60119. * Returns a new Viewport copied from the current one
  60120. * @returns a new Viewport
  60121. */
  60122. clone(): Viewport;
  60123. }
  60124. /**
  60125. * Reprasents a camera frustum
  60126. */
  60127. export class Frustum {
  60128. /**
  60129. * Gets the planes representing the frustum
  60130. * @param transform matrix to be applied to the returned planes
  60131. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  60132. */
  60133. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  60134. /**
  60135. * Gets the near frustum plane transformed by the transform matrix
  60136. * @param transform transformation matrix to be applied to the resulting frustum plane
  60137. * @param frustumPlane the resuling frustum plane
  60138. */
  60139. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60140. /**
  60141. * Gets the far frustum plane transformed by the transform matrix
  60142. * @param transform transformation matrix to be applied to the resulting frustum plane
  60143. * @param frustumPlane the resuling frustum plane
  60144. */
  60145. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60146. /**
  60147. * Gets the left frustum plane transformed by the transform matrix
  60148. * @param transform transformation matrix to be applied to the resulting frustum plane
  60149. * @param frustumPlane the resuling frustum plane
  60150. */
  60151. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60152. /**
  60153. * Gets the right frustum plane transformed by the transform matrix
  60154. * @param transform transformation matrix to be applied to the resulting frustum plane
  60155. * @param frustumPlane the resuling frustum plane
  60156. */
  60157. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60158. /**
  60159. * Gets the top frustum plane transformed by the transform matrix
  60160. * @param transform transformation matrix to be applied to the resulting frustum plane
  60161. * @param frustumPlane the resuling frustum plane
  60162. */
  60163. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60164. /**
  60165. * Gets the bottom frustum plane transformed by the transform matrix
  60166. * @param transform transformation matrix to be applied to the resulting frustum plane
  60167. * @param frustumPlane the resuling frustum plane
  60168. */
  60169. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  60170. /**
  60171. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  60172. * @param transform transformation matrix to be applied to the resulting frustum planes
  60173. * @param frustumPlanes the resuling frustum planes
  60174. */
  60175. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  60176. }
  60177. /** Defines supported spaces */
  60178. export enum Space {
  60179. /** Local (object) space */
  60180. LOCAL = 0,
  60181. /** World space */
  60182. WORLD = 1,
  60183. /** Bone space */
  60184. BONE = 2
  60185. }
  60186. /** Defines the 3 main axes */
  60187. export class Axis {
  60188. /** X axis */
  60189. static X: Vector3;
  60190. /** Y axis */
  60191. static Y: Vector3;
  60192. /** Z axis */
  60193. static Z: Vector3;
  60194. }
  60195. /** Class used to represent a Bezier curve */
  60196. export class BezierCurve {
  60197. /**
  60198. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  60199. * @param t defines the time
  60200. * @param x1 defines the left coordinate on X axis
  60201. * @param y1 defines the left coordinate on Y axis
  60202. * @param x2 defines the right coordinate on X axis
  60203. * @param y2 defines the right coordinate on Y axis
  60204. * @returns the interpolated value
  60205. */
  60206. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  60207. }
  60208. /**
  60209. * Defines potential orientation for back face culling
  60210. */
  60211. export enum Orientation {
  60212. /**
  60213. * Clockwise
  60214. */
  60215. CW = 0,
  60216. /** Counter clockwise */
  60217. CCW = 1
  60218. }
  60219. /**
  60220. * Defines angle representation
  60221. */
  60222. export class Angle {
  60223. private _radians;
  60224. /**
  60225. * Creates an Angle object of "radians" radians (float).
  60226. * @param radians the angle in radians
  60227. */
  60228. constructor(radians: number);
  60229. /**
  60230. * Get value in degrees
  60231. * @returns the Angle value in degrees (float)
  60232. */
  60233. degrees(): number;
  60234. /**
  60235. * Get value in radians
  60236. * @returns the Angle value in radians (float)
  60237. */
  60238. radians(): number;
  60239. /**
  60240. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  60241. * @param a defines first vector
  60242. * @param b defines second vector
  60243. * @returns a new Angle
  60244. */
  60245. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  60246. /**
  60247. * Gets a new Angle object from the given float in radians
  60248. * @param radians defines the angle value in radians
  60249. * @returns a new Angle
  60250. */
  60251. static FromRadians(radians: number): Angle;
  60252. /**
  60253. * Gets a new Angle object from the given float in degrees
  60254. * @param degrees defines the angle value in degrees
  60255. * @returns a new Angle
  60256. */
  60257. static FromDegrees(degrees: number): Angle;
  60258. }
  60259. /**
  60260. * This represents an arc in a 2d space.
  60261. */
  60262. export class Arc2 {
  60263. /** Defines the start point of the arc */
  60264. startPoint: Vector2;
  60265. /** Defines the mid point of the arc */
  60266. midPoint: Vector2;
  60267. /** Defines the end point of the arc */
  60268. endPoint: Vector2;
  60269. /**
  60270. * Defines the center point of the arc.
  60271. */
  60272. centerPoint: Vector2;
  60273. /**
  60274. * Defines the radius of the arc.
  60275. */
  60276. radius: number;
  60277. /**
  60278. * Defines the angle of the arc (from mid point to end point).
  60279. */
  60280. angle: Angle;
  60281. /**
  60282. * Defines the start angle of the arc (from start point to middle point).
  60283. */
  60284. startAngle: Angle;
  60285. /**
  60286. * Defines the orientation of the arc (clock wise/counter clock wise).
  60287. */
  60288. orientation: Orientation;
  60289. /**
  60290. * Creates an Arc object from the three given points : start, middle and end.
  60291. * @param startPoint Defines the start point of the arc
  60292. * @param midPoint Defines the midlle point of the arc
  60293. * @param endPoint Defines the end point of the arc
  60294. */
  60295. constructor(
  60296. /** Defines the start point of the arc */
  60297. startPoint: Vector2,
  60298. /** Defines the mid point of the arc */
  60299. midPoint: Vector2,
  60300. /** Defines the end point of the arc */
  60301. endPoint: Vector2);
  60302. }
  60303. /**
  60304. * Represents a 2D path made up of multiple 2D points
  60305. */
  60306. export class Path2 {
  60307. private _points;
  60308. private _length;
  60309. /**
  60310. * If the path start and end point are the same
  60311. */
  60312. closed: boolean;
  60313. /**
  60314. * Creates a Path2 object from the starting 2D coordinates x and y.
  60315. * @param x the starting points x value
  60316. * @param y the starting points y value
  60317. */
  60318. constructor(x: number, y: number);
  60319. /**
  60320. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  60321. * @param x the added points x value
  60322. * @param y the added points y value
  60323. * @returns the updated Path2.
  60324. */
  60325. addLineTo(x: number, y: number): Path2;
  60326. /**
  60327. * 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.
  60328. * @param midX middle point x value
  60329. * @param midY middle point y value
  60330. * @param endX end point x value
  60331. * @param endY end point y value
  60332. * @param numberOfSegments (default: 36)
  60333. * @returns the updated Path2.
  60334. */
  60335. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  60336. /**
  60337. * Closes the Path2.
  60338. * @returns the Path2.
  60339. */
  60340. close(): Path2;
  60341. /**
  60342. * Gets the sum of the distance between each sequential point in the path
  60343. * @returns the Path2 total length (float).
  60344. */
  60345. length(): number;
  60346. /**
  60347. * Gets the points which construct the path
  60348. * @returns the Path2 internal array of points.
  60349. */
  60350. getPoints(): Vector2[];
  60351. /**
  60352. * Retreives the point at the distance aways from the starting point
  60353. * @param normalizedLengthPosition the length along the path to retreive the point from
  60354. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  60355. */
  60356. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  60357. /**
  60358. * Creates a new path starting from an x and y position
  60359. * @param x starting x value
  60360. * @param y starting y value
  60361. * @returns a new Path2 starting at the coordinates (x, y).
  60362. */
  60363. static StartingAt(x: number, y: number): Path2;
  60364. }
  60365. /**
  60366. * Represents a 3D path made up of multiple 3D points
  60367. */
  60368. export class Path3D {
  60369. /**
  60370. * an array of Vector3, the curve axis of the Path3D
  60371. */
  60372. path: Vector3[];
  60373. private _curve;
  60374. private _distances;
  60375. private _tangents;
  60376. private _normals;
  60377. private _binormals;
  60378. private _raw;
  60379. /**
  60380. * new Path3D(path, normal, raw)
  60381. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  60382. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  60383. * @param path an array of Vector3, the curve axis of the Path3D
  60384. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  60385. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  60386. */
  60387. constructor(
  60388. /**
  60389. * an array of Vector3, the curve axis of the Path3D
  60390. */
  60391. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  60392. /**
  60393. * Returns the Path3D array of successive Vector3 designing its curve.
  60394. * @returns the Path3D array of successive Vector3 designing its curve.
  60395. */
  60396. getCurve(): Vector3[];
  60397. /**
  60398. * Returns an array populated with tangent vectors on each Path3D curve point.
  60399. * @returns an array populated with tangent vectors on each Path3D curve point.
  60400. */
  60401. getTangents(): Vector3[];
  60402. /**
  60403. * Returns an array populated with normal vectors on each Path3D curve point.
  60404. * @returns an array populated with normal vectors on each Path3D curve point.
  60405. */
  60406. getNormals(): Vector3[];
  60407. /**
  60408. * Returns an array populated with binormal vectors on each Path3D curve point.
  60409. * @returns an array populated with binormal vectors on each Path3D curve point.
  60410. */
  60411. getBinormals(): Vector3[];
  60412. /**
  60413. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  60414. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  60415. */
  60416. getDistances(): number[];
  60417. /**
  60418. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  60419. * @param path path which all values are copied into the curves points
  60420. * @param firstNormal which should be projected onto the curve
  60421. * @returns the same object updated.
  60422. */
  60423. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  60424. private _compute;
  60425. private _getFirstNonNullVector;
  60426. private _getLastNonNullVector;
  60427. private _normalVector;
  60428. }
  60429. /**
  60430. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60431. * A Curve3 is designed from a series of successive Vector3.
  60432. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  60433. */
  60434. export class Curve3 {
  60435. private _points;
  60436. private _length;
  60437. /**
  60438. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  60439. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  60440. * @param v1 (Vector3) the control point
  60441. * @param v2 (Vector3) the end point of the Quadratic Bezier
  60442. * @param nbPoints (integer) the wanted number of points in the curve
  60443. * @returns the created Curve3
  60444. */
  60445. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60446. /**
  60447. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  60448. * @param v0 (Vector3) the origin point of the Cubic Bezier
  60449. * @param v1 (Vector3) the first control point
  60450. * @param v2 (Vector3) the second control point
  60451. * @param v3 (Vector3) the end point of the Cubic Bezier
  60452. * @param nbPoints (integer) the wanted number of points in the curve
  60453. * @returns the created Curve3
  60454. */
  60455. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60456. /**
  60457. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  60458. * @param p1 (Vector3) the origin point of the Hermite Spline
  60459. * @param t1 (Vector3) the tangent vector at the origin point
  60460. * @param p2 (Vector3) the end point of the Hermite Spline
  60461. * @param t2 (Vector3) the tangent vector at the end point
  60462. * @param nbPoints (integer) the wanted number of points in the curve
  60463. * @returns the created Curve3
  60464. */
  60465. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  60466. /**
  60467. * Returns a Curve3 object along a CatmullRom Spline curve :
  60468. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  60469. * @param nbPoints (integer) the wanted number of points between each curve control points
  60470. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  60471. * @returns the created Curve3
  60472. */
  60473. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  60474. /**
  60475. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  60476. * A Curve3 is designed from a series of successive Vector3.
  60477. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  60478. * @param points points which make up the curve
  60479. */
  60480. constructor(points: Vector3[]);
  60481. /**
  60482. * @returns the Curve3 stored array of successive Vector3
  60483. */
  60484. getPoints(): Vector3[];
  60485. /**
  60486. * @returns the computed length (float) of the curve.
  60487. */
  60488. length(): number;
  60489. /**
  60490. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  60491. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  60492. * curveA and curveB keep unchanged.
  60493. * @param curve the curve to continue from this curve
  60494. * @returns the newly constructed curve
  60495. */
  60496. continue(curve: DeepImmutable<Curve3>): Curve3;
  60497. private _computeLength;
  60498. }
  60499. /**
  60500. * Contains position and normal vectors for a vertex
  60501. */
  60502. export class PositionNormalVertex {
  60503. /** the position of the vertex (defaut: 0,0,0) */
  60504. position: Vector3;
  60505. /** the normal of the vertex (defaut: 0,1,0) */
  60506. normal: Vector3;
  60507. /**
  60508. * Creates a PositionNormalVertex
  60509. * @param position the position of the vertex (defaut: 0,0,0)
  60510. * @param normal the normal of the vertex (defaut: 0,1,0)
  60511. */
  60512. constructor(
  60513. /** the position of the vertex (defaut: 0,0,0) */
  60514. position?: Vector3,
  60515. /** the normal of the vertex (defaut: 0,1,0) */
  60516. normal?: Vector3);
  60517. /**
  60518. * Clones the PositionNormalVertex
  60519. * @returns the cloned PositionNormalVertex
  60520. */
  60521. clone(): PositionNormalVertex;
  60522. }
  60523. /**
  60524. * Contains position, normal and uv vectors for a vertex
  60525. */
  60526. export class PositionNormalTextureVertex {
  60527. /** the position of the vertex (defaut: 0,0,0) */
  60528. position: Vector3;
  60529. /** the normal of the vertex (defaut: 0,1,0) */
  60530. normal: Vector3;
  60531. /** the uv of the vertex (default: 0,0) */
  60532. uv: Vector2;
  60533. /**
  60534. * Creates a PositionNormalTextureVertex
  60535. * @param position the position of the vertex (defaut: 0,0,0)
  60536. * @param normal the normal of the vertex (defaut: 0,1,0)
  60537. * @param uv the uv of the vertex (default: 0,0)
  60538. */
  60539. constructor(
  60540. /** the position of the vertex (defaut: 0,0,0) */
  60541. position?: Vector3,
  60542. /** the normal of the vertex (defaut: 0,1,0) */
  60543. normal?: Vector3,
  60544. /** the uv of the vertex (default: 0,0) */
  60545. uv?: Vector2);
  60546. /**
  60547. * Clones the PositionNormalTextureVertex
  60548. * @returns the cloned PositionNormalTextureVertex
  60549. */
  60550. clone(): PositionNormalTextureVertex;
  60551. }
  60552. /**
  60553. * @hidden
  60554. */
  60555. export class Tmp {
  60556. static Color3: Color3[];
  60557. static Color4: Color4[];
  60558. static Vector2: Vector2[];
  60559. static Vector3: Vector3[];
  60560. static Vector4: Vector4[];
  60561. static Quaternion: Quaternion[];
  60562. static Matrix: Matrix[];
  60563. }
  60564. }
  60565. declare module BABYLON {
  60566. /**
  60567. * Class used to enable access to offline support
  60568. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60569. */
  60570. export interface IOfflineProvider {
  60571. /**
  60572. * Gets a boolean indicating if scene must be saved in the database
  60573. */
  60574. enableSceneOffline: boolean;
  60575. /**
  60576. * Gets a boolean indicating if textures must be saved in the database
  60577. */
  60578. enableTexturesOffline: boolean;
  60579. /**
  60580. * Open the offline support and make it available
  60581. * @param successCallback defines the callback to call on success
  60582. * @param errorCallback defines the callback to call on error
  60583. */
  60584. open(successCallback: () => void, errorCallback: () => void): void;
  60585. /**
  60586. * Loads an image from the offline support
  60587. * @param url defines the url to load from
  60588. * @param image defines the target DOM image
  60589. */
  60590. loadImage(url: string, image: HTMLImageElement): void;
  60591. /**
  60592. * Loads a file from offline support
  60593. * @param url defines the URL to load from
  60594. * @param sceneLoaded defines a callback to call on success
  60595. * @param progressCallBack defines a callback to call when progress changed
  60596. * @param errorCallback defines a callback to call on error
  60597. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60598. */
  60599. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60600. }
  60601. }
  60602. declare module BABYLON {
  60603. /**
  60604. * A class serves as a medium between the observable and its observers
  60605. */
  60606. export class EventState {
  60607. /**
  60608. * Create a new EventState
  60609. * @param mask defines the mask associated with this state
  60610. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60611. * @param target defines the original target of the state
  60612. * @param currentTarget defines the current target of the state
  60613. */
  60614. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  60615. /**
  60616. * Initialize the current event state
  60617. * @param mask defines the mask associated with this state
  60618. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60619. * @param target defines the original target of the state
  60620. * @param currentTarget defines the current target of the state
  60621. * @returns the current event state
  60622. */
  60623. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  60624. /**
  60625. * An Observer can set this property to true to prevent subsequent observers of being notified
  60626. */
  60627. skipNextObservers: boolean;
  60628. /**
  60629. * Get the mask value that were used to trigger the event corresponding to this EventState object
  60630. */
  60631. mask: number;
  60632. /**
  60633. * The object that originally notified the event
  60634. */
  60635. target?: any;
  60636. /**
  60637. * The current object in the bubbling phase
  60638. */
  60639. currentTarget?: any;
  60640. /**
  60641. * This will be populated with the return value of the last function that was executed.
  60642. * If it is the first function in the callback chain it will be the event data.
  60643. */
  60644. lastReturnValue?: any;
  60645. }
  60646. /**
  60647. * Represent an Observer registered to a given Observable object.
  60648. */
  60649. export class Observer<T> {
  60650. /**
  60651. * Defines the callback to call when the observer is notified
  60652. */
  60653. callback: (eventData: T, eventState: EventState) => void;
  60654. /**
  60655. * Defines the mask of the observer (used to filter notifications)
  60656. */
  60657. mask: number;
  60658. /**
  60659. * Defines the current scope used to restore the JS context
  60660. */
  60661. scope: any;
  60662. /** @hidden */
  60663. _willBeUnregistered: boolean;
  60664. /**
  60665. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  60666. */
  60667. unregisterOnNextCall: boolean;
  60668. /**
  60669. * Creates a new observer
  60670. * @param callback defines the callback to call when the observer is notified
  60671. * @param mask defines the mask of the observer (used to filter notifications)
  60672. * @param scope defines the current scope used to restore the JS context
  60673. */
  60674. constructor(
  60675. /**
  60676. * Defines the callback to call when the observer is notified
  60677. */
  60678. callback: (eventData: T, eventState: EventState) => void,
  60679. /**
  60680. * Defines the mask of the observer (used to filter notifications)
  60681. */
  60682. mask: number,
  60683. /**
  60684. * Defines the current scope used to restore the JS context
  60685. */
  60686. scope?: any);
  60687. }
  60688. /**
  60689. * Represent a list of observers registered to multiple Observables object.
  60690. */
  60691. export class MultiObserver<T> {
  60692. private _observers;
  60693. private _observables;
  60694. /**
  60695. * Release associated resources
  60696. */
  60697. dispose(): void;
  60698. /**
  60699. * Raise a callback when one of the observable will notify
  60700. * @param observables defines a list of observables to watch
  60701. * @param callback defines the callback to call on notification
  60702. * @param mask defines the mask used to filter notifications
  60703. * @param scope defines the current scope used to restore the JS context
  60704. * @returns the new MultiObserver
  60705. */
  60706. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  60707. }
  60708. /**
  60709. * The Observable class is a simple implementation of the Observable pattern.
  60710. *
  60711. * 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.
  60712. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  60713. * 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).
  60714. * 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.
  60715. */
  60716. export class Observable<T> {
  60717. private _observers;
  60718. private _eventState;
  60719. private _onObserverAdded;
  60720. /**
  60721. * Creates a new observable
  60722. * @param onObserverAdded defines a callback to call when a new observer is added
  60723. */
  60724. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  60725. /**
  60726. * Create a new Observer with the specified callback
  60727. * @param callback the callback that will be executed for that Observer
  60728. * @param mask the mask used to filter observers
  60729. * @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.
  60730. * @param scope optional scope for the callback to be called from
  60731. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  60732. * @returns the new observer created for the callback
  60733. */
  60734. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  60735. /**
  60736. * Create a new Observer with the specified callback and unregisters after the next notification
  60737. * @param callback the callback that will be executed for that Observer
  60738. * @returns the new observer created for the callback
  60739. */
  60740. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  60741. /**
  60742. * Remove an Observer from the Observable object
  60743. * @param observer the instance of the Observer to remove
  60744. * @returns false if it doesn't belong to this Observable
  60745. */
  60746. remove(observer: Nullable<Observer<T>>): boolean;
  60747. /**
  60748. * Remove a callback from the Observable object
  60749. * @param callback the callback to remove
  60750. * @param scope optional scope. If used only the callbacks with this scope will be removed
  60751. * @returns false if it doesn't belong to this Observable
  60752. */
  60753. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  60754. private _deferUnregister;
  60755. private _remove;
  60756. /**
  60757. * Notify all Observers by calling their respective callback with the given data
  60758. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  60759. * @param eventData defines the data to send to all observers
  60760. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  60761. * @param target defines the original target of the state
  60762. * @param currentTarget defines the current target of the state
  60763. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  60764. */
  60765. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  60766. /**
  60767. * Calling this will execute each callback, expecting it to be a promise or return a value.
  60768. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  60769. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  60770. * and it is crucial that all callbacks will be executed.
  60771. * The order of the callbacks is kept, callbacks are not executed parallel.
  60772. *
  60773. * @param eventData The data to be sent to each callback
  60774. * @param mask is used to filter observers defaults to -1
  60775. * @param target defines the callback target (see EventState)
  60776. * @param currentTarget defines he current object in the bubbling phase
  60777. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  60778. */
  60779. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  60780. /**
  60781. * Notify a specific observer
  60782. * @param observer defines the observer to notify
  60783. * @param eventData defines the data to be sent to each callback
  60784. * @param mask is used to filter observers defaults to -1
  60785. */
  60786. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  60787. /**
  60788. * Gets a boolean indicating if the observable has at least one observer
  60789. * @returns true is the Observable has at least one Observer registered
  60790. */
  60791. hasObservers(): boolean;
  60792. /**
  60793. * Clear the list of observers
  60794. */
  60795. clear(): void;
  60796. /**
  60797. * Clone the current observable
  60798. * @returns a new observable
  60799. */
  60800. clone(): Observable<T>;
  60801. /**
  60802. * Does this observable handles observer registered with a given mask
  60803. * @param mask defines the mask to be tested
  60804. * @return whether or not one observer registered with the given mask is handeled
  60805. **/
  60806. hasSpecificMask(mask?: number): boolean;
  60807. }
  60808. }
  60809. declare module BABYLON {
  60810. /**
  60811. * Class used to help managing file picking and drag'n'drop
  60812. * File Storage
  60813. */
  60814. export class FilesInputStore {
  60815. /**
  60816. * List of files ready to be loaded
  60817. */
  60818. static FilesToLoad: {
  60819. [key: string]: File;
  60820. };
  60821. }
  60822. }
  60823. declare module BABYLON {
  60824. /** Defines the cross module used constants to avoid circular dependncies */
  60825. export class Constants {
  60826. /** Defines that alpha blending is disabled */
  60827. static readonly ALPHA_DISABLE: number;
  60828. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  60829. static readonly ALPHA_ADD: number;
  60830. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  60831. static readonly ALPHA_COMBINE: number;
  60832. /** Defines that alpha blending to DEST - SRC * DEST */
  60833. static readonly ALPHA_SUBTRACT: number;
  60834. /** Defines that alpha blending to SRC * DEST */
  60835. static readonly ALPHA_MULTIPLY: number;
  60836. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  60837. static readonly ALPHA_MAXIMIZED: number;
  60838. /** Defines that alpha blending to SRC + DEST */
  60839. static readonly ALPHA_ONEONE: number;
  60840. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  60841. static readonly ALPHA_PREMULTIPLIED: number;
  60842. /**
  60843. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  60844. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  60845. */
  60846. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  60847. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  60848. static readonly ALPHA_INTERPOLATE: number;
  60849. /**
  60850. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  60851. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  60852. */
  60853. static readonly ALPHA_SCREENMODE: number;
  60854. /** Defines that the ressource is not delayed*/
  60855. static readonly DELAYLOADSTATE_NONE: number;
  60856. /** Defines that the ressource was successfully delay loaded */
  60857. static readonly DELAYLOADSTATE_LOADED: number;
  60858. /** Defines that the ressource is currently delay loading */
  60859. static readonly DELAYLOADSTATE_LOADING: number;
  60860. /** Defines that the ressource is delayed and has not started loading */
  60861. static readonly DELAYLOADSTATE_NOTLOADED: number;
  60862. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  60863. static readonly NEVER: number;
  60864. /** 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 */
  60865. static readonly ALWAYS: number;
  60866. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  60867. static readonly LESS: number;
  60868. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  60869. static readonly EQUAL: number;
  60870. /** 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 */
  60871. static readonly LEQUAL: number;
  60872. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  60873. static readonly GREATER: number;
  60874. /** 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 */
  60875. static readonly GEQUAL: number;
  60876. /** 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 */
  60877. static readonly NOTEQUAL: number;
  60878. /** Passed to stencilOperation to specify that stencil value must be kept */
  60879. static readonly KEEP: number;
  60880. /** Passed to stencilOperation to specify that stencil value must be replaced */
  60881. static readonly REPLACE: number;
  60882. /** Passed to stencilOperation to specify that stencil value must be incremented */
  60883. static readonly INCR: number;
  60884. /** Passed to stencilOperation to specify that stencil value must be decremented */
  60885. static readonly DECR: number;
  60886. /** Passed to stencilOperation to specify that stencil value must be inverted */
  60887. static readonly INVERT: number;
  60888. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  60889. static readonly INCR_WRAP: number;
  60890. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  60891. static readonly DECR_WRAP: number;
  60892. /** Texture is not repeating outside of 0..1 UVs */
  60893. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  60894. /** Texture is repeating outside of 0..1 UVs */
  60895. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  60896. /** Texture is repeating and mirrored */
  60897. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  60898. /** ALPHA */
  60899. static readonly TEXTUREFORMAT_ALPHA: number;
  60900. /** LUMINANCE */
  60901. static readonly TEXTUREFORMAT_LUMINANCE: number;
  60902. /** LUMINANCE_ALPHA */
  60903. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  60904. /** RGB */
  60905. static readonly TEXTUREFORMAT_RGB: number;
  60906. /** RGBA */
  60907. static readonly TEXTUREFORMAT_RGBA: number;
  60908. /** RED */
  60909. static readonly TEXTUREFORMAT_RED: number;
  60910. /** RED (2nd reference) */
  60911. static readonly TEXTUREFORMAT_R: number;
  60912. /** RG */
  60913. static readonly TEXTUREFORMAT_RG: number;
  60914. /** RED_INTEGER */
  60915. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  60916. /** RED_INTEGER (2nd reference) */
  60917. static readonly TEXTUREFORMAT_R_INTEGER: number;
  60918. /** RG_INTEGER */
  60919. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  60920. /** RGB_INTEGER */
  60921. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  60922. /** RGBA_INTEGER */
  60923. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  60924. /** UNSIGNED_BYTE */
  60925. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  60926. /** UNSIGNED_BYTE (2nd reference) */
  60927. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  60928. /** FLOAT */
  60929. static readonly TEXTURETYPE_FLOAT: number;
  60930. /** HALF_FLOAT */
  60931. static readonly TEXTURETYPE_HALF_FLOAT: number;
  60932. /** BYTE */
  60933. static readonly TEXTURETYPE_BYTE: number;
  60934. /** SHORT */
  60935. static readonly TEXTURETYPE_SHORT: number;
  60936. /** UNSIGNED_SHORT */
  60937. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  60938. /** INT */
  60939. static readonly TEXTURETYPE_INT: number;
  60940. /** UNSIGNED_INT */
  60941. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  60942. /** UNSIGNED_SHORT_4_4_4_4 */
  60943. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  60944. /** UNSIGNED_SHORT_5_5_5_1 */
  60945. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  60946. /** UNSIGNED_SHORT_5_6_5 */
  60947. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  60948. /** UNSIGNED_INT_2_10_10_10_REV */
  60949. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  60950. /** UNSIGNED_INT_24_8 */
  60951. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  60952. /** UNSIGNED_INT_10F_11F_11F_REV */
  60953. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  60954. /** UNSIGNED_INT_5_9_9_9_REV */
  60955. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  60956. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  60957. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60958. /** nearest is mag = nearest and min = nearest and mip = linear */
  60959. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  60960. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60961. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  60962. /** Trilinear is mag = linear and min = linear and mip = linear */
  60963. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  60964. /** nearest is mag = nearest and min = nearest and mip = linear */
  60965. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  60966. /** Bilinear is mag = linear and min = linear and mip = nearest */
  60967. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  60968. /** Trilinear is mag = linear and min = linear and mip = linear */
  60969. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  60970. /** mag = nearest and min = nearest and mip = nearest */
  60971. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  60972. /** mag = nearest and min = linear and mip = nearest */
  60973. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  60974. /** mag = nearest and min = linear and mip = linear */
  60975. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  60976. /** mag = nearest and min = linear and mip = none */
  60977. static readonly TEXTURE_NEAREST_LINEAR: number;
  60978. /** mag = nearest and min = nearest and mip = none */
  60979. static readonly TEXTURE_NEAREST_NEAREST: number;
  60980. /** mag = linear and min = nearest and mip = nearest */
  60981. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  60982. /** mag = linear and min = nearest and mip = linear */
  60983. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  60984. /** mag = linear and min = linear and mip = none */
  60985. static readonly TEXTURE_LINEAR_LINEAR: number;
  60986. /** mag = linear and min = nearest and mip = none */
  60987. static readonly TEXTURE_LINEAR_NEAREST: number;
  60988. /** Explicit coordinates mode */
  60989. static readonly TEXTURE_EXPLICIT_MODE: number;
  60990. /** Spherical coordinates mode */
  60991. static readonly TEXTURE_SPHERICAL_MODE: number;
  60992. /** Planar coordinates mode */
  60993. static readonly TEXTURE_PLANAR_MODE: number;
  60994. /** Cubic coordinates mode */
  60995. static readonly TEXTURE_CUBIC_MODE: number;
  60996. /** Projection coordinates mode */
  60997. static readonly TEXTURE_PROJECTION_MODE: number;
  60998. /** Skybox coordinates mode */
  60999. static readonly TEXTURE_SKYBOX_MODE: number;
  61000. /** Inverse Cubic coordinates mode */
  61001. static readonly TEXTURE_INVCUBIC_MODE: number;
  61002. /** Equirectangular coordinates mode */
  61003. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  61004. /** Equirectangular Fixed coordinates mode */
  61005. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  61006. /** Equirectangular Fixed Mirrored coordinates mode */
  61007. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  61008. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  61009. static readonly SCALEMODE_FLOOR: number;
  61010. /** Defines that texture rescaling will look for the nearest power of 2 size */
  61011. static readonly SCALEMODE_NEAREST: number;
  61012. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  61013. static readonly SCALEMODE_CEILING: number;
  61014. /**
  61015. * The dirty texture flag value
  61016. */
  61017. static readonly MATERIAL_TextureDirtyFlag: number;
  61018. /**
  61019. * The dirty light flag value
  61020. */
  61021. static readonly MATERIAL_LightDirtyFlag: number;
  61022. /**
  61023. * The dirty fresnel flag value
  61024. */
  61025. static readonly MATERIAL_FresnelDirtyFlag: number;
  61026. /**
  61027. * The dirty attribute flag value
  61028. */
  61029. static readonly MATERIAL_AttributesDirtyFlag: number;
  61030. /**
  61031. * The dirty misc flag value
  61032. */
  61033. static readonly MATERIAL_MiscDirtyFlag: number;
  61034. /**
  61035. * The all dirty flag value
  61036. */
  61037. static readonly MATERIAL_AllDirtyFlag: number;
  61038. /**
  61039. * Returns the triangle fill mode
  61040. */
  61041. static readonly MATERIAL_TriangleFillMode: number;
  61042. /**
  61043. * Returns the wireframe mode
  61044. */
  61045. static readonly MATERIAL_WireFrameFillMode: number;
  61046. /**
  61047. * Returns the point fill mode
  61048. */
  61049. static readonly MATERIAL_PointFillMode: number;
  61050. /**
  61051. * Returns the point list draw mode
  61052. */
  61053. static readonly MATERIAL_PointListDrawMode: number;
  61054. /**
  61055. * Returns the line list draw mode
  61056. */
  61057. static readonly MATERIAL_LineListDrawMode: number;
  61058. /**
  61059. * Returns the line loop draw mode
  61060. */
  61061. static readonly MATERIAL_LineLoopDrawMode: number;
  61062. /**
  61063. * Returns the line strip draw mode
  61064. */
  61065. static readonly MATERIAL_LineStripDrawMode: number;
  61066. /**
  61067. * Returns the triangle strip draw mode
  61068. */
  61069. static readonly MATERIAL_TriangleStripDrawMode: number;
  61070. /**
  61071. * Returns the triangle fan draw mode
  61072. */
  61073. static readonly MATERIAL_TriangleFanDrawMode: number;
  61074. /**
  61075. * Stores the clock-wise side orientation
  61076. */
  61077. static readonly MATERIAL_ClockWiseSideOrientation: number;
  61078. /**
  61079. * Stores the counter clock-wise side orientation
  61080. */
  61081. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  61082. /**
  61083. * Nothing
  61084. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61085. */
  61086. static readonly ACTION_NothingTrigger: number;
  61087. /**
  61088. * On pick
  61089. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61090. */
  61091. static readonly ACTION_OnPickTrigger: number;
  61092. /**
  61093. * On left pick
  61094. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61095. */
  61096. static readonly ACTION_OnLeftPickTrigger: number;
  61097. /**
  61098. * On right pick
  61099. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61100. */
  61101. static readonly ACTION_OnRightPickTrigger: number;
  61102. /**
  61103. * On center pick
  61104. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61105. */
  61106. static readonly ACTION_OnCenterPickTrigger: number;
  61107. /**
  61108. * On pick down
  61109. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61110. */
  61111. static readonly ACTION_OnPickDownTrigger: number;
  61112. /**
  61113. * On double pick
  61114. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61115. */
  61116. static readonly ACTION_OnDoublePickTrigger: number;
  61117. /**
  61118. * On pick up
  61119. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61120. */
  61121. static readonly ACTION_OnPickUpTrigger: number;
  61122. /**
  61123. * On pick out.
  61124. * This trigger will only be raised if you also declared a OnPickDown
  61125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61126. */
  61127. static readonly ACTION_OnPickOutTrigger: number;
  61128. /**
  61129. * On long press
  61130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61131. */
  61132. static readonly ACTION_OnLongPressTrigger: number;
  61133. /**
  61134. * On pointer over
  61135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61136. */
  61137. static readonly ACTION_OnPointerOverTrigger: number;
  61138. /**
  61139. * On pointer out
  61140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61141. */
  61142. static readonly ACTION_OnPointerOutTrigger: number;
  61143. /**
  61144. * On every frame
  61145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61146. */
  61147. static readonly ACTION_OnEveryFrameTrigger: number;
  61148. /**
  61149. * On intersection enter
  61150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61151. */
  61152. static readonly ACTION_OnIntersectionEnterTrigger: number;
  61153. /**
  61154. * On intersection exit
  61155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61156. */
  61157. static readonly ACTION_OnIntersectionExitTrigger: number;
  61158. /**
  61159. * On key down
  61160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61161. */
  61162. static readonly ACTION_OnKeyDownTrigger: number;
  61163. /**
  61164. * On key up
  61165. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  61166. */
  61167. static readonly ACTION_OnKeyUpTrigger: number;
  61168. /**
  61169. * Billboard mode will only apply to Y axis
  61170. */
  61171. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  61172. /**
  61173. * Billboard mode will apply to all axes
  61174. */
  61175. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  61176. /**
  61177. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  61178. */
  61179. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  61180. /**
  61181. * Gets or sets base Assets URL
  61182. */
  61183. static readonly PARTICLES_BaseAssetsUrl: string;
  61184. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  61185. * Test order :
  61186. * Is the bounding sphere outside the frustum ?
  61187. * If not, are the bounding box vertices outside the frustum ?
  61188. * It not, then the cullable object is in the frustum.
  61189. */
  61190. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  61191. /** Culling strategy : Bounding Sphere Only.
  61192. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  61193. * It's also less accurate than the standard because some not visible objects can still be selected.
  61194. * Test : is the bounding sphere outside the frustum ?
  61195. * If not, then the cullable object is in the frustum.
  61196. */
  61197. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  61198. /** Culling strategy : Optimistic Inclusion.
  61199. * This in an inclusion test first, then the standard exclusion test.
  61200. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  61201. * 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.
  61202. * Anyway, it's as accurate as the standard strategy.
  61203. * Test :
  61204. * Is the cullable object bounding sphere center in the frustum ?
  61205. * If not, apply the default culling strategy.
  61206. */
  61207. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  61208. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  61209. * This in an inclusion test first, then the bounding sphere only exclusion test.
  61210. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  61211. * 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.
  61212. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  61213. * Test :
  61214. * Is the cullable object bounding sphere center in the frustum ?
  61215. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  61216. */
  61217. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  61218. /**
  61219. * No logging while loading
  61220. */
  61221. static readonly SCENELOADER_NO_LOGGING: number;
  61222. /**
  61223. * Minimal logging while loading
  61224. */
  61225. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  61226. /**
  61227. * Summary logging while loading
  61228. */
  61229. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  61230. /**
  61231. * Detailled logging while loading
  61232. */
  61233. static readonly SCENELOADER_DETAILED_LOGGING: number;
  61234. }
  61235. }
  61236. declare module BABYLON {
  61237. /**
  61238. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  61239. * Babylon.js
  61240. */
  61241. export class DomManagement {
  61242. /**
  61243. * Checks if the window object exists
  61244. * @returns true if the window object exists
  61245. */
  61246. static IsWindowObjectExist(): boolean;
  61247. /**
  61248. * Extracts text content from a DOM element hierarchy
  61249. * @param element defines the root element
  61250. * @returns a string
  61251. */
  61252. static GetDOMTextContent(element: HTMLElement): string;
  61253. }
  61254. }
  61255. declare module BABYLON {
  61256. /**
  61257. * Logger used througouht the application to allow configuration of
  61258. * the log level required for the messages.
  61259. */
  61260. export class Logger {
  61261. /**
  61262. * No log
  61263. */
  61264. static readonly NoneLogLevel: number;
  61265. /**
  61266. * Only message logs
  61267. */
  61268. static readonly MessageLogLevel: number;
  61269. /**
  61270. * Only warning logs
  61271. */
  61272. static readonly WarningLogLevel: number;
  61273. /**
  61274. * Only error logs
  61275. */
  61276. static readonly ErrorLogLevel: number;
  61277. /**
  61278. * All logs
  61279. */
  61280. static readonly AllLogLevel: number;
  61281. private static _LogCache;
  61282. /**
  61283. * Gets a value indicating the number of loading errors
  61284. * @ignorenaming
  61285. */
  61286. static errorsCount: number;
  61287. /**
  61288. * Callback called when a new log is added
  61289. */
  61290. static OnNewCacheEntry: (entry: string) => void;
  61291. private static _AddLogEntry;
  61292. private static _FormatMessage;
  61293. private static _LogDisabled;
  61294. private static _LogEnabled;
  61295. private static _WarnDisabled;
  61296. private static _WarnEnabled;
  61297. private static _ErrorDisabled;
  61298. private static _ErrorEnabled;
  61299. /**
  61300. * Log a message to the console
  61301. */
  61302. static Log: (message: string) => void;
  61303. /**
  61304. * Write a warning message to the console
  61305. */
  61306. static Warn: (message: string) => void;
  61307. /**
  61308. * Write an error message to the console
  61309. */
  61310. static Error: (message: string) => void;
  61311. /**
  61312. * Gets current log cache (list of logs)
  61313. */
  61314. static readonly LogCache: string;
  61315. /**
  61316. * Clears the log cache
  61317. */
  61318. static ClearLogCache(): void;
  61319. /**
  61320. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  61321. */
  61322. static LogLevels: number;
  61323. }
  61324. }
  61325. declare module BABYLON {
  61326. /** @hidden */
  61327. export class _TypeStore {
  61328. /** @hidden */
  61329. static RegisteredTypes: {
  61330. [key: string]: Object;
  61331. };
  61332. /** @hidden */
  61333. static GetClass(fqdn: string): any;
  61334. }
  61335. }
  61336. declare module BABYLON {
  61337. /**
  61338. * Class containing a set of static utilities functions for deep copy.
  61339. */
  61340. export class DeepCopier {
  61341. /**
  61342. * Tries to copy an object by duplicating every property
  61343. * @param source defines the source object
  61344. * @param destination defines the target object
  61345. * @param doNotCopyList defines a list of properties to avoid
  61346. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  61347. */
  61348. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  61349. }
  61350. }
  61351. declare module BABYLON {
  61352. /**
  61353. * Class containing a set of static utilities functions for precision date
  61354. */
  61355. export class PrecisionDate {
  61356. /**
  61357. * Gets either window.performance.now() if supported or Date.now() else
  61358. */
  61359. static readonly Now: number;
  61360. }
  61361. }
  61362. declare module BABYLON {
  61363. /**
  61364. * Class used to evalaute queries containing `and` and `or` operators
  61365. */
  61366. export class AndOrNotEvaluator {
  61367. /**
  61368. * Evaluate a query
  61369. * @param query defines the query to evaluate
  61370. * @param evaluateCallback defines the callback used to filter result
  61371. * @returns true if the query matches
  61372. */
  61373. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  61374. private static _HandleParenthesisContent;
  61375. private static _SimplifyNegation;
  61376. }
  61377. }
  61378. declare module BABYLON {
  61379. /**
  61380. * Class used to store custom tags
  61381. */
  61382. export class Tags {
  61383. /**
  61384. * Adds support for tags on the given object
  61385. * @param obj defines the object to use
  61386. */
  61387. static EnableFor(obj: any): void;
  61388. /**
  61389. * Removes tags support
  61390. * @param obj defines the object to use
  61391. */
  61392. static DisableFor(obj: any): void;
  61393. /**
  61394. * Gets a boolean indicating if the given object has tags
  61395. * @param obj defines the object to use
  61396. * @returns a boolean
  61397. */
  61398. static HasTags(obj: any): boolean;
  61399. /**
  61400. * Gets the tags available on a given object
  61401. * @param obj defines the object to use
  61402. * @param asString defines if the tags must be returned as a string instead of an array of strings
  61403. * @returns the tags
  61404. */
  61405. static GetTags(obj: any, asString?: boolean): any;
  61406. /**
  61407. * Adds tags to an object
  61408. * @param obj defines the object to use
  61409. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  61410. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  61411. */
  61412. static AddTagsTo(obj: any, tagsString: string): void;
  61413. /**
  61414. * @hidden
  61415. */
  61416. static _AddTagTo(obj: any, tag: string): void;
  61417. /**
  61418. * Removes specific tags from a specific object
  61419. * @param obj defines the object to use
  61420. * @param tagsString defines the tags to remove
  61421. */
  61422. static RemoveTagsFrom(obj: any, tagsString: string): void;
  61423. /**
  61424. * @hidden
  61425. */
  61426. static _RemoveTagFrom(obj: any, tag: string): void;
  61427. /**
  61428. * Defines if tags hosted on an object match a given query
  61429. * @param obj defines the object to use
  61430. * @param tagsQuery defines the tag query
  61431. * @returns a boolean
  61432. */
  61433. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  61434. }
  61435. }
  61436. declare module BABYLON {
  61437. /**
  61438. * Manages the defines for the Material
  61439. */
  61440. export class MaterialDefines {
  61441. private _keys;
  61442. private _isDirty;
  61443. /** @hidden */
  61444. _renderId: number;
  61445. /** @hidden */
  61446. _areLightsDirty: boolean;
  61447. /** @hidden */
  61448. _areAttributesDirty: boolean;
  61449. /** @hidden */
  61450. _areTexturesDirty: boolean;
  61451. /** @hidden */
  61452. _areFresnelDirty: boolean;
  61453. /** @hidden */
  61454. _areMiscDirty: boolean;
  61455. /** @hidden */
  61456. _areImageProcessingDirty: boolean;
  61457. /** @hidden */
  61458. _normals: boolean;
  61459. /** @hidden */
  61460. _uvs: boolean;
  61461. /** @hidden */
  61462. _needNormals: boolean;
  61463. /** @hidden */
  61464. _needUVs: boolean;
  61465. /**
  61466. * Specifies if the material needs to be re-calculated
  61467. */
  61468. readonly isDirty: boolean;
  61469. /**
  61470. * Marks the material to indicate that it has been re-calculated
  61471. */
  61472. markAsProcessed(): void;
  61473. /**
  61474. * Marks the material to indicate that it needs to be re-calculated
  61475. */
  61476. markAsUnprocessed(): void;
  61477. /**
  61478. * Marks the material to indicate all of its defines need to be re-calculated
  61479. */
  61480. markAllAsDirty(): void;
  61481. /**
  61482. * Marks the material to indicate that image processing needs to be re-calculated
  61483. */
  61484. markAsImageProcessingDirty(): void;
  61485. /**
  61486. * Marks the material to indicate the lights need to be re-calculated
  61487. */
  61488. markAsLightDirty(): void;
  61489. /**
  61490. * Marks the attribute state as changed
  61491. */
  61492. markAsAttributesDirty(): void;
  61493. /**
  61494. * Marks the texture state as changed
  61495. */
  61496. markAsTexturesDirty(): void;
  61497. /**
  61498. * Marks the fresnel state as changed
  61499. */
  61500. markAsFresnelDirty(): void;
  61501. /**
  61502. * Marks the misc state as changed
  61503. */
  61504. markAsMiscDirty(): void;
  61505. /**
  61506. * Rebuilds the material defines
  61507. */
  61508. rebuild(): void;
  61509. /**
  61510. * Specifies if two material defines are equal
  61511. * @param other - A material define instance to compare to
  61512. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  61513. */
  61514. isEqual(other: MaterialDefines): boolean;
  61515. /**
  61516. * Clones this instance's defines to another instance
  61517. * @param other - material defines to clone values to
  61518. */
  61519. cloneTo(other: MaterialDefines): void;
  61520. /**
  61521. * Resets the material define values
  61522. */
  61523. reset(): void;
  61524. /**
  61525. * Converts the material define values to a string
  61526. * @returns - String of material define information
  61527. */
  61528. toString(): string;
  61529. }
  61530. }
  61531. declare module BABYLON {
  61532. /**
  61533. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  61534. */
  61535. export class PerformanceMonitor {
  61536. private _enabled;
  61537. private _rollingFrameTime;
  61538. private _lastFrameTimeMs;
  61539. /**
  61540. * constructor
  61541. * @param frameSampleSize The number of samples required to saturate the sliding window
  61542. */
  61543. constructor(frameSampleSize?: number);
  61544. /**
  61545. * Samples current frame
  61546. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  61547. */
  61548. sampleFrame(timeMs?: number): void;
  61549. /**
  61550. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61551. */
  61552. readonly averageFrameTime: number;
  61553. /**
  61554. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  61555. */
  61556. readonly averageFrameTimeVariance: number;
  61557. /**
  61558. * Returns the frame time of the most recent frame
  61559. */
  61560. readonly instantaneousFrameTime: number;
  61561. /**
  61562. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  61563. */
  61564. readonly averageFPS: number;
  61565. /**
  61566. * Returns the average framerate in frames per second using the most recent frame time
  61567. */
  61568. readonly instantaneousFPS: number;
  61569. /**
  61570. * Returns true if enough samples have been taken to completely fill the sliding window
  61571. */
  61572. readonly isSaturated: boolean;
  61573. /**
  61574. * Enables contributions to the sliding window sample set
  61575. */
  61576. enable(): void;
  61577. /**
  61578. * Disables contributions to the sliding window sample set
  61579. * Samples will not be interpolated over the disabled period
  61580. */
  61581. disable(): void;
  61582. /**
  61583. * Returns true if sampling is enabled
  61584. */
  61585. readonly isEnabled: boolean;
  61586. /**
  61587. * Resets performance monitor
  61588. */
  61589. reset(): void;
  61590. }
  61591. /**
  61592. * RollingAverage
  61593. *
  61594. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  61595. */
  61596. export class RollingAverage {
  61597. /**
  61598. * Current average
  61599. */
  61600. average: number;
  61601. /**
  61602. * Current variance
  61603. */
  61604. variance: number;
  61605. protected _samples: Array<number>;
  61606. protected _sampleCount: number;
  61607. protected _pos: number;
  61608. protected _m2: number;
  61609. /**
  61610. * constructor
  61611. * @param length The number of samples required to saturate the sliding window
  61612. */
  61613. constructor(length: number);
  61614. /**
  61615. * Adds a sample to the sample set
  61616. * @param v The sample value
  61617. */
  61618. add(v: number): void;
  61619. /**
  61620. * Returns previously added values or null if outside of history or outside the sliding window domain
  61621. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  61622. * @return Value previously recorded with add() or null if outside of range
  61623. */
  61624. history(i: number): number;
  61625. /**
  61626. * Returns true if enough samples have been taken to completely fill the sliding window
  61627. * @return true if sample-set saturated
  61628. */
  61629. isSaturated(): boolean;
  61630. /**
  61631. * Resets the rolling average (equivalent to 0 samples taken so far)
  61632. */
  61633. reset(): void;
  61634. /**
  61635. * Wraps a value around the sample range boundaries
  61636. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  61637. * @return Wrapped position in sample range
  61638. */
  61639. protected _wrapPosition(i: number): number;
  61640. }
  61641. }
  61642. declare module BABYLON {
  61643. /**
  61644. * This class implement a typical dictionary using a string as key and the generic type T as value.
  61645. * The underlying implementation relies on an associative array to ensure the best performances.
  61646. * The value can be anything including 'null' but except 'undefined'
  61647. */
  61648. export class StringDictionary<T> {
  61649. /**
  61650. * This will clear this dictionary and copy the content from the 'source' one.
  61651. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  61652. * @param source the dictionary to take the content from and copy to this dictionary
  61653. */
  61654. copyFrom(source: StringDictionary<T>): void;
  61655. /**
  61656. * Get a value based from its key
  61657. * @param key the given key to get the matching value from
  61658. * @return the value if found, otherwise undefined is returned
  61659. */
  61660. get(key: string): T | undefined;
  61661. /**
  61662. * Get a value from its key or add it if it doesn't exist.
  61663. * This method will ensure you that a given key/data will be present in the dictionary.
  61664. * @param key the given key to get the matching value from
  61665. * @param factory the factory that will create the value if the key is not present in the dictionary.
  61666. * The factory will only be invoked if there's no data for the given key.
  61667. * @return the value corresponding to the key.
  61668. */
  61669. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  61670. /**
  61671. * Get a value from its key if present in the dictionary otherwise add it
  61672. * @param key the key to get the value from
  61673. * @param val if there's no such key/value pair in the dictionary add it with this value
  61674. * @return the value corresponding to the key
  61675. */
  61676. getOrAdd(key: string, val: T): T;
  61677. /**
  61678. * Check if there's a given key in the dictionary
  61679. * @param key the key to check for
  61680. * @return true if the key is present, false otherwise
  61681. */
  61682. contains(key: string): boolean;
  61683. /**
  61684. * Add a new key and its corresponding value
  61685. * @param key the key to add
  61686. * @param value the value corresponding to the key
  61687. * @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
  61688. */
  61689. add(key: string, value: T): boolean;
  61690. /**
  61691. * Update a specific value associated to a key
  61692. * @param key defines the key to use
  61693. * @param value defines the value to store
  61694. * @returns true if the value was updated (or false if the key was not found)
  61695. */
  61696. set(key: string, value: T): boolean;
  61697. /**
  61698. * Get the element of the given key and remove it from the dictionary
  61699. * @param key defines the key to search
  61700. * @returns the value associated with the key or null if not found
  61701. */
  61702. getAndRemove(key: string): Nullable<T>;
  61703. /**
  61704. * Remove a key/value from the dictionary.
  61705. * @param key the key to remove
  61706. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  61707. */
  61708. remove(key: string): boolean;
  61709. /**
  61710. * Clear the whole content of the dictionary
  61711. */
  61712. clear(): void;
  61713. /**
  61714. * Gets the current count
  61715. */
  61716. readonly count: number;
  61717. /**
  61718. * Execute a callback on each key/val of the dictionary.
  61719. * Note that you can remove any element in this dictionary in the callback implementation
  61720. * @param callback the callback to execute on a given key/value pair
  61721. */
  61722. forEach(callback: (key: string, val: T) => void): void;
  61723. /**
  61724. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  61725. * If the callback returns null or undefined the method will iterate to the next key/value pair
  61726. * Note that you can remove any element in this dictionary in the callback implementation
  61727. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  61728. * @returns the first item
  61729. */
  61730. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  61731. private _count;
  61732. private _data;
  61733. }
  61734. }
  61735. declare module BABYLON {
  61736. /**
  61737. * Helper class that provides a small promise polyfill
  61738. */
  61739. export class PromisePolyfill {
  61740. /**
  61741. * Static function used to check if the polyfill is required
  61742. * If this is the case then the function will inject the polyfill to window.Promise
  61743. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  61744. */
  61745. static Apply(force?: boolean): void;
  61746. }
  61747. }
  61748. declare module BABYLON {
  61749. /**
  61750. * Class used to store data that will be store in GPU memory
  61751. */
  61752. export class Buffer {
  61753. private _engine;
  61754. private _buffer;
  61755. /** @hidden */
  61756. _data: Nullable<DataArray>;
  61757. private _updatable;
  61758. private _instanced;
  61759. /**
  61760. * Gets the byte stride.
  61761. */
  61762. readonly byteStride: number;
  61763. /**
  61764. * Constructor
  61765. * @param engine the engine
  61766. * @param data the data to use for this buffer
  61767. * @param updatable whether the data is updatable
  61768. * @param stride the stride (optional)
  61769. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61770. * @param instanced whether the buffer is instanced (optional)
  61771. * @param useBytes set to true if the stride in in bytes (optional)
  61772. */
  61773. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  61774. /**
  61775. * Create a new VertexBuffer based on the current buffer
  61776. * @param kind defines the vertex buffer kind (position, normal, etc.)
  61777. * @param offset defines offset in the buffer (0 by default)
  61778. * @param size defines the size in floats of attributes (position is 3 for instance)
  61779. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  61780. * @param instanced defines if the vertex buffer contains indexed data
  61781. * @param useBytes defines if the offset and stride are in bytes
  61782. * @returns the new vertex buffer
  61783. */
  61784. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  61785. /**
  61786. * Gets a boolean indicating if the Buffer is updatable?
  61787. * @returns true if the buffer is updatable
  61788. */
  61789. isUpdatable(): boolean;
  61790. /**
  61791. * Gets current buffer's data
  61792. * @returns a DataArray or null
  61793. */
  61794. getData(): Nullable<DataArray>;
  61795. /**
  61796. * Gets underlying native buffer
  61797. * @returns underlying native buffer
  61798. */
  61799. getBuffer(): Nullable<WebGLBuffer>;
  61800. /**
  61801. * Gets the stride in float32 units (i.e. byte stride / 4).
  61802. * May not be an integer if the byte stride is not divisible by 4.
  61803. * DEPRECATED. Use byteStride instead.
  61804. * @returns the stride in float32 units
  61805. */
  61806. getStrideSize(): number;
  61807. /**
  61808. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61809. * @param data defines the data to store
  61810. */
  61811. create(data?: Nullable<DataArray>): void;
  61812. /** @hidden */
  61813. _rebuild(): void;
  61814. /**
  61815. * Update current buffer data
  61816. * @param data defines the data to store
  61817. */
  61818. update(data: DataArray): void;
  61819. /**
  61820. * Updates the data directly.
  61821. * @param data the new data
  61822. * @param offset the new offset
  61823. * @param vertexCount the vertex count (optional)
  61824. * @param useBytes set to true if the offset is in bytes
  61825. */
  61826. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  61827. /**
  61828. * Release all resources
  61829. */
  61830. dispose(): void;
  61831. }
  61832. /**
  61833. * Specialized buffer used to store vertex data
  61834. */
  61835. export class VertexBuffer {
  61836. /** @hidden */
  61837. _buffer: Buffer;
  61838. private _kind;
  61839. private _size;
  61840. private _ownsBuffer;
  61841. private _instanced;
  61842. private _instanceDivisor;
  61843. /**
  61844. * The byte type.
  61845. */
  61846. static readonly BYTE: number;
  61847. /**
  61848. * The unsigned byte type.
  61849. */
  61850. static readonly UNSIGNED_BYTE: number;
  61851. /**
  61852. * The short type.
  61853. */
  61854. static readonly SHORT: number;
  61855. /**
  61856. * The unsigned short type.
  61857. */
  61858. static readonly UNSIGNED_SHORT: number;
  61859. /**
  61860. * The integer type.
  61861. */
  61862. static readonly INT: number;
  61863. /**
  61864. * The unsigned integer type.
  61865. */
  61866. static readonly UNSIGNED_INT: number;
  61867. /**
  61868. * The float type.
  61869. */
  61870. static readonly FLOAT: number;
  61871. /**
  61872. * Gets or sets the instance divisor when in instanced mode
  61873. */
  61874. instanceDivisor: number;
  61875. /**
  61876. * Gets the byte stride.
  61877. */
  61878. readonly byteStride: number;
  61879. /**
  61880. * Gets the byte offset.
  61881. */
  61882. readonly byteOffset: number;
  61883. /**
  61884. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  61885. */
  61886. readonly normalized: boolean;
  61887. /**
  61888. * Gets the data type of each component in the array.
  61889. */
  61890. readonly type: number;
  61891. /**
  61892. * Constructor
  61893. * @param engine the engine
  61894. * @param data the data to use for this vertex buffer
  61895. * @param kind the vertex buffer kind
  61896. * @param updatable whether the data is updatable
  61897. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  61898. * @param stride the stride (optional)
  61899. * @param instanced whether the buffer is instanced (optional)
  61900. * @param offset the offset of the data (optional)
  61901. * @param size the number of components (optional)
  61902. * @param type the type of the component (optional)
  61903. * @param normalized whether the data contains normalized data (optional)
  61904. * @param useBytes set to true if stride and offset are in bytes (optional)
  61905. */
  61906. 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);
  61907. /** @hidden */
  61908. _rebuild(): void;
  61909. /**
  61910. * Returns the kind of the VertexBuffer (string)
  61911. * @returns a string
  61912. */
  61913. getKind(): string;
  61914. /**
  61915. * Gets a boolean indicating if the VertexBuffer is updatable?
  61916. * @returns true if the buffer is updatable
  61917. */
  61918. isUpdatable(): boolean;
  61919. /**
  61920. * Gets current buffer's data
  61921. * @returns a DataArray or null
  61922. */
  61923. getData(): Nullable<DataArray>;
  61924. /**
  61925. * Gets underlying native buffer
  61926. * @returns underlying native buffer
  61927. */
  61928. getBuffer(): Nullable<WebGLBuffer>;
  61929. /**
  61930. * Gets the stride in float32 units (i.e. byte stride / 4).
  61931. * May not be an integer if the byte stride is not divisible by 4.
  61932. * DEPRECATED. Use byteStride instead.
  61933. * @returns the stride in float32 units
  61934. */
  61935. getStrideSize(): number;
  61936. /**
  61937. * Returns the offset as a multiple of the type byte length.
  61938. * DEPRECATED. Use byteOffset instead.
  61939. * @returns the offset in bytes
  61940. */
  61941. getOffset(): number;
  61942. /**
  61943. * Returns the number of components per vertex attribute (integer)
  61944. * @returns the size in float
  61945. */
  61946. getSize(): number;
  61947. /**
  61948. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  61949. * @returns true if this buffer is instanced
  61950. */
  61951. getIsInstanced(): boolean;
  61952. /**
  61953. * Returns the instancing divisor, zero for non-instanced (integer).
  61954. * @returns a number
  61955. */
  61956. getInstanceDivisor(): number;
  61957. /**
  61958. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  61959. * @param data defines the data to store
  61960. */
  61961. create(data?: DataArray): void;
  61962. /**
  61963. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  61964. * This function will create a new buffer if the current one is not updatable
  61965. * @param data defines the data to store
  61966. */
  61967. update(data: DataArray): void;
  61968. /**
  61969. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  61970. * Returns the directly updated WebGLBuffer.
  61971. * @param data the new data
  61972. * @param offset the new offset
  61973. * @param useBytes set to true if the offset is in bytes
  61974. */
  61975. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  61976. /**
  61977. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  61978. */
  61979. dispose(): void;
  61980. /**
  61981. * Enumerates each value of this vertex buffer as numbers.
  61982. * @param count the number of values to enumerate
  61983. * @param callback the callback function called for each value
  61984. */
  61985. forEach(count: number, callback: (value: number, index: number) => void): void;
  61986. /**
  61987. * Positions
  61988. */
  61989. static readonly PositionKind: string;
  61990. /**
  61991. * Normals
  61992. */
  61993. static readonly NormalKind: string;
  61994. /**
  61995. * Tangents
  61996. */
  61997. static readonly TangentKind: string;
  61998. /**
  61999. * Texture coordinates
  62000. */
  62001. static readonly UVKind: string;
  62002. /**
  62003. * Texture coordinates 2
  62004. */
  62005. static readonly UV2Kind: string;
  62006. /**
  62007. * Texture coordinates 3
  62008. */
  62009. static readonly UV3Kind: string;
  62010. /**
  62011. * Texture coordinates 4
  62012. */
  62013. static readonly UV4Kind: string;
  62014. /**
  62015. * Texture coordinates 5
  62016. */
  62017. static readonly UV5Kind: string;
  62018. /**
  62019. * Texture coordinates 6
  62020. */
  62021. static readonly UV6Kind: string;
  62022. /**
  62023. * Colors
  62024. */
  62025. static readonly ColorKind: string;
  62026. /**
  62027. * Matrix indices (for bones)
  62028. */
  62029. static readonly MatricesIndicesKind: string;
  62030. /**
  62031. * Matrix weights (for bones)
  62032. */
  62033. static readonly MatricesWeightsKind: string;
  62034. /**
  62035. * Additional matrix indices (for bones)
  62036. */
  62037. static readonly MatricesIndicesExtraKind: string;
  62038. /**
  62039. * Additional matrix weights (for bones)
  62040. */
  62041. static readonly MatricesWeightsExtraKind: string;
  62042. /**
  62043. * Deduces the stride given a kind.
  62044. * @param kind The kind string to deduce
  62045. * @returns The deduced stride
  62046. */
  62047. static DeduceStride(kind: string): number;
  62048. /**
  62049. * Gets the byte length of the given type.
  62050. * @param type the type
  62051. * @returns the number of bytes
  62052. */
  62053. static GetTypeByteLength(type: number): number;
  62054. /**
  62055. * Enumerates each value of the given parameters as numbers.
  62056. * @param data the data to enumerate
  62057. * @param byteOffset the byte offset of the data
  62058. * @param byteStride the byte stride of the data
  62059. * @param componentCount the number of components per element
  62060. * @param componentType the type of the component
  62061. * @param count the total number of components
  62062. * @param normalized whether the data is normalized
  62063. * @param callback the callback function called for each value
  62064. */
  62065. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  62066. private static _GetFloatValue;
  62067. }
  62068. }
  62069. declare module BABYLON {
  62070. /**
  62071. * Class representing spherical polynomial coefficients to the 3rd degree
  62072. */
  62073. export class SphericalPolynomial {
  62074. /**
  62075. * The x coefficients of the spherical polynomial
  62076. */
  62077. x: Vector3;
  62078. /**
  62079. * The y coefficients of the spherical polynomial
  62080. */
  62081. y: Vector3;
  62082. /**
  62083. * The z coefficients of the spherical polynomial
  62084. */
  62085. z: Vector3;
  62086. /**
  62087. * The xx coefficients of the spherical polynomial
  62088. */
  62089. xx: Vector3;
  62090. /**
  62091. * The yy coefficients of the spherical polynomial
  62092. */
  62093. yy: Vector3;
  62094. /**
  62095. * The zz coefficients of the spherical polynomial
  62096. */
  62097. zz: Vector3;
  62098. /**
  62099. * The xy coefficients of the spherical polynomial
  62100. */
  62101. xy: Vector3;
  62102. /**
  62103. * The yz coefficients of the spherical polynomial
  62104. */
  62105. yz: Vector3;
  62106. /**
  62107. * The zx coefficients of the spherical polynomial
  62108. */
  62109. zx: Vector3;
  62110. /**
  62111. * Adds an ambient color to the spherical polynomial
  62112. * @param color the color to add
  62113. */
  62114. addAmbient(color: Color3): void;
  62115. /**
  62116. * Scales the spherical polynomial by the given amount
  62117. * @param scale the amount to scale
  62118. */
  62119. scale(scale: number): void;
  62120. /**
  62121. * Gets the spherical polynomial from harmonics
  62122. * @param harmonics the spherical harmonics
  62123. * @returns the spherical polynomial
  62124. */
  62125. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  62126. /**
  62127. * Constructs a spherical polynomial from an array.
  62128. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  62129. * @returns the spherical polynomial
  62130. */
  62131. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  62132. }
  62133. /**
  62134. * Class representing spherical harmonics coefficients to the 3rd degree
  62135. */
  62136. export class SphericalHarmonics {
  62137. /**
  62138. * The l0,0 coefficients of the spherical harmonics
  62139. */
  62140. l00: Vector3;
  62141. /**
  62142. * The l1,-1 coefficients of the spherical harmonics
  62143. */
  62144. l1_1: Vector3;
  62145. /**
  62146. * The l1,0 coefficients of the spherical harmonics
  62147. */
  62148. l10: Vector3;
  62149. /**
  62150. * The l1,1 coefficients of the spherical harmonics
  62151. */
  62152. l11: Vector3;
  62153. /**
  62154. * The l2,-2 coefficients of the spherical harmonics
  62155. */
  62156. l2_2: Vector3;
  62157. /**
  62158. * The l2,-1 coefficients of the spherical harmonics
  62159. */
  62160. l2_1: Vector3;
  62161. /**
  62162. * The l2,0 coefficients of the spherical harmonics
  62163. */
  62164. l20: Vector3;
  62165. /**
  62166. * The l2,1 coefficients of the spherical harmonics
  62167. */
  62168. l21: Vector3;
  62169. /**
  62170. * The l2,2 coefficients of the spherical harmonics
  62171. */
  62172. lL22: Vector3;
  62173. /**
  62174. * Adds a light to the spherical harmonics
  62175. * @param direction the direction of the light
  62176. * @param color the color of the light
  62177. * @param deltaSolidAngle the delta solid angle of the light
  62178. */
  62179. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  62180. /**
  62181. * Scales the spherical harmonics by the given amount
  62182. * @param scale the amount to scale
  62183. */
  62184. scale(scale: number): void;
  62185. /**
  62186. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  62187. *
  62188. * ```
  62189. * E_lm = A_l * L_lm
  62190. * ```
  62191. *
  62192. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  62193. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  62194. * the scaling factors are given in equation 9.
  62195. */
  62196. convertIncidentRadianceToIrradiance(): void;
  62197. /**
  62198. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  62199. *
  62200. * ```
  62201. * L = (1/pi) * E * rho
  62202. * ```
  62203. *
  62204. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  62205. */
  62206. convertIrradianceToLambertianRadiance(): void;
  62207. /**
  62208. * Gets the spherical harmonics from polynomial
  62209. * @param polynomial the spherical polynomial
  62210. * @returns the spherical harmonics
  62211. */
  62212. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  62213. /**
  62214. * Constructs a spherical harmonics from an array.
  62215. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  62216. * @returns the spherical harmonics
  62217. */
  62218. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  62219. }
  62220. }
  62221. declare module BABYLON {
  62222. /**
  62223. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  62224. */
  62225. export interface CubeMapInfo {
  62226. /**
  62227. * The pixel array for the front face.
  62228. * This is stored in format, left to right, up to down format.
  62229. */
  62230. front: Nullable<ArrayBufferView>;
  62231. /**
  62232. * The pixel array for the back face.
  62233. * This is stored in format, left to right, up to down format.
  62234. */
  62235. back: Nullable<ArrayBufferView>;
  62236. /**
  62237. * The pixel array for the left face.
  62238. * This is stored in format, left to right, up to down format.
  62239. */
  62240. left: Nullable<ArrayBufferView>;
  62241. /**
  62242. * The pixel array for the right face.
  62243. * This is stored in format, left to right, up to down format.
  62244. */
  62245. right: Nullable<ArrayBufferView>;
  62246. /**
  62247. * The pixel array for the up face.
  62248. * This is stored in format, left to right, up to down format.
  62249. */
  62250. up: Nullable<ArrayBufferView>;
  62251. /**
  62252. * The pixel array for the down face.
  62253. * This is stored in format, left to right, up to down format.
  62254. */
  62255. down: Nullable<ArrayBufferView>;
  62256. /**
  62257. * The size of the cubemap stored.
  62258. *
  62259. * Each faces will be size * size pixels.
  62260. */
  62261. size: number;
  62262. /**
  62263. * The format of the texture.
  62264. *
  62265. * RGBA, RGB.
  62266. */
  62267. format: number;
  62268. /**
  62269. * The type of the texture data.
  62270. *
  62271. * UNSIGNED_INT, FLOAT.
  62272. */
  62273. type: number;
  62274. /**
  62275. * Specifies whether the texture is in gamma space.
  62276. */
  62277. gammaSpace: boolean;
  62278. }
  62279. /**
  62280. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  62281. */
  62282. export class PanoramaToCubeMapTools {
  62283. private static FACE_FRONT;
  62284. private static FACE_BACK;
  62285. private static FACE_RIGHT;
  62286. private static FACE_LEFT;
  62287. private static FACE_DOWN;
  62288. private static FACE_UP;
  62289. /**
  62290. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  62291. *
  62292. * @param float32Array The source data.
  62293. * @param inputWidth The width of the input panorama.
  62294. * @param inputHeight The height of the input panorama.
  62295. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  62296. * @return The cubemap data
  62297. */
  62298. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  62299. private static CreateCubemapTexture;
  62300. private static CalcProjectionSpherical;
  62301. }
  62302. }
  62303. declare module BABYLON {
  62304. /**
  62305. * Helper class dealing with the extraction of spherical polynomial dataArray
  62306. * from a cube map.
  62307. */
  62308. export class CubeMapToSphericalPolynomialTools {
  62309. private static FileFaces;
  62310. /**
  62311. * Converts a texture to the according Spherical Polynomial data.
  62312. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62313. *
  62314. * @param texture The texture to extract the information from.
  62315. * @return The Spherical Polynomial data.
  62316. */
  62317. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  62318. /**
  62319. * Converts a cubemap to the according Spherical Polynomial data.
  62320. * This extracts the first 3 orders only as they are the only one used in the lighting.
  62321. *
  62322. * @param cubeInfo The Cube map to extract the information from.
  62323. * @return The Spherical Polynomial data.
  62324. */
  62325. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  62326. }
  62327. }
  62328. declare module BABYLON {
  62329. /**
  62330. * The engine store class is responsible to hold all the instances of Engine and Scene created
  62331. * during the life time of the application.
  62332. */
  62333. export class EngineStore {
  62334. /** Gets the list of created engines */
  62335. static Instances: Engine[];
  62336. /**
  62337. * Gets the latest created engine
  62338. */
  62339. static readonly LastCreatedEngine: Nullable<Engine>;
  62340. /**
  62341. * Gets the latest created scene
  62342. */
  62343. static readonly LastCreatedScene: Nullable<Scene>;
  62344. }
  62345. }
  62346. declare module BABYLON {
  62347. /**
  62348. * Define options used to create a render target texture
  62349. */
  62350. export class RenderTargetCreationOptions {
  62351. /**
  62352. * Specifies is mipmaps must be generated
  62353. */
  62354. generateMipMaps?: boolean;
  62355. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  62356. generateDepthBuffer?: boolean;
  62357. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  62358. generateStencilBuffer?: boolean;
  62359. /** Defines texture type (int by default) */
  62360. type?: number;
  62361. /** Defines sampling mode (trilinear by default) */
  62362. samplingMode?: number;
  62363. /** Defines format (RGBA by default) */
  62364. format?: number;
  62365. }
  62366. }
  62367. declare module BABYLON {
  62368. /**
  62369. * @hidden
  62370. **/
  62371. export class _AlphaState {
  62372. private _isAlphaBlendDirty;
  62373. private _isBlendFunctionParametersDirty;
  62374. private _isBlendEquationParametersDirty;
  62375. private _isBlendConstantsDirty;
  62376. private _alphaBlend;
  62377. private _blendFunctionParameters;
  62378. private _blendEquationParameters;
  62379. private _blendConstants;
  62380. /**
  62381. * Initializes the state.
  62382. */
  62383. constructor();
  62384. readonly isDirty: boolean;
  62385. alphaBlend: boolean;
  62386. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  62387. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  62388. setAlphaEquationParameters(rgb: number, alpha: number): void;
  62389. reset(): void;
  62390. apply(gl: WebGLRenderingContext): void;
  62391. }
  62392. }
  62393. declare module BABYLON {
  62394. /**
  62395. * @hidden
  62396. **/
  62397. export class _DepthCullingState {
  62398. private _isDepthTestDirty;
  62399. private _isDepthMaskDirty;
  62400. private _isDepthFuncDirty;
  62401. private _isCullFaceDirty;
  62402. private _isCullDirty;
  62403. private _isZOffsetDirty;
  62404. private _isFrontFaceDirty;
  62405. private _depthTest;
  62406. private _depthMask;
  62407. private _depthFunc;
  62408. private _cull;
  62409. private _cullFace;
  62410. private _zOffset;
  62411. private _frontFace;
  62412. /**
  62413. * Initializes the state.
  62414. */
  62415. constructor();
  62416. readonly isDirty: boolean;
  62417. zOffset: number;
  62418. cullFace: Nullable<number>;
  62419. cull: Nullable<boolean>;
  62420. depthFunc: Nullable<number>;
  62421. depthMask: boolean;
  62422. depthTest: boolean;
  62423. frontFace: Nullable<number>;
  62424. reset(): void;
  62425. apply(gl: WebGLRenderingContext): void;
  62426. }
  62427. }
  62428. declare module BABYLON {
  62429. /**
  62430. * @hidden
  62431. **/
  62432. export class _StencilState {
  62433. /** 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 */
  62434. static readonly ALWAYS: number;
  62435. /** Passed to stencilOperation to specify that stencil value must be kept */
  62436. static readonly KEEP: number;
  62437. /** Passed to stencilOperation to specify that stencil value must be replaced */
  62438. static readonly REPLACE: number;
  62439. private _isStencilTestDirty;
  62440. private _isStencilMaskDirty;
  62441. private _isStencilFuncDirty;
  62442. private _isStencilOpDirty;
  62443. private _stencilTest;
  62444. private _stencilMask;
  62445. private _stencilFunc;
  62446. private _stencilFuncRef;
  62447. private _stencilFuncMask;
  62448. private _stencilOpStencilFail;
  62449. private _stencilOpDepthFail;
  62450. private _stencilOpStencilDepthPass;
  62451. readonly isDirty: boolean;
  62452. stencilFunc: number;
  62453. stencilFuncRef: number;
  62454. stencilFuncMask: number;
  62455. stencilOpStencilFail: number;
  62456. stencilOpDepthFail: number;
  62457. stencilOpStencilDepthPass: number;
  62458. stencilMask: number;
  62459. stencilTest: boolean;
  62460. constructor();
  62461. reset(): void;
  62462. apply(gl: WebGLRenderingContext): void;
  62463. }
  62464. }
  62465. declare module BABYLON {
  62466. /**
  62467. * @hidden
  62468. **/
  62469. export class _TimeToken {
  62470. _startTimeQuery: Nullable<WebGLQuery>;
  62471. _endTimeQuery: Nullable<WebGLQuery>;
  62472. _timeElapsedQuery: Nullable<WebGLQuery>;
  62473. _timeElapsedQueryEnded: boolean;
  62474. }
  62475. }
  62476. declare module BABYLON {
  62477. /**
  62478. * Internal interface used to track InternalTexture already bound to the GL context
  62479. */
  62480. export interface IInternalTextureTracker {
  62481. /**
  62482. * Gets or set the previous tracker in the list
  62483. */
  62484. previous: Nullable<IInternalTextureTracker>;
  62485. /**
  62486. * Gets or set the next tracker in the list
  62487. */
  62488. next: Nullable<IInternalTextureTracker>;
  62489. }
  62490. /**
  62491. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  62492. */
  62493. export class DummyInternalTextureTracker {
  62494. /**
  62495. * Gets or set the previous tracker in the list
  62496. */
  62497. previous: Nullable<IInternalTextureTracker>;
  62498. /**
  62499. * Gets or set the next tracker in the list
  62500. */
  62501. next: Nullable<IInternalTextureTracker>;
  62502. }
  62503. }
  62504. declare module BABYLON {
  62505. /**
  62506. * Class used to store data associated with WebGL texture data for the engine
  62507. * This class should not be used directly
  62508. */
  62509. export class InternalTexture implements IInternalTextureTracker {
  62510. /** hidden */
  62511. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  62512. /**
  62513. * The source of the texture data is unknown
  62514. */
  62515. static DATASOURCE_UNKNOWN: number;
  62516. /**
  62517. * Texture data comes from an URL
  62518. */
  62519. static DATASOURCE_URL: number;
  62520. /**
  62521. * Texture data is only used for temporary storage
  62522. */
  62523. static DATASOURCE_TEMP: number;
  62524. /**
  62525. * Texture data comes from raw data (ArrayBuffer)
  62526. */
  62527. static DATASOURCE_RAW: number;
  62528. /**
  62529. * Texture content is dynamic (video or dynamic texture)
  62530. */
  62531. static DATASOURCE_DYNAMIC: number;
  62532. /**
  62533. * Texture content is generated by rendering to it
  62534. */
  62535. static DATASOURCE_RENDERTARGET: number;
  62536. /**
  62537. * Texture content is part of a multi render target process
  62538. */
  62539. static DATASOURCE_MULTIRENDERTARGET: number;
  62540. /**
  62541. * Texture data comes from a cube data file
  62542. */
  62543. static DATASOURCE_CUBE: number;
  62544. /**
  62545. * Texture data comes from a raw cube data
  62546. */
  62547. static DATASOURCE_CUBERAW: number;
  62548. /**
  62549. * Texture data come from a prefiltered cube data file
  62550. */
  62551. static DATASOURCE_CUBEPREFILTERED: number;
  62552. /**
  62553. * Texture content is raw 3D data
  62554. */
  62555. static DATASOURCE_RAW3D: number;
  62556. /**
  62557. * Texture content is a depth texture
  62558. */
  62559. static DATASOURCE_DEPTHTEXTURE: number;
  62560. /**
  62561. * Texture data comes from a raw cube data encoded with RGBD
  62562. */
  62563. static DATASOURCE_CUBERAW_RGBD: number;
  62564. /**
  62565. * Defines if the texture is ready
  62566. */
  62567. isReady: boolean;
  62568. /**
  62569. * Defines if the texture is a cube texture
  62570. */
  62571. isCube: boolean;
  62572. /**
  62573. * Defines if the texture contains 3D data
  62574. */
  62575. is3D: boolean;
  62576. /**
  62577. * Gets the URL used to load this texture
  62578. */
  62579. url: string;
  62580. /**
  62581. * Gets the sampling mode of the texture
  62582. */
  62583. samplingMode: number;
  62584. /**
  62585. * Gets a boolean indicating if the texture needs mipmaps generation
  62586. */
  62587. generateMipMaps: boolean;
  62588. /**
  62589. * Gets the number of samples used by the texture (WebGL2+ only)
  62590. */
  62591. samples: number;
  62592. /**
  62593. * Gets the type of the texture (int, float...)
  62594. */
  62595. type: number;
  62596. /**
  62597. * Gets the format of the texture (RGB, RGBA...)
  62598. */
  62599. format: number;
  62600. /**
  62601. * Observable called when the texture is loaded
  62602. */
  62603. onLoadedObservable: Observable<InternalTexture>;
  62604. /**
  62605. * Gets the width of the texture
  62606. */
  62607. width: number;
  62608. /**
  62609. * Gets the height of the texture
  62610. */
  62611. height: number;
  62612. /**
  62613. * Gets the depth of the texture
  62614. */
  62615. depth: number;
  62616. /**
  62617. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  62618. */
  62619. baseWidth: number;
  62620. /**
  62621. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  62622. */
  62623. baseHeight: number;
  62624. /**
  62625. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  62626. */
  62627. baseDepth: number;
  62628. /**
  62629. * Gets a boolean indicating if the texture is inverted on Y axis
  62630. */
  62631. invertY: boolean;
  62632. /**
  62633. * Gets or set the previous tracker in the list
  62634. */
  62635. previous: Nullable<IInternalTextureTracker>;
  62636. /**
  62637. * Gets or set the next tracker in the list
  62638. */
  62639. next: Nullable<IInternalTextureTracker>;
  62640. /** @hidden */
  62641. _invertVScale: boolean;
  62642. /** @hidden */
  62643. _initialSlot: number;
  62644. /** @hidden */
  62645. _designatedSlot: number;
  62646. /** @hidden */
  62647. _dataSource: number;
  62648. /** @hidden */
  62649. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  62650. /** @hidden */
  62651. _bufferView: Nullable<ArrayBufferView>;
  62652. /** @hidden */
  62653. _bufferViewArray: Nullable<ArrayBufferView[]>;
  62654. /** @hidden */
  62655. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  62656. /** @hidden */
  62657. _size: number;
  62658. /** @hidden */
  62659. _extension: string;
  62660. /** @hidden */
  62661. _files: Nullable<string[]>;
  62662. /** @hidden */
  62663. _workingCanvas: HTMLCanvasElement;
  62664. /** @hidden */
  62665. _workingContext: CanvasRenderingContext2D;
  62666. /** @hidden */
  62667. _framebuffer: Nullable<WebGLFramebuffer>;
  62668. /** @hidden */
  62669. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  62670. /** @hidden */
  62671. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  62672. /** @hidden */
  62673. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  62674. /** @hidden */
  62675. _attachments: Nullable<number[]>;
  62676. /** @hidden */
  62677. _cachedCoordinatesMode: Nullable<number>;
  62678. /** @hidden */
  62679. _cachedWrapU: Nullable<number>;
  62680. /** @hidden */
  62681. _cachedWrapV: Nullable<number>;
  62682. /** @hidden */
  62683. _cachedWrapR: Nullable<number>;
  62684. /** @hidden */
  62685. _cachedAnisotropicFilteringLevel: Nullable<number>;
  62686. /** @hidden */
  62687. _isDisabled: boolean;
  62688. /** @hidden */
  62689. _compression: Nullable<string>;
  62690. /** @hidden */
  62691. _generateStencilBuffer: boolean;
  62692. /** @hidden */
  62693. _generateDepthBuffer: boolean;
  62694. /** @hidden */
  62695. _comparisonFunction: number;
  62696. /** @hidden */
  62697. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  62698. /** @hidden */
  62699. _lodGenerationScale: number;
  62700. /** @hidden */
  62701. _lodGenerationOffset: number;
  62702. /** @hidden */
  62703. _lodTextureHigh: BaseTexture;
  62704. /** @hidden */
  62705. _lodTextureMid: BaseTexture;
  62706. /** @hidden */
  62707. _lodTextureLow: BaseTexture;
  62708. /** @hidden */
  62709. _isRGBD: boolean;
  62710. /** @hidden */
  62711. _webGLTexture: Nullable<WebGLTexture>;
  62712. /** @hidden */
  62713. _references: number;
  62714. private _engine;
  62715. /**
  62716. * Gets the Engine the texture belongs to.
  62717. * @returns The babylon engine
  62718. */
  62719. getEngine(): Engine;
  62720. /**
  62721. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  62722. */
  62723. readonly dataSource: number;
  62724. /**
  62725. * Creates a new InternalTexture
  62726. * @param engine defines the engine to use
  62727. * @param dataSource defines the type of data that will be used
  62728. * @param delayAllocation if the texture allocation should be delayed (default: false)
  62729. */
  62730. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  62731. /**
  62732. * Increments the number of references (ie. the number of Texture that point to it)
  62733. */
  62734. incrementReferences(): void;
  62735. /**
  62736. * Change the size of the texture (not the size of the content)
  62737. * @param width defines the new width
  62738. * @param height defines the new height
  62739. * @param depth defines the new depth (1 by default)
  62740. */
  62741. updateSize(width: int, height: int, depth?: int): void;
  62742. /** @hidden */
  62743. _rebuild(): void;
  62744. /** @hidden */
  62745. _swapAndDie(target: InternalTexture): void;
  62746. /**
  62747. * Dispose the current allocated resources
  62748. */
  62749. dispose(): void;
  62750. }
  62751. }
  62752. declare module BABYLON {
  62753. /**
  62754. * This represents the main contract an easing function should follow.
  62755. * Easing functions are used throughout the animation system.
  62756. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62757. */
  62758. export interface IEasingFunction {
  62759. /**
  62760. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62761. * of the easing function.
  62762. * The link below provides some of the most common examples of easing functions.
  62763. * @see https://easings.net/
  62764. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62765. * @returns the corresponding value on the curve defined by the easing function
  62766. */
  62767. ease(gradient: number): number;
  62768. }
  62769. /**
  62770. * Base class used for every default easing function.
  62771. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62772. */
  62773. export class EasingFunction implements IEasingFunction {
  62774. /**
  62775. * Interpolation follows the mathematical formula associated with the easing function.
  62776. */
  62777. static readonly EASINGMODE_EASEIN: number;
  62778. /**
  62779. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  62780. */
  62781. static readonly EASINGMODE_EASEOUT: number;
  62782. /**
  62783. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  62784. */
  62785. static readonly EASINGMODE_EASEINOUT: number;
  62786. private _easingMode;
  62787. /**
  62788. * Sets the easing mode of the current function.
  62789. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  62790. */
  62791. setEasingMode(easingMode: number): void;
  62792. /**
  62793. * Gets the current easing mode.
  62794. * @returns the easing mode
  62795. */
  62796. getEasingMode(): number;
  62797. /**
  62798. * @hidden
  62799. */
  62800. easeInCore(gradient: number): number;
  62801. /**
  62802. * Given an input gradient between 0 and 1, this returns the corrseponding value
  62803. * of the easing function.
  62804. * @param gradient Defines the value between 0 and 1 we want the easing value for
  62805. * @returns the corresponding value on the curve defined by the easing function
  62806. */
  62807. ease(gradient: number): number;
  62808. }
  62809. /**
  62810. * Easing function with a circle shape (see link below).
  62811. * @see https://easings.net/#easeInCirc
  62812. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62813. */
  62814. export class CircleEase extends EasingFunction implements IEasingFunction {
  62815. /** @hidden */
  62816. easeInCore(gradient: number): number;
  62817. }
  62818. /**
  62819. * Easing function with a ease back shape (see link below).
  62820. * @see https://easings.net/#easeInBack
  62821. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62822. */
  62823. export class BackEase extends EasingFunction implements IEasingFunction {
  62824. /** Defines the amplitude of the function */
  62825. amplitude: number;
  62826. /**
  62827. * Instantiates a back ease easing
  62828. * @see https://easings.net/#easeInBack
  62829. * @param amplitude Defines the amplitude of the function
  62830. */
  62831. constructor(
  62832. /** Defines the amplitude of the function */
  62833. amplitude?: number);
  62834. /** @hidden */
  62835. easeInCore(gradient: number): number;
  62836. }
  62837. /**
  62838. * Easing function with a bouncing shape (see link below).
  62839. * @see https://easings.net/#easeInBounce
  62840. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62841. */
  62842. export class BounceEase extends EasingFunction implements IEasingFunction {
  62843. /** Defines the number of bounces */
  62844. bounces: number;
  62845. /** Defines the amplitude of the bounce */
  62846. bounciness: number;
  62847. /**
  62848. * Instantiates a bounce easing
  62849. * @see https://easings.net/#easeInBounce
  62850. * @param bounces Defines the number of bounces
  62851. * @param bounciness Defines the amplitude of the bounce
  62852. */
  62853. constructor(
  62854. /** Defines the number of bounces */
  62855. bounces?: number,
  62856. /** Defines the amplitude of the bounce */
  62857. bounciness?: number);
  62858. /** @hidden */
  62859. easeInCore(gradient: number): number;
  62860. }
  62861. /**
  62862. * Easing function with a power of 3 shape (see link below).
  62863. * @see https://easings.net/#easeInCubic
  62864. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62865. */
  62866. export class CubicEase extends EasingFunction implements IEasingFunction {
  62867. /** @hidden */
  62868. easeInCore(gradient: number): number;
  62869. }
  62870. /**
  62871. * Easing function with an elastic shape (see link below).
  62872. * @see https://easings.net/#easeInElastic
  62873. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62874. */
  62875. export class ElasticEase extends EasingFunction implements IEasingFunction {
  62876. /** Defines the number of oscillations*/
  62877. oscillations: number;
  62878. /** Defines the amplitude of the oscillations*/
  62879. springiness: number;
  62880. /**
  62881. * Instantiates an elastic easing function
  62882. * @see https://easings.net/#easeInElastic
  62883. * @param oscillations Defines the number of oscillations
  62884. * @param springiness Defines the amplitude of the oscillations
  62885. */
  62886. constructor(
  62887. /** Defines the number of oscillations*/
  62888. oscillations?: number,
  62889. /** Defines the amplitude of the oscillations*/
  62890. springiness?: number);
  62891. /** @hidden */
  62892. easeInCore(gradient: number): number;
  62893. }
  62894. /**
  62895. * Easing function with an exponential shape (see link below).
  62896. * @see https://easings.net/#easeInExpo
  62897. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62898. */
  62899. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  62900. /** Defines the exponent of the function */
  62901. exponent: number;
  62902. /**
  62903. * Instantiates an exponential easing function
  62904. * @see https://easings.net/#easeInExpo
  62905. * @param exponent Defines the exponent of the function
  62906. */
  62907. constructor(
  62908. /** Defines the exponent of the function */
  62909. exponent?: number);
  62910. /** @hidden */
  62911. easeInCore(gradient: number): number;
  62912. }
  62913. /**
  62914. * Easing function with a power shape (see link below).
  62915. * @see https://easings.net/#easeInQuad
  62916. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62917. */
  62918. export class PowerEase extends EasingFunction implements IEasingFunction {
  62919. /** Defines the power of the function */
  62920. power: number;
  62921. /**
  62922. * Instantiates an power base easing function
  62923. * @see https://easings.net/#easeInQuad
  62924. * @param power Defines the power of the function
  62925. */
  62926. constructor(
  62927. /** Defines the power of the function */
  62928. power?: number);
  62929. /** @hidden */
  62930. easeInCore(gradient: number): number;
  62931. }
  62932. /**
  62933. * Easing function with a power of 2 shape (see link below).
  62934. * @see https://easings.net/#easeInQuad
  62935. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62936. */
  62937. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  62938. /** @hidden */
  62939. easeInCore(gradient: number): number;
  62940. }
  62941. /**
  62942. * Easing function with a power of 4 shape (see link below).
  62943. * @see https://easings.net/#easeInQuart
  62944. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62945. */
  62946. export class QuarticEase extends EasingFunction implements IEasingFunction {
  62947. /** @hidden */
  62948. easeInCore(gradient: number): number;
  62949. }
  62950. /**
  62951. * Easing function with a power of 5 shape (see link below).
  62952. * @see https://easings.net/#easeInQuint
  62953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62954. */
  62955. export class QuinticEase extends EasingFunction implements IEasingFunction {
  62956. /** @hidden */
  62957. easeInCore(gradient: number): number;
  62958. }
  62959. /**
  62960. * Easing function with a sin shape (see link below).
  62961. * @see https://easings.net/#easeInSine
  62962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62963. */
  62964. export class SineEase extends EasingFunction implements IEasingFunction {
  62965. /** @hidden */
  62966. easeInCore(gradient: number): number;
  62967. }
  62968. /**
  62969. * Easing function with a bezier shape (see link below).
  62970. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  62971. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  62972. */
  62973. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  62974. /** Defines the x component of the start tangent in the bezier curve */
  62975. x1: number;
  62976. /** Defines the y component of the start tangent in the bezier curve */
  62977. y1: number;
  62978. /** Defines the x component of the end tangent in the bezier curve */
  62979. x2: number;
  62980. /** Defines the y component of the end tangent in the bezier curve */
  62981. y2: number;
  62982. /**
  62983. * Instantiates a bezier function
  62984. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  62985. * @param x1 Defines the x component of the start tangent in the bezier curve
  62986. * @param y1 Defines the y component of the start tangent in the bezier curve
  62987. * @param x2 Defines the x component of the end tangent in the bezier curve
  62988. * @param y2 Defines the y component of the end tangent in the bezier curve
  62989. */
  62990. constructor(
  62991. /** Defines the x component of the start tangent in the bezier curve */
  62992. x1?: number,
  62993. /** Defines the y component of the start tangent in the bezier curve */
  62994. y1?: number,
  62995. /** Defines the x component of the end tangent in the bezier curve */
  62996. x2?: number,
  62997. /** Defines the y component of the end tangent in the bezier curve */
  62998. y2?: number);
  62999. /** @hidden */
  63000. easeInCore(gradient: number): number;
  63001. }
  63002. }
  63003. declare module BABYLON {
  63004. /**
  63005. * Defines an interface which represents an animation key frame
  63006. */
  63007. export interface IAnimationKey {
  63008. /**
  63009. * Frame of the key frame
  63010. */
  63011. frame: number;
  63012. /**
  63013. * Value at the specifies key frame
  63014. */
  63015. value: any;
  63016. /**
  63017. * The input tangent for the cubic hermite spline
  63018. */
  63019. inTangent?: any;
  63020. /**
  63021. * The output tangent for the cubic hermite spline
  63022. */
  63023. outTangent?: any;
  63024. /**
  63025. * The animation interpolation type
  63026. */
  63027. interpolation?: AnimationKeyInterpolation;
  63028. }
  63029. /**
  63030. * Enum for the animation key frame interpolation type
  63031. */
  63032. export enum AnimationKeyInterpolation {
  63033. /**
  63034. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  63035. */
  63036. STEP = 1
  63037. }
  63038. }
  63039. declare module BABYLON {
  63040. /**
  63041. * Represents the range of an animation
  63042. */
  63043. export class AnimationRange {
  63044. /**The name of the animation range**/
  63045. name: string;
  63046. /**The starting frame of the animation */
  63047. from: number;
  63048. /**The ending frame of the animation*/
  63049. to: number;
  63050. /**
  63051. * Initializes the range of an animation
  63052. * @param name The name of the animation range
  63053. * @param from The starting frame of the animation
  63054. * @param to The ending frame of the animation
  63055. */
  63056. constructor(
  63057. /**The name of the animation range**/
  63058. name: string,
  63059. /**The starting frame of the animation */
  63060. from: number,
  63061. /**The ending frame of the animation*/
  63062. to: number);
  63063. /**
  63064. * Makes a copy of the animation range
  63065. * @returns A copy of the animation range
  63066. */
  63067. clone(): AnimationRange;
  63068. }
  63069. }
  63070. declare module BABYLON {
  63071. /**
  63072. * Composed of a frame, and an action function
  63073. */
  63074. export class AnimationEvent {
  63075. /** The frame for which the event is triggered **/
  63076. frame: number;
  63077. /** The event to perform when triggered **/
  63078. action: (currentFrame: number) => void;
  63079. /** Specifies if the event should be triggered only once**/
  63080. onlyOnce?: boolean | undefined;
  63081. /**
  63082. * Specifies if the animation event is done
  63083. */
  63084. isDone: boolean;
  63085. /**
  63086. * Initializes the animation event
  63087. * @param frame The frame for which the event is triggered
  63088. * @param action The event to perform when triggered
  63089. * @param onlyOnce Specifies if the event should be triggered only once
  63090. */
  63091. constructor(
  63092. /** The frame for which the event is triggered **/
  63093. frame: number,
  63094. /** The event to perform when triggered **/
  63095. action: (currentFrame: number) => void,
  63096. /** Specifies if the event should be triggered only once**/
  63097. onlyOnce?: boolean | undefined);
  63098. /** @hidden */
  63099. _clone(): AnimationEvent;
  63100. }
  63101. }
  63102. declare module BABYLON {
  63103. /**
  63104. * Interface used to define a behavior
  63105. */
  63106. export interface Behavior<T> {
  63107. /** gets or sets behavior's name */
  63108. name: string;
  63109. /**
  63110. * Function called when the behavior needs to be initialized (after attaching it to a target)
  63111. */
  63112. init(): void;
  63113. /**
  63114. * Called when the behavior is attached to a target
  63115. * @param target defines the target where the behavior is attached to
  63116. */
  63117. attach(target: T): void;
  63118. /**
  63119. * Called when the behavior is detached from its target
  63120. */
  63121. detach(): void;
  63122. }
  63123. /**
  63124. * Interface implemented by classes supporting behaviors
  63125. */
  63126. export interface IBehaviorAware<T> {
  63127. /**
  63128. * Attach a behavior
  63129. * @param behavior defines the behavior to attach
  63130. * @returns the current host
  63131. */
  63132. addBehavior(behavior: Behavior<T>): T;
  63133. /**
  63134. * Remove a behavior from the current object
  63135. * @param behavior defines the behavior to detach
  63136. * @returns the current host
  63137. */
  63138. removeBehavior(behavior: Behavior<T>): T;
  63139. /**
  63140. * Gets a behavior using its name to search
  63141. * @param name defines the name to search
  63142. * @returns the behavior or null if not found
  63143. */
  63144. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  63145. }
  63146. }
  63147. declare module BABYLON {
  63148. /**
  63149. * Defines a runtime animation
  63150. */
  63151. export class RuntimeAnimation {
  63152. private _events;
  63153. /**
  63154. * The current frame of the runtime animation
  63155. */
  63156. private _currentFrame;
  63157. /**
  63158. * The animation used by the runtime animation
  63159. */
  63160. private _animation;
  63161. /**
  63162. * The target of the runtime animation
  63163. */
  63164. private _target;
  63165. /**
  63166. * The initiating animatable
  63167. */
  63168. private _host;
  63169. /**
  63170. * The original value of the runtime animation
  63171. */
  63172. private _originalValue;
  63173. /**
  63174. * The original blend value of the runtime animation
  63175. */
  63176. private _originalBlendValue;
  63177. /**
  63178. * The offsets cache of the runtime animation
  63179. */
  63180. private _offsetsCache;
  63181. /**
  63182. * The high limits cache of the runtime animation
  63183. */
  63184. private _highLimitsCache;
  63185. /**
  63186. * Specifies if the runtime animation has been stopped
  63187. */
  63188. private _stopped;
  63189. /**
  63190. * The blending factor of the runtime animation
  63191. */
  63192. private _blendingFactor;
  63193. /**
  63194. * The BabylonJS scene
  63195. */
  63196. private _scene;
  63197. /**
  63198. * The current value of the runtime animation
  63199. */
  63200. private _currentValue;
  63201. /** @hidden */
  63202. _workValue: any;
  63203. /**
  63204. * The active target of the runtime animation
  63205. */
  63206. private _activeTarget;
  63207. /**
  63208. * The target path of the runtime animation
  63209. */
  63210. private _targetPath;
  63211. /**
  63212. * The weight of the runtime animation
  63213. */
  63214. private _weight;
  63215. /**
  63216. * The ratio offset of the runtime animation
  63217. */
  63218. private _ratioOffset;
  63219. /**
  63220. * The previous delay of the runtime animation
  63221. */
  63222. private _previousDelay;
  63223. /**
  63224. * The previous ratio of the runtime animation
  63225. */
  63226. private _previousRatio;
  63227. /**
  63228. * Gets the current frame of the runtime animation
  63229. */
  63230. readonly currentFrame: number;
  63231. /**
  63232. * Gets the weight of the runtime animation
  63233. */
  63234. readonly weight: number;
  63235. /**
  63236. * Gets the current value of the runtime animation
  63237. */
  63238. readonly currentValue: any;
  63239. /**
  63240. * Gets the target path of the runtime animation
  63241. */
  63242. readonly targetPath: string;
  63243. /**
  63244. * Gets the actual target of the runtime animation
  63245. */
  63246. readonly target: any;
  63247. /**
  63248. * Create a new RuntimeAnimation object
  63249. * @param target defines the target of the animation
  63250. * @param animation defines the source animation object
  63251. * @param scene defines the hosting scene
  63252. * @param host defines the initiating Animatable
  63253. */
  63254. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  63255. /**
  63256. * Gets the animation from the runtime animation
  63257. */
  63258. readonly animation: Animation;
  63259. /**
  63260. * Resets the runtime animation to the beginning
  63261. * @param restoreOriginal defines whether to restore the target property to the original value
  63262. */
  63263. reset(restoreOriginal?: boolean): void;
  63264. /**
  63265. * Specifies if the runtime animation is stopped
  63266. * @returns Boolean specifying if the runtime animation is stopped
  63267. */
  63268. isStopped(): boolean;
  63269. /**
  63270. * Disposes of the runtime animation
  63271. */
  63272. dispose(): void;
  63273. /**
  63274. * Interpolates the animation from the current frame
  63275. * @param currentFrame The frame to interpolate the animation to
  63276. * @param repeatCount The number of times that the animation should loop
  63277. * @param loopMode The type of looping mode to use
  63278. * @param offsetValue Animation offset value
  63279. * @param highLimitValue The high limit value
  63280. * @returns The interpolated value
  63281. */
  63282. private _interpolate;
  63283. /**
  63284. * Apply the interpolated value to the target
  63285. * @param currentValue defines the value computed by the animation
  63286. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  63287. */
  63288. setValue(currentValue: any, weight?: number): void;
  63289. private _setValue;
  63290. /**
  63291. * Gets the loop pmode of the runtime animation
  63292. * @returns Loop Mode
  63293. */
  63294. private _getCorrectLoopMode;
  63295. /**
  63296. * Move the current animation to a given frame
  63297. * @param frame defines the frame to move to
  63298. */
  63299. goToFrame(frame: number): void;
  63300. /**
  63301. * @hidden Internal use only
  63302. */
  63303. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  63304. /**
  63305. * Execute the current animation
  63306. * @param delay defines the delay to add to the current frame
  63307. * @param from defines the lower bound of the animation range
  63308. * @param to defines the upper bound of the animation range
  63309. * @param loop defines if the current animation must loop
  63310. * @param speedRatio defines the current speed ratio
  63311. * @param weight defines the weight of the animation (default is -1 so no weight)
  63312. * @param onLoop optional callback called when animation loops
  63313. * @returns a boolean indicating if the animation is running
  63314. */
  63315. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  63316. }
  63317. }
  63318. declare module BABYLON {
  63319. /**
  63320. * @hidden
  63321. */
  63322. export class IntersectionInfo {
  63323. bu: Nullable<number>;
  63324. bv: Nullable<number>;
  63325. distance: number;
  63326. faceId: number;
  63327. subMeshId: number;
  63328. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  63329. }
  63330. }
  63331. declare module BABYLON {
  63332. /**
  63333. * Interface used to define ActionEvent
  63334. */
  63335. export interface IActionEvent {
  63336. /** The mesh or sprite that triggered the action */
  63337. source: any;
  63338. /** The X mouse cursor position at the time of the event */
  63339. pointerX: number;
  63340. /** The Y mouse cursor position at the time of the event */
  63341. pointerY: number;
  63342. /** The mesh that is currently pointed at (can be null) */
  63343. meshUnderPointer: Nullable<AbstractMesh>;
  63344. /** the original (browser) event that triggered the ActionEvent */
  63345. sourceEvent?: any;
  63346. /** additional data for the event */
  63347. additionalData?: any;
  63348. }
  63349. /**
  63350. * ActionEvent is the event being sent when an action is triggered.
  63351. */
  63352. export class ActionEvent implements IActionEvent {
  63353. /** The mesh or sprite that triggered the action */
  63354. source: any;
  63355. /** The X mouse cursor position at the time of the event */
  63356. pointerX: number;
  63357. /** The Y mouse cursor position at the time of the event */
  63358. pointerY: number;
  63359. /** The mesh that is currently pointed at (can be null) */
  63360. meshUnderPointer: Nullable<AbstractMesh>;
  63361. /** the original (browser) event that triggered the ActionEvent */
  63362. sourceEvent?: any;
  63363. /** additional data for the event */
  63364. additionalData?: any;
  63365. /**
  63366. * Creates a new ActionEvent
  63367. * @param source The mesh or sprite that triggered the action
  63368. * @param pointerX The X mouse cursor position at the time of the event
  63369. * @param pointerY The Y mouse cursor position at the time of the event
  63370. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  63371. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  63372. * @param additionalData additional data for the event
  63373. */
  63374. constructor(
  63375. /** The mesh or sprite that triggered the action */
  63376. source: any,
  63377. /** The X mouse cursor position at the time of the event */
  63378. pointerX: number,
  63379. /** The Y mouse cursor position at the time of the event */
  63380. pointerY: number,
  63381. /** The mesh that is currently pointed at (can be null) */
  63382. meshUnderPointer: Nullable<AbstractMesh>,
  63383. /** the original (browser) event that triggered the ActionEvent */
  63384. sourceEvent?: any,
  63385. /** additional data for the event */
  63386. additionalData?: any);
  63387. /**
  63388. * Helper function to auto-create an ActionEvent from a source mesh.
  63389. * @param source The source mesh that triggered the event
  63390. * @param evt The original (browser) event
  63391. * @param additionalData additional data for the event
  63392. * @returns the new ActionEvent
  63393. */
  63394. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  63395. /**
  63396. * Helper function to auto-create an ActionEvent from a source sprite
  63397. * @param source The source sprite that triggered the event
  63398. * @param scene Scene associated with the sprite
  63399. * @param evt The original (browser) event
  63400. * @param additionalData additional data for the event
  63401. * @returns the new ActionEvent
  63402. */
  63403. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  63404. /**
  63405. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  63406. * @param scene the scene where the event occurred
  63407. * @param evt The original (browser) event
  63408. * @returns the new ActionEvent
  63409. */
  63410. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  63411. /**
  63412. * Helper function to auto-create an ActionEvent from a primitive
  63413. * @param prim defines the target primitive
  63414. * @param pointerPos defines the pointer position
  63415. * @param evt The original (browser) event
  63416. * @param additionalData additional data for the event
  63417. * @returns the new ActionEvent
  63418. */
  63419. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  63420. }
  63421. }
  63422. declare module BABYLON {
  63423. /**
  63424. * Class used to store bounding sphere information
  63425. */
  63426. export class BoundingSphere {
  63427. /**
  63428. * Gets the center of the bounding sphere in local space
  63429. */
  63430. readonly center: Vector3;
  63431. /**
  63432. * Radius of the bounding sphere in local space
  63433. */
  63434. radius: number;
  63435. /**
  63436. * Gets the center of the bounding sphere in world space
  63437. */
  63438. readonly centerWorld: Vector3;
  63439. /**
  63440. * Radius of the bounding sphere in world space
  63441. */
  63442. radiusWorld: number;
  63443. /**
  63444. * Gets the minimum vector in local space
  63445. */
  63446. readonly minimum: Vector3;
  63447. /**
  63448. * Gets the maximum vector in local space
  63449. */
  63450. readonly maximum: Vector3;
  63451. private _worldMatrix;
  63452. private static readonly TmpVector3;
  63453. /**
  63454. * Creates a new bounding sphere
  63455. * @param min defines the minimum vector (in local space)
  63456. * @param max defines the maximum vector (in local space)
  63457. * @param worldMatrix defines the new world matrix
  63458. */
  63459. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63460. /**
  63461. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  63462. * @param min defines the new minimum vector (in local space)
  63463. * @param max defines the new maximum vector (in local space)
  63464. * @param worldMatrix defines the new world matrix
  63465. */
  63466. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63467. /**
  63468. * Scale the current bounding sphere by applying a scale factor
  63469. * @param factor defines the scale factor to apply
  63470. * @returns the current bounding box
  63471. */
  63472. scale(factor: number): BoundingSphere;
  63473. /**
  63474. * Gets the world matrix of the bounding box
  63475. * @returns a matrix
  63476. */
  63477. getWorldMatrix(): DeepImmutable<Matrix>;
  63478. /** @hidden */
  63479. _update(worldMatrix: DeepImmutable<Matrix>): void;
  63480. /**
  63481. * Tests if the bounding sphere is intersecting the frustum planes
  63482. * @param frustumPlanes defines the frustum planes to test
  63483. * @returns true if there is an intersection
  63484. */
  63485. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63486. /**
  63487. * Tests if the bounding sphere center is in between the frustum planes.
  63488. * Used for optimistic fast inclusion.
  63489. * @param frustumPlanes defines the frustum planes to test
  63490. * @returns true if the sphere center is in between the frustum planes
  63491. */
  63492. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63493. /**
  63494. * Tests if a point is inside the bounding sphere
  63495. * @param point defines the point to test
  63496. * @returns true if the point is inside the bounding sphere
  63497. */
  63498. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63499. /**
  63500. * Checks if two sphere intersct
  63501. * @param sphere0 sphere 0
  63502. * @param sphere1 sphere 1
  63503. * @returns true if the speres intersect
  63504. */
  63505. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  63506. }
  63507. }
  63508. declare module BABYLON {
  63509. /**
  63510. * Class used to store bounding box information
  63511. */
  63512. export class BoundingBox implements ICullable {
  63513. /**
  63514. * Gets the 8 vectors representing the bounding box in local space
  63515. */
  63516. readonly vectors: Vector3[];
  63517. /**
  63518. * Gets the center of the bounding box in local space
  63519. */
  63520. readonly center: Vector3;
  63521. /**
  63522. * Gets the center of the bounding box in world space
  63523. */
  63524. readonly centerWorld: Vector3;
  63525. /**
  63526. * Gets the extend size in local space
  63527. */
  63528. readonly extendSize: Vector3;
  63529. /**
  63530. * Gets the extend size in world space
  63531. */
  63532. readonly extendSizeWorld: Vector3;
  63533. /**
  63534. * Gets the OBB (object bounding box) directions
  63535. */
  63536. readonly directions: Vector3[];
  63537. /**
  63538. * Gets the 8 vectors representing the bounding box in world space
  63539. */
  63540. readonly vectorsWorld: Vector3[];
  63541. /**
  63542. * Gets the minimum vector in world space
  63543. */
  63544. readonly minimumWorld: Vector3;
  63545. /**
  63546. * Gets the maximum vector in world space
  63547. */
  63548. readonly maximumWorld: Vector3;
  63549. /**
  63550. * Gets the minimum vector in local space
  63551. */
  63552. readonly minimum: Vector3;
  63553. /**
  63554. * Gets the maximum vector in local space
  63555. */
  63556. readonly maximum: Vector3;
  63557. private _worldMatrix;
  63558. private static readonly TmpVector3;
  63559. /**
  63560. * @hidden
  63561. */
  63562. _tag: number;
  63563. /**
  63564. * Creates a new bounding box
  63565. * @param min defines the minimum vector (in local space)
  63566. * @param max defines the maximum vector (in local space)
  63567. * @param worldMatrix defines the new world matrix
  63568. */
  63569. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63570. /**
  63571. * Recreates the entire bounding box from scratch as if we call the constructor in place
  63572. * @param min defines the new minimum vector (in local space)
  63573. * @param max defines the new maximum vector (in local space)
  63574. * @param worldMatrix defines the new world matrix
  63575. */
  63576. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63577. /**
  63578. * Scale the current bounding box by applying a scale factor
  63579. * @param factor defines the scale factor to apply
  63580. * @returns the current bounding box
  63581. */
  63582. scale(factor: number): BoundingBox;
  63583. /**
  63584. * Gets the world matrix of the bounding box
  63585. * @returns a matrix
  63586. */
  63587. getWorldMatrix(): DeepImmutable<Matrix>;
  63588. /** @hidden */
  63589. _update(world: DeepImmutable<Matrix>): void;
  63590. /**
  63591. * Tests if the bounding box is intersecting the frustum planes
  63592. * @param frustumPlanes defines the frustum planes to test
  63593. * @returns true if there is an intersection
  63594. */
  63595. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63596. /**
  63597. * Tests if the bounding box is entirely inside the frustum planes
  63598. * @param frustumPlanes defines the frustum planes to test
  63599. * @returns true if there is an inclusion
  63600. */
  63601. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63602. /**
  63603. * Tests if a point is inside the bounding box
  63604. * @param point defines the point to test
  63605. * @returns true if the point is inside the bounding box
  63606. */
  63607. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63608. /**
  63609. * Tests if the bounding box intersects with a bounding sphere
  63610. * @param sphere defines the sphere to test
  63611. * @returns true if there is an intersection
  63612. */
  63613. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  63614. /**
  63615. * Tests if the bounding box intersects with a box defined by a min and max vectors
  63616. * @param min defines the min vector to use
  63617. * @param max defines the max vector to use
  63618. * @returns true if there is an intersection
  63619. */
  63620. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  63621. /**
  63622. * Tests if two bounding boxes are intersections
  63623. * @param box0 defines the first box to test
  63624. * @param box1 defines the second box to test
  63625. * @returns true if there is an intersection
  63626. */
  63627. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  63628. /**
  63629. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  63630. * @param minPoint defines the minimum vector of the bounding box
  63631. * @param maxPoint defines the maximum vector of the bounding box
  63632. * @param sphereCenter defines the sphere center
  63633. * @param sphereRadius defines the sphere radius
  63634. * @returns true if there is an intersection
  63635. */
  63636. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  63637. /**
  63638. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  63639. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63640. * @param frustumPlanes defines the frustum planes to test
  63641. * @return true if there is an inclusion
  63642. */
  63643. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63644. /**
  63645. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  63646. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  63647. * @param frustumPlanes defines the frustum planes to test
  63648. * @return true if there is an intersection
  63649. */
  63650. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63651. }
  63652. }
  63653. declare module BABYLON {
  63654. /** @hidden */
  63655. export class Collider {
  63656. /** Define if a collision was found */
  63657. collisionFound: boolean;
  63658. /**
  63659. * Define last intersection point in local space
  63660. */
  63661. intersectionPoint: Vector3;
  63662. /**
  63663. * Define last collided mesh
  63664. */
  63665. collidedMesh: Nullable<AbstractMesh>;
  63666. private _collisionPoint;
  63667. private _planeIntersectionPoint;
  63668. private _tempVector;
  63669. private _tempVector2;
  63670. private _tempVector3;
  63671. private _tempVector4;
  63672. private _edge;
  63673. private _baseToVertex;
  63674. private _destinationPoint;
  63675. private _slidePlaneNormal;
  63676. private _displacementVector;
  63677. /** @hidden */
  63678. _radius: Vector3;
  63679. /** @hidden */
  63680. _retry: number;
  63681. private _velocity;
  63682. private _basePoint;
  63683. private _epsilon;
  63684. /** @hidden */
  63685. _velocityWorldLength: number;
  63686. /** @hidden */
  63687. _basePointWorld: Vector3;
  63688. private _velocityWorld;
  63689. private _normalizedVelocity;
  63690. /** @hidden */
  63691. _initialVelocity: Vector3;
  63692. /** @hidden */
  63693. _initialPosition: Vector3;
  63694. private _nearestDistance;
  63695. private _collisionMask;
  63696. collisionMask: number;
  63697. /**
  63698. * Gets the plane normal used to compute the sliding response (in local space)
  63699. */
  63700. readonly slidePlaneNormal: Vector3;
  63701. /** @hidden */
  63702. _initialize(source: Vector3, dir: Vector3, e: number): void;
  63703. /** @hidden */
  63704. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  63705. /** @hidden */
  63706. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  63707. /** @hidden */
  63708. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  63709. /** @hidden */
  63710. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  63711. /** @hidden */
  63712. _getResponse(pos: Vector3, vel: Vector3): void;
  63713. }
  63714. }
  63715. declare module BABYLON {
  63716. /**
  63717. * Interface for cullable objects
  63718. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  63719. */
  63720. export interface ICullable {
  63721. /**
  63722. * Checks if the object or part of the object is in the frustum
  63723. * @param frustumPlanes Camera near/planes
  63724. * @returns true if the object is in frustum otherwise false
  63725. */
  63726. isInFrustum(frustumPlanes: Plane[]): boolean;
  63727. /**
  63728. * Checks if a cullable object (mesh...) is in the camera frustum
  63729. * Unlike isInFrustum this cheks the full bounding box
  63730. * @param frustumPlanes Camera near/planes
  63731. * @returns true if the object is in frustum otherwise false
  63732. */
  63733. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  63734. }
  63735. /**
  63736. * Info for a bounding data of a mesh
  63737. */
  63738. export class BoundingInfo implements ICullable {
  63739. /**
  63740. * Bounding box for the mesh
  63741. */
  63742. readonly boundingBox: BoundingBox;
  63743. /**
  63744. * Bounding sphere for the mesh
  63745. */
  63746. readonly boundingSphere: BoundingSphere;
  63747. private _isLocked;
  63748. private static readonly TmpVector3;
  63749. /**
  63750. * Constructs bounding info
  63751. * @param minimum min vector of the bounding box/sphere
  63752. * @param maximum max vector of the bounding box/sphere
  63753. * @param worldMatrix defines the new world matrix
  63754. */
  63755. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  63756. /**
  63757. * Recreates the entire bounding info from scratch as if we call the constructor in place
  63758. * @param min defines the new minimum vector (in local space)
  63759. * @param max defines the new maximum vector (in local space)
  63760. * @param worldMatrix defines the new world matrix
  63761. */
  63762. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  63763. /**
  63764. * min vector of the bounding box/sphere
  63765. */
  63766. readonly minimum: Vector3;
  63767. /**
  63768. * max vector of the bounding box/sphere
  63769. */
  63770. readonly maximum: Vector3;
  63771. /**
  63772. * If the info is locked and won't be updated to avoid perf overhead
  63773. */
  63774. isLocked: boolean;
  63775. /**
  63776. * Updates the bounding sphere and box
  63777. * @param world world matrix to be used to update
  63778. */
  63779. update(world: DeepImmutable<Matrix>): void;
  63780. /**
  63781. * Recreate the bounding info to be centered around a specific point given a specific extend.
  63782. * @param center New center of the bounding info
  63783. * @param extend New extend of the bounding info
  63784. * @returns the current bounding info
  63785. */
  63786. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  63787. /**
  63788. * Scale the current bounding info by applying a scale factor
  63789. * @param factor defines the scale factor to apply
  63790. * @returns the current bounding info
  63791. */
  63792. scale(factor: number): BoundingInfo;
  63793. /**
  63794. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  63795. * @param frustumPlanes defines the frustum to test
  63796. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  63797. * @returns true if the bounding info is in the frustum planes
  63798. */
  63799. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  63800. /**
  63801. * Gets the world distance between the min and max points of the bounding box
  63802. */
  63803. readonly diagonalLength: number;
  63804. /**
  63805. * Checks if a cullable object (mesh...) is in the camera frustum
  63806. * Unlike isInFrustum this cheks the full bounding box
  63807. * @param frustumPlanes Camera near/planes
  63808. * @returns true if the object is in frustum otherwise false
  63809. */
  63810. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  63811. /** @hidden */
  63812. _checkCollision(collider: Collider): boolean;
  63813. /**
  63814. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  63815. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63816. * @param point the point to check intersection with
  63817. * @returns if the point intersects
  63818. */
  63819. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  63820. /**
  63821. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  63822. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  63823. * @param boundingInfo the bounding info to check intersection with
  63824. * @param precise if the intersection should be done using OBB
  63825. * @returns if the bounding info intersects
  63826. */
  63827. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  63828. }
  63829. }
  63830. declare module BABYLON {
  63831. /**
  63832. * Defines an array and its length.
  63833. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  63834. */
  63835. export interface ISmartArrayLike<T> {
  63836. /**
  63837. * The data of the array.
  63838. */
  63839. data: Array<T>;
  63840. /**
  63841. * The active length of the array.
  63842. */
  63843. length: number;
  63844. }
  63845. /**
  63846. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63847. */
  63848. export class SmartArray<T> implements ISmartArrayLike<T> {
  63849. /**
  63850. * The full set of data from the array.
  63851. */
  63852. data: Array<T>;
  63853. /**
  63854. * The active length of the array.
  63855. */
  63856. length: number;
  63857. protected _id: number;
  63858. /**
  63859. * Instantiates a Smart Array.
  63860. * @param capacity defines the default capacity of the array.
  63861. */
  63862. constructor(capacity: number);
  63863. /**
  63864. * Pushes a value at the end of the active data.
  63865. * @param value defines the object to push in the array.
  63866. */
  63867. push(value: T): void;
  63868. /**
  63869. * Iterates over the active data and apply the lambda to them.
  63870. * @param func defines the action to apply on each value.
  63871. */
  63872. forEach(func: (content: T) => void): void;
  63873. /**
  63874. * Sorts the full sets of data.
  63875. * @param compareFn defines the comparison function to apply.
  63876. */
  63877. sort(compareFn: (a: T, b: T) => number): void;
  63878. /**
  63879. * Resets the active data to an empty array.
  63880. */
  63881. reset(): void;
  63882. /**
  63883. * Releases all the data from the array as well as the array.
  63884. */
  63885. dispose(): void;
  63886. /**
  63887. * Concats the active data with a given array.
  63888. * @param array defines the data to concatenate with.
  63889. */
  63890. concat(array: any): void;
  63891. /**
  63892. * Returns the position of a value in the active data.
  63893. * @param value defines the value to find the index for
  63894. * @returns the index if found in the active data otherwise -1
  63895. */
  63896. indexOf(value: T): number;
  63897. /**
  63898. * Returns whether an element is part of the active data.
  63899. * @param value defines the value to look for
  63900. * @returns true if found in the active data otherwise false
  63901. */
  63902. contains(value: T): boolean;
  63903. private static _GlobalId;
  63904. }
  63905. /**
  63906. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  63907. * The data in this array can only be present once
  63908. */
  63909. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  63910. private _duplicateId;
  63911. /**
  63912. * Pushes a value at the end of the active data.
  63913. * THIS DOES NOT PREVENT DUPPLICATE DATA
  63914. * @param value defines the object to push in the array.
  63915. */
  63916. push(value: T): void;
  63917. /**
  63918. * Pushes a value at the end of the active data.
  63919. * If the data is already present, it won t be added again
  63920. * @param value defines the object to push in the array.
  63921. * @returns true if added false if it was already present
  63922. */
  63923. pushNoDuplicate(value: T): boolean;
  63924. /**
  63925. * Resets the active data to an empty array.
  63926. */
  63927. reset(): void;
  63928. /**
  63929. * Concats the active data with a given array.
  63930. * This ensures no dupplicate will be present in the result.
  63931. * @param array defines the data to concatenate with.
  63932. */
  63933. concatWithNoDuplicate(array: any): void;
  63934. }
  63935. }
  63936. declare module BABYLON {
  63937. /**
  63938. * Class for creating a cube texture
  63939. */
  63940. export class CubeTexture extends BaseTexture {
  63941. private _delayedOnLoad;
  63942. /**
  63943. * The url of the texture
  63944. */
  63945. url: string;
  63946. /**
  63947. * Gets or sets the center of the bounding box associated with the cube texture.
  63948. * It must define where the camera used to render the texture was set
  63949. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  63950. */
  63951. boundingBoxPosition: Vector3;
  63952. private _boundingBoxSize;
  63953. /**
  63954. * Gets or sets the size of the bounding box associated with the cube texture
  63955. * When defined, the cubemap will switch to local mode
  63956. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63957. * @example https://www.babylonjs-playground.com/#RNASML
  63958. */
  63959. /**
  63960. * Returns the bounding box size
  63961. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  63962. */
  63963. boundingBoxSize: Vector3;
  63964. protected _rotationY: number;
  63965. /**
  63966. * Sets texture matrix rotation angle around Y axis in radians.
  63967. */
  63968. /**
  63969. * Gets texture matrix rotation angle around Y axis radians.
  63970. */
  63971. rotationY: number;
  63972. /**
  63973. * Are mip maps generated for this texture or not.
  63974. */
  63975. readonly noMipmap: boolean;
  63976. private _noMipmap;
  63977. private _files;
  63978. private _extensions;
  63979. private _textureMatrix;
  63980. private _format;
  63981. private _createPolynomials;
  63982. /** @hidden */
  63983. _prefiltered: boolean;
  63984. /**
  63985. * Creates a cube texture from an array of image urls
  63986. * @param files defines an array of image urls
  63987. * @param scene defines the hosting scene
  63988. * @param noMipmap specifies if mip maps are not used
  63989. * @returns a cube texture
  63990. */
  63991. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  63992. /**
  63993. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  63994. * @param url defines the url of the prefiltered texture
  63995. * @param scene defines the scene the texture is attached to
  63996. * @param forcedExtension defines the extension of the file if different from the url
  63997. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  63998. * @return the prefiltered texture
  63999. */
  64000. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  64001. /**
  64002. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  64003. * as prefiltered data.
  64004. * @param rootUrl defines the url of the texture or the root name of the six images
  64005. * @param scene defines the scene the texture is attached to
  64006. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  64007. * @param noMipmap defines if mipmaps should be created or not
  64008. * @param files defines the six files to load for the different faces
  64009. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  64010. * @param onError defines a callback triggered in case of error during load
  64011. * @param format defines the internal format to use for the texture once loaded
  64012. * @param prefiltered defines whether or not the texture is created from prefiltered data
  64013. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  64014. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  64015. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64016. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64017. * @return the cube texture
  64018. */
  64019. 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);
  64020. /**
  64021. * Get the current class name of the texture useful for serialization or dynamic coding.
  64022. * @returns "CubeTexture"
  64023. */
  64024. getClassName(): string;
  64025. /**
  64026. * Update the url (and optional buffer) of this texture if url was null during construction.
  64027. * @param url the url of the texture
  64028. * @param forcedExtension defines the extension to use
  64029. * @param onLoad callback called when the texture is loaded (defaults to null)
  64030. */
  64031. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  64032. /**
  64033. * Delays loading of the cube texture
  64034. * @param forcedExtension defines the extension to use
  64035. */
  64036. delayLoad(forcedExtension?: string): void;
  64037. /**
  64038. * Returns the reflection texture matrix
  64039. * @returns the reflection texture matrix
  64040. */
  64041. getReflectionTextureMatrix(): Matrix;
  64042. /**
  64043. * Sets the reflection texture matrix
  64044. * @param value Reflection texture matrix
  64045. */
  64046. setReflectionTextureMatrix(value: Matrix): void;
  64047. /**
  64048. * Parses text to create a cube texture
  64049. * @param parsedTexture define the serialized text to read from
  64050. * @param scene defines the hosting scene
  64051. * @param rootUrl defines the root url of the cube texture
  64052. * @returns a cube texture
  64053. */
  64054. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  64055. /**
  64056. * Makes a clone, or deep copy, of the cube texture
  64057. * @returns a new cube texture
  64058. */
  64059. clone(): CubeTexture;
  64060. }
  64061. }
  64062. declare module BABYLON {
  64063. /** @hidden */
  64064. export var postprocessVertexShader: {
  64065. name: string;
  64066. shader: string;
  64067. };
  64068. }
  64069. declare module BABYLON {
  64070. /**
  64071. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  64072. * This is the base of the follow, arc rotate cameras and Free camera
  64073. * @see http://doc.babylonjs.com/features/cameras
  64074. */
  64075. export class TargetCamera extends Camera {
  64076. private static _RigCamTransformMatrix;
  64077. private static _TargetTransformMatrix;
  64078. private static _TargetFocalPoint;
  64079. /**
  64080. * Define the current direction the camera is moving to
  64081. */
  64082. cameraDirection: Vector3;
  64083. /**
  64084. * Define the current rotation the camera is rotating to
  64085. */
  64086. cameraRotation: Vector2;
  64087. /**
  64088. * When set, the up vector of the camera will be updated by the rotation of the camera
  64089. */
  64090. updateUpVectorFromRotation: boolean;
  64091. private _tmpQuaternion;
  64092. /**
  64093. * Define the current rotation of the camera
  64094. */
  64095. rotation: Vector3;
  64096. /**
  64097. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  64098. */
  64099. rotationQuaternion: Quaternion;
  64100. /**
  64101. * Define the current speed of the camera
  64102. */
  64103. speed: number;
  64104. /**
  64105. * Add cconstraint to the camera to prevent it to move freely in all directions and
  64106. * around all axis.
  64107. */
  64108. noRotationConstraint: boolean;
  64109. /**
  64110. * Define the current target of the camera as an object or a position.
  64111. */
  64112. lockedTarget: any;
  64113. /** @hidden */
  64114. _currentTarget: Vector3;
  64115. /** @hidden */
  64116. _initialFocalDistance: number;
  64117. /** @hidden */
  64118. _viewMatrix: Matrix;
  64119. /** @hidden */
  64120. _camMatrix: Matrix;
  64121. /** @hidden */
  64122. _cameraTransformMatrix: Matrix;
  64123. /** @hidden */
  64124. _cameraRotationMatrix: Matrix;
  64125. /** @hidden */
  64126. _referencePoint: Vector3;
  64127. /** @hidden */
  64128. _transformedReferencePoint: Vector3;
  64129. protected _globalCurrentTarget: Vector3;
  64130. protected _globalCurrentUpVector: Vector3;
  64131. /** @hidden */
  64132. _reset: () => void;
  64133. private _defaultUp;
  64134. /**
  64135. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  64136. * This is the base of the follow, arc rotate cameras and Free camera
  64137. * @see http://doc.babylonjs.com/features/cameras
  64138. * @param name Defines the name of the camera in the scene
  64139. * @param position Defines the start position of the camera in the scene
  64140. * @param scene Defines the scene the camera belongs to
  64141. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64142. */
  64143. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64144. /**
  64145. * Gets the position in front of the camera at a given distance.
  64146. * @param distance The distance from the camera we want the position to be
  64147. * @returns the position
  64148. */
  64149. getFrontPosition(distance: number): Vector3;
  64150. /** @hidden */
  64151. _getLockedTargetPosition(): Nullable<Vector3>;
  64152. private _storedPosition;
  64153. private _storedRotation;
  64154. private _storedRotationQuaternion;
  64155. /**
  64156. * Store current camera state of the camera (fov, position, rotation, etc..)
  64157. * @returns the camera
  64158. */
  64159. storeState(): Camera;
  64160. /**
  64161. * Restored camera state. You must call storeState() first
  64162. * @returns whether it was successful or not
  64163. * @hidden
  64164. */
  64165. _restoreStateValues(): boolean;
  64166. /** @hidden */
  64167. _initCache(): void;
  64168. /** @hidden */
  64169. _updateCache(ignoreParentClass?: boolean): void;
  64170. /** @hidden */
  64171. _isSynchronizedViewMatrix(): boolean;
  64172. /** @hidden */
  64173. _computeLocalCameraSpeed(): number;
  64174. /** @hidden */
  64175. setTarget(target: Vector3): void;
  64176. /**
  64177. * Return the current target position of the camera. This value is expressed in local space.
  64178. * @returns the target position
  64179. */
  64180. getTarget(): Vector3;
  64181. /** @hidden */
  64182. _decideIfNeedsToMove(): boolean;
  64183. /** @hidden */
  64184. _updatePosition(): void;
  64185. /** @hidden */
  64186. _checkInputs(): void;
  64187. protected _updateCameraRotationMatrix(): void;
  64188. /**
  64189. * 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)
  64190. * @returns the current camera
  64191. */
  64192. private _rotateUpVectorWithCameraRotationMatrix;
  64193. private _cachedRotationZ;
  64194. private _cachedQuaternionRotationZ;
  64195. /** @hidden */
  64196. _getViewMatrix(): Matrix;
  64197. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  64198. /**
  64199. * @hidden
  64200. */
  64201. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  64202. /**
  64203. * @hidden
  64204. */
  64205. _updateRigCameras(): void;
  64206. private _getRigCamPositionAndTarget;
  64207. /**
  64208. * Gets the current object class name.
  64209. * @return the class name
  64210. */
  64211. getClassName(): string;
  64212. }
  64213. }
  64214. declare module BABYLON {
  64215. /**
  64216. * @ignore
  64217. * This is a list of all the different input types that are available in the application.
  64218. * Fo instance: ArcRotateCameraGamepadInput...
  64219. */
  64220. export var CameraInputTypes: {};
  64221. /**
  64222. * This is the contract to implement in order to create a new input class.
  64223. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  64224. */
  64225. export interface ICameraInput<TCamera extends Camera> {
  64226. /**
  64227. * Defines the camera the input is attached to.
  64228. */
  64229. camera: Nullable<TCamera>;
  64230. /**
  64231. * Gets the class name of the current intput.
  64232. * @returns the class name
  64233. */
  64234. getClassName(): string;
  64235. /**
  64236. * Get the friendly name associated with the input class.
  64237. * @returns the input friendly name
  64238. */
  64239. getSimpleName(): string;
  64240. /**
  64241. * Attach the input controls to a specific dom element to get the input from.
  64242. * @param element Defines the element the controls should be listened from
  64243. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64244. */
  64245. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64246. /**
  64247. * Detach the current controls from the specified dom element.
  64248. * @param element Defines the element to stop listening the inputs from
  64249. */
  64250. detachControl(element: Nullable<HTMLElement>): void;
  64251. /**
  64252. * Update the current camera state depending on the inputs that have been used this frame.
  64253. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64254. */
  64255. checkInputs?: () => void;
  64256. }
  64257. /**
  64258. * Represents a map of input types to input instance or input index to input instance.
  64259. */
  64260. export interface CameraInputsMap<TCamera extends Camera> {
  64261. /**
  64262. * Accessor to the input by input type.
  64263. */
  64264. [name: string]: ICameraInput<TCamera>;
  64265. /**
  64266. * Accessor to the input by input index.
  64267. */
  64268. [idx: number]: ICameraInput<TCamera>;
  64269. }
  64270. /**
  64271. * This represents the input manager used within a camera.
  64272. * It helps dealing with all the different kind of input attached to a camera.
  64273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64274. */
  64275. export class CameraInputsManager<TCamera extends Camera> {
  64276. /**
  64277. * Defines the list of inputs attahed to the camera.
  64278. */
  64279. attached: CameraInputsMap<TCamera>;
  64280. /**
  64281. * Defines the dom element the camera is collecting inputs from.
  64282. * This is null if the controls have not been attached.
  64283. */
  64284. attachedElement: Nullable<HTMLElement>;
  64285. /**
  64286. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64287. */
  64288. noPreventDefault: boolean;
  64289. /**
  64290. * Defined the camera the input manager belongs to.
  64291. */
  64292. camera: TCamera;
  64293. /**
  64294. * Update the current camera state depending on the inputs that have been used this frame.
  64295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64296. */
  64297. checkInputs: () => void;
  64298. /**
  64299. * Instantiate a new Camera Input Manager.
  64300. * @param camera Defines the camera the input manager blongs to
  64301. */
  64302. constructor(camera: TCamera);
  64303. /**
  64304. * Add an input method to a camera
  64305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64306. * @param input camera input method
  64307. */
  64308. add(input: ICameraInput<TCamera>): void;
  64309. /**
  64310. * Remove a specific input method from a camera
  64311. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  64312. * @param inputToRemove camera input method
  64313. */
  64314. remove(inputToRemove: ICameraInput<TCamera>): void;
  64315. /**
  64316. * Remove a specific input type from a camera
  64317. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  64318. * @param inputType the type of the input to remove
  64319. */
  64320. removeByType(inputType: string): void;
  64321. private _addCheckInputs;
  64322. /**
  64323. * Attach the input controls to the currently attached dom element to listen the events from.
  64324. * @param input Defines the input to attach
  64325. */
  64326. attachInput(input: ICameraInput<TCamera>): void;
  64327. /**
  64328. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  64329. * @param element Defines the dom element to collect the events from
  64330. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64331. */
  64332. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  64333. /**
  64334. * Detach the current manager inputs controls from a specific dom element.
  64335. * @param element Defines the dom element to collect the events from
  64336. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  64337. */
  64338. detachElement(element: HTMLElement, disconnect?: boolean): void;
  64339. /**
  64340. * Rebuild the dynamic inputCheck function from the current list of
  64341. * defined inputs in the manager.
  64342. */
  64343. rebuildInputCheck(): void;
  64344. /**
  64345. * Remove all attached input methods from a camera
  64346. */
  64347. clear(): void;
  64348. /**
  64349. * Serialize the current input manager attached to a camera.
  64350. * This ensures than once parsed,
  64351. * the input associated to the camera will be identical to the current ones
  64352. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  64353. */
  64354. serialize(serializedCamera: any): void;
  64355. /**
  64356. * Parses an input manager serialized JSON to restore the previous list of inputs
  64357. * and states associated to a camera.
  64358. * @param parsedCamera Defines the JSON to parse
  64359. */
  64360. parse(parsedCamera: any): void;
  64361. }
  64362. }
  64363. declare module BABYLON {
  64364. /**
  64365. * Gather the list of keyboard event types as constants.
  64366. */
  64367. export class KeyboardEventTypes {
  64368. /**
  64369. * The keydown event is fired when a key becomes active (pressed).
  64370. */
  64371. static readonly KEYDOWN: number;
  64372. /**
  64373. * The keyup event is fired when a key has been released.
  64374. */
  64375. static readonly KEYUP: number;
  64376. }
  64377. /**
  64378. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64379. */
  64380. export class KeyboardInfo {
  64381. /**
  64382. * Defines the type of event (KeyboardEventTypes)
  64383. */
  64384. type: number;
  64385. /**
  64386. * Defines the related dom event
  64387. */
  64388. event: KeyboardEvent;
  64389. /**
  64390. * Instantiates a new keyboard info.
  64391. * This class is used to store keyboard related info for the onKeyboardObservable event.
  64392. * @param type Defines the type of event (KeyboardEventTypes)
  64393. * @param event Defines the related dom event
  64394. */
  64395. constructor(
  64396. /**
  64397. * Defines the type of event (KeyboardEventTypes)
  64398. */
  64399. type: number,
  64400. /**
  64401. * Defines the related dom event
  64402. */
  64403. event: KeyboardEvent);
  64404. }
  64405. /**
  64406. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64407. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  64408. */
  64409. export class KeyboardInfoPre extends KeyboardInfo {
  64410. /**
  64411. * Defines the type of event (KeyboardEventTypes)
  64412. */
  64413. type: number;
  64414. /**
  64415. * Defines the related dom event
  64416. */
  64417. event: KeyboardEvent;
  64418. /**
  64419. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  64420. */
  64421. skipOnPointerObservable: boolean;
  64422. /**
  64423. * Instantiates a new keyboard pre info.
  64424. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  64425. * @param type Defines the type of event (KeyboardEventTypes)
  64426. * @param event Defines the related dom event
  64427. */
  64428. constructor(
  64429. /**
  64430. * Defines the type of event (KeyboardEventTypes)
  64431. */
  64432. type: number,
  64433. /**
  64434. * Defines the related dom event
  64435. */
  64436. event: KeyboardEvent);
  64437. }
  64438. }
  64439. declare module BABYLON {
  64440. /**
  64441. * Manage the keyboard inputs to control the movement of a free camera.
  64442. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64443. */
  64444. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  64445. /**
  64446. * Defines the camera the input is attached to.
  64447. */
  64448. camera: FreeCamera;
  64449. /**
  64450. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64451. */
  64452. keysUp: number[];
  64453. /**
  64454. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64455. */
  64456. keysDown: number[];
  64457. /**
  64458. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64459. */
  64460. keysLeft: number[];
  64461. /**
  64462. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64463. */
  64464. keysRight: number[];
  64465. private _keys;
  64466. private _onCanvasBlurObserver;
  64467. private _onKeyboardObserver;
  64468. private _engine;
  64469. private _scene;
  64470. /**
  64471. * Attach the input controls to a specific dom element to get the input from.
  64472. * @param element Defines the element the controls should be listened from
  64473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64474. */
  64475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64476. /**
  64477. * Detach the current controls from the specified dom element.
  64478. * @param element Defines the element to stop listening the inputs from
  64479. */
  64480. detachControl(element: Nullable<HTMLElement>): void;
  64481. /**
  64482. * Update the current camera state depending on the inputs that have been used this frame.
  64483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64484. */
  64485. checkInputs(): void;
  64486. /**
  64487. * Gets the class name of the current intput.
  64488. * @returns the class name
  64489. */
  64490. getClassName(): string;
  64491. /** @hidden */
  64492. _onLostFocus(): void;
  64493. /**
  64494. * Get the friendly name associated with the input class.
  64495. * @returns the input friendly name
  64496. */
  64497. getSimpleName(): string;
  64498. }
  64499. }
  64500. declare module BABYLON {
  64501. /**
  64502. * Gather the list of pointer event types as constants.
  64503. */
  64504. export class PointerEventTypes {
  64505. /**
  64506. * 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.
  64507. */
  64508. static readonly POINTERDOWN: number;
  64509. /**
  64510. * The pointerup event is fired when a pointer is no longer active.
  64511. */
  64512. static readonly POINTERUP: number;
  64513. /**
  64514. * The pointermove event is fired when a pointer changes coordinates.
  64515. */
  64516. static readonly POINTERMOVE: number;
  64517. /**
  64518. * The pointerwheel event is fired when a mouse wheel has been rotated.
  64519. */
  64520. static readonly POINTERWHEEL: number;
  64521. /**
  64522. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  64523. */
  64524. static readonly POINTERPICK: number;
  64525. /**
  64526. * The pointertap event is fired when a the object has been touched and released without drag.
  64527. */
  64528. static readonly POINTERTAP: number;
  64529. /**
  64530. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  64531. */
  64532. static readonly POINTERDOUBLETAP: number;
  64533. }
  64534. /**
  64535. * Base class of pointer info types.
  64536. */
  64537. export class PointerInfoBase {
  64538. /**
  64539. * Defines the type of event (PointerEventTypes)
  64540. */
  64541. type: number;
  64542. /**
  64543. * Defines the related dom event
  64544. */
  64545. event: PointerEvent | MouseWheelEvent;
  64546. /**
  64547. * Instantiates the base class of pointers info.
  64548. * @param type Defines the type of event (PointerEventTypes)
  64549. * @param event Defines the related dom event
  64550. */
  64551. constructor(
  64552. /**
  64553. * Defines the type of event (PointerEventTypes)
  64554. */
  64555. type: number,
  64556. /**
  64557. * Defines the related dom event
  64558. */
  64559. event: PointerEvent | MouseWheelEvent);
  64560. }
  64561. /**
  64562. * This class is used to store pointer related info for the onPrePointerObservable event.
  64563. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  64564. */
  64565. export class PointerInfoPre extends PointerInfoBase {
  64566. /**
  64567. * Ray from a pointer if availible (eg. 6dof controller)
  64568. */
  64569. ray: Nullable<Ray>;
  64570. /**
  64571. * Defines the local position of the pointer on the canvas.
  64572. */
  64573. localPosition: Vector2;
  64574. /**
  64575. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  64576. */
  64577. skipOnPointerObservable: boolean;
  64578. /**
  64579. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  64580. * @param type Defines the type of event (PointerEventTypes)
  64581. * @param event Defines the related dom event
  64582. * @param localX Defines the local x coordinates of the pointer when the event occured
  64583. * @param localY Defines the local y coordinates of the pointer when the event occured
  64584. */
  64585. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  64586. }
  64587. /**
  64588. * This type contains all the data related to a pointer event in Babylon.js.
  64589. * 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.
  64590. */
  64591. export class PointerInfo extends PointerInfoBase {
  64592. /**
  64593. * Defines the picking info associated to the info (if any)\
  64594. */
  64595. pickInfo: Nullable<PickingInfo>;
  64596. /**
  64597. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  64598. * @param type Defines the type of event (PointerEventTypes)
  64599. * @param event Defines the related dom event
  64600. * @param pickInfo Defines the picking info associated to the info (if any)\
  64601. */
  64602. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  64603. /**
  64604. * Defines the picking info associated to the info (if any)\
  64605. */
  64606. pickInfo: Nullable<PickingInfo>);
  64607. }
  64608. }
  64609. declare module BABYLON {
  64610. /**
  64611. * Manage the mouse inputs to control the movement of a free camera.
  64612. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64613. */
  64614. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  64615. /**
  64616. * Define if touch is enabled in the mouse input
  64617. */
  64618. touchEnabled: boolean;
  64619. /**
  64620. * Defines the camera the input is attached to.
  64621. */
  64622. camera: FreeCamera;
  64623. /**
  64624. * Defines the buttons associated with the input to handle camera move.
  64625. */
  64626. buttons: number[];
  64627. /**
  64628. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  64629. */
  64630. angularSensibility: number;
  64631. private _pointerInput;
  64632. private _onMouseMove;
  64633. private _observer;
  64634. private previousPosition;
  64635. /**
  64636. * Manage the mouse inputs to control the movement of a free camera.
  64637. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64638. * @param touchEnabled Defines if touch is enabled or not
  64639. */
  64640. constructor(
  64641. /**
  64642. * Define if touch is enabled in the mouse input
  64643. */
  64644. touchEnabled?: boolean);
  64645. /**
  64646. * Attach the input controls to a specific dom element to get the input from.
  64647. * @param element Defines the element the controls should be listened from
  64648. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64649. */
  64650. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64651. /**
  64652. * Detach the current controls from the specified dom element.
  64653. * @param element Defines the element to stop listening the inputs from
  64654. */
  64655. detachControl(element: Nullable<HTMLElement>): void;
  64656. /**
  64657. * Gets the class name of the current intput.
  64658. * @returns the class name
  64659. */
  64660. getClassName(): string;
  64661. /**
  64662. * Get the friendly name associated with the input class.
  64663. * @returns the input friendly name
  64664. */
  64665. getSimpleName(): string;
  64666. }
  64667. }
  64668. declare module BABYLON {
  64669. /**
  64670. * Manage the touch inputs to control the movement of a free camera.
  64671. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64672. */
  64673. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  64674. /**
  64675. * Defines the camera the input is attached to.
  64676. */
  64677. camera: FreeCamera;
  64678. /**
  64679. * Defines the touch sensibility for rotation.
  64680. * The higher the faster.
  64681. */
  64682. touchAngularSensibility: number;
  64683. /**
  64684. * Defines the touch sensibility for move.
  64685. * The higher the faster.
  64686. */
  64687. touchMoveSensibility: number;
  64688. private _offsetX;
  64689. private _offsetY;
  64690. private _pointerPressed;
  64691. private _pointerInput;
  64692. private _observer;
  64693. private _onLostFocus;
  64694. /**
  64695. * Attach the input controls to a specific dom element to get the input from.
  64696. * @param element Defines the element the controls should be listened from
  64697. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64698. */
  64699. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64700. /**
  64701. * Detach the current controls from the specified dom element.
  64702. * @param element Defines the element to stop listening the inputs from
  64703. */
  64704. detachControl(element: Nullable<HTMLElement>): void;
  64705. /**
  64706. * Update the current camera state depending on the inputs that have been used this frame.
  64707. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  64708. */
  64709. checkInputs(): void;
  64710. /**
  64711. * Gets the class name of the current intput.
  64712. * @returns the class name
  64713. */
  64714. getClassName(): string;
  64715. /**
  64716. * Get the friendly name associated with the input class.
  64717. * @returns the input friendly name
  64718. */
  64719. getSimpleName(): string;
  64720. }
  64721. }
  64722. declare module BABYLON {
  64723. /**
  64724. * Default Inputs manager for the FreeCamera.
  64725. * It groups all the default supported inputs for ease of use.
  64726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  64727. */
  64728. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  64729. /**
  64730. * Instantiates a new FreeCameraInputsManager.
  64731. * @param camera Defines the camera the inputs belong to
  64732. */
  64733. constructor(camera: FreeCamera);
  64734. /**
  64735. * Add keyboard input support to the input manager.
  64736. * @returns the current input manager
  64737. */
  64738. addKeyboard(): FreeCameraInputsManager;
  64739. /**
  64740. * Add mouse input support to the input manager.
  64741. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  64742. * @returns the current input manager
  64743. */
  64744. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  64745. /**
  64746. * Add touch input support to the input manager.
  64747. * @returns the current input manager
  64748. */
  64749. addTouch(): FreeCameraInputsManager;
  64750. }
  64751. }
  64752. declare module BABYLON {
  64753. /**
  64754. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  64755. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  64756. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  64757. */
  64758. export class FreeCamera extends TargetCamera {
  64759. /**
  64760. * Define the collision ellipsoid of the camera.
  64761. * This is helpful to simulate a camera body like the player body around the camera
  64762. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  64763. */
  64764. ellipsoid: Vector3;
  64765. /**
  64766. * Define an offset for the position of the ellipsoid around the camera.
  64767. * This can be helpful to determine the center of the body near the gravity center of the body
  64768. * instead of its head.
  64769. */
  64770. ellipsoidOffset: Vector3;
  64771. /**
  64772. * Enable or disable collisions of the camera with the rest of the scene objects.
  64773. */
  64774. checkCollisions: boolean;
  64775. /**
  64776. * Enable or disable gravity on the camera.
  64777. */
  64778. applyGravity: boolean;
  64779. /**
  64780. * Define the input manager associated to the camera.
  64781. */
  64782. inputs: FreeCameraInputsManager;
  64783. /**
  64784. * Gets the input sensibility for a mouse input. (default is 2000.0)
  64785. * Higher values reduce sensitivity.
  64786. */
  64787. /**
  64788. * Sets the input sensibility for a mouse input. (default is 2000.0)
  64789. * Higher values reduce sensitivity.
  64790. */
  64791. angularSensibility: number;
  64792. /**
  64793. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  64794. */
  64795. keysUp: number[];
  64796. /**
  64797. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  64798. */
  64799. keysDown: number[];
  64800. /**
  64801. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  64802. */
  64803. keysLeft: number[];
  64804. /**
  64805. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  64806. */
  64807. keysRight: number[];
  64808. /**
  64809. * Event raised when the camera collide with a mesh in the scene.
  64810. */
  64811. onCollide: (collidedMesh: AbstractMesh) => void;
  64812. private _collider;
  64813. private _needMoveForGravity;
  64814. private _oldPosition;
  64815. private _diffPosition;
  64816. private _newPosition;
  64817. /** @hidden */
  64818. _localDirection: Vector3;
  64819. /** @hidden */
  64820. _transformedDirection: Vector3;
  64821. /**
  64822. * Instantiates a Free Camera.
  64823. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  64824. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  64825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  64826. * @param name Define the name of the camera in the scene
  64827. * @param position Define the start position of the camera in the scene
  64828. * @param scene Define the scene the camera belongs to
  64829. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  64830. */
  64831. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  64832. /**
  64833. * Attached controls to the current camera.
  64834. * @param element Defines the element the controls should be listened from
  64835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  64836. */
  64837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  64838. /**
  64839. * Detach the current controls from the camera.
  64840. * The camera will stop reacting to inputs.
  64841. * @param element Defines the element to stop listening the inputs from
  64842. */
  64843. detachControl(element: HTMLElement): void;
  64844. private _collisionMask;
  64845. /**
  64846. * Define a collision mask to limit the list of object the camera can collide with
  64847. */
  64848. collisionMask: number;
  64849. /** @hidden */
  64850. _collideWithWorld(displacement: Vector3): void;
  64851. private _onCollisionPositionChange;
  64852. /** @hidden */
  64853. _checkInputs(): void;
  64854. /** @hidden */
  64855. _decideIfNeedsToMove(): boolean;
  64856. /** @hidden */
  64857. _updatePosition(): void;
  64858. /**
  64859. * Destroy the camera and release the current resources hold by it.
  64860. */
  64861. dispose(): void;
  64862. /**
  64863. * Gets the current object class name.
  64864. * @return the class name
  64865. */
  64866. getClassName(): string;
  64867. }
  64868. }
  64869. declare module BABYLON {
  64870. /**
  64871. * Represents a gamepad control stick position
  64872. */
  64873. export class StickValues {
  64874. /**
  64875. * The x component of the control stick
  64876. */
  64877. x: number;
  64878. /**
  64879. * The y component of the control stick
  64880. */
  64881. y: number;
  64882. /**
  64883. * Initializes the gamepad x and y control stick values
  64884. * @param x The x component of the gamepad control stick value
  64885. * @param y The y component of the gamepad control stick value
  64886. */
  64887. constructor(
  64888. /**
  64889. * The x component of the control stick
  64890. */
  64891. x: number,
  64892. /**
  64893. * The y component of the control stick
  64894. */
  64895. y: number);
  64896. }
  64897. /**
  64898. * An interface which manages callbacks for gamepad button changes
  64899. */
  64900. export interface GamepadButtonChanges {
  64901. /**
  64902. * Called when a gamepad has been changed
  64903. */
  64904. changed: boolean;
  64905. /**
  64906. * Called when a gamepad press event has been triggered
  64907. */
  64908. pressChanged: boolean;
  64909. /**
  64910. * Called when a touch event has been triggered
  64911. */
  64912. touchChanged: boolean;
  64913. /**
  64914. * Called when a value has changed
  64915. */
  64916. valueChanged: boolean;
  64917. }
  64918. /**
  64919. * Represents a gamepad
  64920. */
  64921. export class Gamepad {
  64922. /**
  64923. * The id of the gamepad
  64924. */
  64925. id: string;
  64926. /**
  64927. * The index of the gamepad
  64928. */
  64929. index: number;
  64930. /**
  64931. * The browser gamepad
  64932. */
  64933. browserGamepad: any;
  64934. /**
  64935. * Specifies what type of gamepad this represents
  64936. */
  64937. type: number;
  64938. private _leftStick;
  64939. private _rightStick;
  64940. /** @hidden */
  64941. _isConnected: boolean;
  64942. private _leftStickAxisX;
  64943. private _leftStickAxisY;
  64944. private _rightStickAxisX;
  64945. private _rightStickAxisY;
  64946. /**
  64947. * Triggered when the left control stick has been changed
  64948. */
  64949. private _onleftstickchanged;
  64950. /**
  64951. * Triggered when the right control stick has been changed
  64952. */
  64953. private _onrightstickchanged;
  64954. /**
  64955. * Represents a gamepad controller
  64956. */
  64957. static GAMEPAD: number;
  64958. /**
  64959. * Represents a generic controller
  64960. */
  64961. static GENERIC: number;
  64962. /**
  64963. * Represents an XBox controller
  64964. */
  64965. static XBOX: number;
  64966. /**
  64967. * Represents a pose-enabled controller
  64968. */
  64969. static POSE_ENABLED: number;
  64970. /**
  64971. * Specifies whether the left control stick should be Y-inverted
  64972. */
  64973. protected _invertLeftStickY: boolean;
  64974. /**
  64975. * Specifies if the gamepad has been connected
  64976. */
  64977. readonly isConnected: boolean;
  64978. /**
  64979. * Initializes the gamepad
  64980. * @param id The id of the gamepad
  64981. * @param index The index of the gamepad
  64982. * @param browserGamepad The browser gamepad
  64983. * @param leftStickX The x component of the left joystick
  64984. * @param leftStickY The y component of the left joystick
  64985. * @param rightStickX The x component of the right joystick
  64986. * @param rightStickY The y component of the right joystick
  64987. */
  64988. constructor(
  64989. /**
  64990. * The id of the gamepad
  64991. */
  64992. id: string,
  64993. /**
  64994. * The index of the gamepad
  64995. */
  64996. index: number,
  64997. /**
  64998. * The browser gamepad
  64999. */
  65000. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  65001. /**
  65002. * Callback triggered when the left joystick has changed
  65003. * @param callback
  65004. */
  65005. onleftstickchanged(callback: (values: StickValues) => void): void;
  65006. /**
  65007. * Callback triggered when the right joystick has changed
  65008. * @param callback
  65009. */
  65010. onrightstickchanged(callback: (values: StickValues) => void): void;
  65011. /**
  65012. * Gets the left joystick
  65013. */
  65014. /**
  65015. * Sets the left joystick values
  65016. */
  65017. leftStick: StickValues;
  65018. /**
  65019. * Gets the right joystick
  65020. */
  65021. /**
  65022. * Sets the right joystick value
  65023. */
  65024. rightStick: StickValues;
  65025. /**
  65026. * Updates the gamepad joystick positions
  65027. */
  65028. update(): void;
  65029. /**
  65030. * Disposes the gamepad
  65031. */
  65032. dispose(): void;
  65033. }
  65034. /**
  65035. * Represents a generic gamepad
  65036. */
  65037. export class GenericPad extends Gamepad {
  65038. private _buttons;
  65039. private _onbuttondown;
  65040. private _onbuttonup;
  65041. /**
  65042. * Observable triggered when a button has been pressed
  65043. */
  65044. onButtonDownObservable: Observable<number>;
  65045. /**
  65046. * Observable triggered when a button has been released
  65047. */
  65048. onButtonUpObservable: Observable<number>;
  65049. /**
  65050. * Callback triggered when a button has been pressed
  65051. * @param callback Called when a button has been pressed
  65052. */
  65053. onbuttondown(callback: (buttonPressed: number) => void): void;
  65054. /**
  65055. * Callback triggered when a button has been released
  65056. * @param callback Called when a button has been released
  65057. */
  65058. onbuttonup(callback: (buttonReleased: number) => void): void;
  65059. /**
  65060. * Initializes the generic gamepad
  65061. * @param id The id of the generic gamepad
  65062. * @param index The index of the generic gamepad
  65063. * @param browserGamepad The browser gamepad
  65064. */
  65065. constructor(id: string, index: number, browserGamepad: any);
  65066. private _setButtonValue;
  65067. /**
  65068. * Updates the generic gamepad
  65069. */
  65070. update(): void;
  65071. /**
  65072. * Disposes the generic gamepad
  65073. */
  65074. dispose(): void;
  65075. }
  65076. }
  65077. declare module BABYLON {
  65078. /**
  65079. * 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.
  65080. * @see https://doc.babylonjs.com/how_to/transformnode
  65081. */
  65082. export class TransformNode extends Node {
  65083. /**
  65084. * Object will not rotate to face the camera
  65085. */
  65086. static BILLBOARDMODE_NONE: number;
  65087. /**
  65088. * Object will rotate to face the camera but only on the x axis
  65089. */
  65090. static BILLBOARDMODE_X: number;
  65091. /**
  65092. * Object will rotate to face the camera but only on the y axis
  65093. */
  65094. static BILLBOARDMODE_Y: number;
  65095. /**
  65096. * Object will rotate to face the camera but only on the z axis
  65097. */
  65098. static BILLBOARDMODE_Z: number;
  65099. /**
  65100. * Object will rotate to face the camera
  65101. */
  65102. static BILLBOARDMODE_ALL: number;
  65103. private _forward;
  65104. private _forwardInverted;
  65105. private _up;
  65106. private _right;
  65107. private _rightInverted;
  65108. private _position;
  65109. private _rotation;
  65110. private _rotationQuaternion;
  65111. protected _scaling: Vector3;
  65112. protected _isDirty: boolean;
  65113. private _transformToBoneReferal;
  65114. /**
  65115. * Set the billboard mode. Default is 0.
  65116. *
  65117. * | Value | Type | Description |
  65118. * | --- | --- | --- |
  65119. * | 0 | BILLBOARDMODE_NONE | |
  65120. * | 1 | BILLBOARDMODE_X | |
  65121. * | 2 | BILLBOARDMODE_Y | |
  65122. * | 4 | BILLBOARDMODE_Z | |
  65123. * | 7 | BILLBOARDMODE_ALL | |
  65124. *
  65125. */
  65126. billboardMode: number;
  65127. /**
  65128. * 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
  65129. */
  65130. scalingDeterminant: number;
  65131. /**
  65132. * Sets the distance of the object to max, often used by skybox
  65133. */
  65134. infiniteDistance: boolean;
  65135. /**
  65136. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  65137. * By default the system will update normals to compensate
  65138. */
  65139. ignoreNonUniformScaling: boolean;
  65140. /** @hidden */
  65141. _poseMatrix: Matrix;
  65142. /** @hidden */
  65143. _localMatrix: Matrix;
  65144. private _absolutePosition;
  65145. private _pivotMatrix;
  65146. private _pivotMatrixInverse;
  65147. protected _postMultiplyPivotMatrix: boolean;
  65148. protected _isWorldMatrixFrozen: boolean;
  65149. /** @hidden */
  65150. _indexInSceneTransformNodesArray: number;
  65151. /**
  65152. * An event triggered after the world matrix is updated
  65153. */
  65154. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  65155. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  65156. /**
  65157. * Gets a string identifying the name of the class
  65158. * @returns "TransformNode" string
  65159. */
  65160. getClassName(): string;
  65161. /**
  65162. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  65163. */
  65164. position: Vector3;
  65165. /**
  65166. * 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)).
  65167. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  65168. */
  65169. rotation: Vector3;
  65170. /**
  65171. * 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)).
  65172. */
  65173. scaling: Vector3;
  65174. /**
  65175. * 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).
  65176. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  65177. */
  65178. rotationQuaternion: Nullable<Quaternion>;
  65179. /**
  65180. * The forward direction of that transform in world space.
  65181. */
  65182. readonly forward: Vector3;
  65183. /**
  65184. * The up direction of that transform in world space.
  65185. */
  65186. readonly up: Vector3;
  65187. /**
  65188. * The right direction of that transform in world space.
  65189. */
  65190. readonly right: Vector3;
  65191. /**
  65192. * Copies the parameter passed Matrix into the mesh Pose matrix.
  65193. * @param matrix the matrix to copy the pose from
  65194. * @returns this TransformNode.
  65195. */
  65196. updatePoseMatrix(matrix: Matrix): TransformNode;
  65197. /**
  65198. * Returns the mesh Pose matrix.
  65199. * @returns the pose matrix
  65200. */
  65201. getPoseMatrix(): Matrix;
  65202. /** @hidden */
  65203. _isSynchronized(): boolean;
  65204. /** @hidden */
  65205. _initCache(): void;
  65206. /**
  65207. * Flag the transform node as dirty (Forcing it to update everything)
  65208. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  65209. * @returns this transform node
  65210. */
  65211. markAsDirty(property: string): TransformNode;
  65212. /**
  65213. * Returns the current mesh absolute position.
  65214. * Returns a Vector3.
  65215. */
  65216. readonly absolutePosition: Vector3;
  65217. /**
  65218. * Sets a new matrix to apply before all other transformation
  65219. * @param matrix defines the transform matrix
  65220. * @returns the current TransformNode
  65221. */
  65222. setPreTransformMatrix(matrix: Matrix): TransformNode;
  65223. /**
  65224. * Sets a new pivot matrix to the current node
  65225. * @param matrix defines the new pivot matrix to use
  65226. * @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
  65227. * @returns the current TransformNode
  65228. */
  65229. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  65230. /**
  65231. * Returns the mesh pivot matrix.
  65232. * Default : Identity.
  65233. * @returns the matrix
  65234. */
  65235. getPivotMatrix(): Matrix;
  65236. /**
  65237. * Prevents the World matrix to be computed any longer.
  65238. * @returns the TransformNode.
  65239. */
  65240. freezeWorldMatrix(): TransformNode;
  65241. /**
  65242. * Allows back the World matrix computation.
  65243. * @returns the TransformNode.
  65244. */
  65245. unfreezeWorldMatrix(): this;
  65246. /**
  65247. * True if the World matrix has been frozen.
  65248. */
  65249. readonly isWorldMatrixFrozen: boolean;
  65250. /**
  65251. * Retuns the mesh absolute position in the World.
  65252. * @returns a Vector3.
  65253. */
  65254. getAbsolutePosition(): Vector3;
  65255. /**
  65256. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  65257. * @param absolutePosition the absolute position to set
  65258. * @returns the TransformNode.
  65259. */
  65260. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  65261. /**
  65262. * Sets the mesh position in its local space.
  65263. * @param vector3 the position to set in localspace
  65264. * @returns the TransformNode.
  65265. */
  65266. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  65267. /**
  65268. * Returns the mesh position in the local space from the current World matrix values.
  65269. * @returns a new Vector3.
  65270. */
  65271. getPositionExpressedInLocalSpace(): Vector3;
  65272. /**
  65273. * Translates the mesh along the passed Vector3 in its local space.
  65274. * @param vector3 the distance to translate in localspace
  65275. * @returns the TransformNode.
  65276. */
  65277. locallyTranslate(vector3: Vector3): TransformNode;
  65278. private static _lookAtVectorCache;
  65279. /**
  65280. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  65281. * @param targetPoint the position (must be in same space as current mesh) to look at
  65282. * @param yawCor optional yaw (y-axis) correction in radians
  65283. * @param pitchCor optional pitch (x-axis) correction in radians
  65284. * @param rollCor optional roll (z-axis) correction in radians
  65285. * @param space the choosen space of the target
  65286. * @returns the TransformNode.
  65287. */
  65288. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  65289. /**
  65290. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65291. * This Vector3 is expressed in the World space.
  65292. * @param localAxis axis to rotate
  65293. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  65294. */
  65295. getDirection(localAxis: Vector3): Vector3;
  65296. /**
  65297. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  65298. * localAxis is expressed in the mesh local space.
  65299. * result is computed in the Wordl space from the mesh World matrix.
  65300. * @param localAxis axis to rotate
  65301. * @param result the resulting transformnode
  65302. * @returns this TransformNode.
  65303. */
  65304. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  65305. /**
  65306. * Sets this transform node rotation to the given local axis.
  65307. * @param localAxis the axis in local space
  65308. * @param yawCor optional yaw (y-axis) correction in radians
  65309. * @param pitchCor optional pitch (x-axis) correction in radians
  65310. * @param rollCor optional roll (z-axis) correction in radians
  65311. * @returns this TransformNode
  65312. */
  65313. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  65314. /**
  65315. * Sets a new pivot point to the current node
  65316. * @param point defines the new pivot point to use
  65317. * @param space defines if the point is in world or local space (local by default)
  65318. * @returns the current TransformNode
  65319. */
  65320. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  65321. /**
  65322. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  65323. * @returns the pivot point
  65324. */
  65325. getPivotPoint(): Vector3;
  65326. /**
  65327. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  65328. * @param result the vector3 to store the result
  65329. * @returns this TransformNode.
  65330. */
  65331. getPivotPointToRef(result: Vector3): TransformNode;
  65332. /**
  65333. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  65334. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  65335. */
  65336. getAbsolutePivotPoint(): Vector3;
  65337. /**
  65338. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  65339. * @param result vector3 to store the result
  65340. * @returns this TransformNode.
  65341. */
  65342. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  65343. /**
  65344. * Defines the passed node as the parent of the current node.
  65345. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  65346. * @param node the node ot set as the parent
  65347. * @returns this TransformNode.
  65348. */
  65349. setParent(node: Nullable<Node>): TransformNode;
  65350. private _nonUniformScaling;
  65351. /**
  65352. * True if the scaling property of this object is non uniform eg. (1,2,1)
  65353. */
  65354. readonly nonUniformScaling: boolean;
  65355. /** @hidden */
  65356. _updateNonUniformScalingState(value: boolean): boolean;
  65357. /**
  65358. * Attach the current TransformNode to another TransformNode associated with a bone
  65359. * @param bone Bone affecting the TransformNode
  65360. * @param affectedTransformNode TransformNode associated with the bone
  65361. * @returns this object
  65362. */
  65363. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  65364. /**
  65365. * Detach the transform node if its associated with a bone
  65366. * @returns this object
  65367. */
  65368. detachFromBone(): TransformNode;
  65369. private static _rotationAxisCache;
  65370. /**
  65371. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  65372. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65373. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65374. * The passed axis is also normalized.
  65375. * @param axis the axis to rotate around
  65376. * @param amount the amount to rotate in radians
  65377. * @param space Space to rotate in (Default: local)
  65378. * @returns the TransformNode.
  65379. */
  65380. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  65381. /**
  65382. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  65383. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  65384. * The passed axis is also normalized. .
  65385. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  65386. * @param point the point to rotate around
  65387. * @param axis the axis to rotate around
  65388. * @param amount the amount to rotate in radians
  65389. * @returns the TransformNode
  65390. */
  65391. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  65392. /**
  65393. * Translates the mesh along the axis vector for the passed distance in the given space.
  65394. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  65395. * @param axis the axis to translate in
  65396. * @param distance the distance to translate
  65397. * @param space Space to rotate in (Default: local)
  65398. * @returns the TransformNode.
  65399. */
  65400. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  65401. /**
  65402. * Adds a rotation step to the mesh current rotation.
  65403. * x, y, z are Euler angles expressed in radians.
  65404. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  65405. * This means this rotation is made in the mesh local space only.
  65406. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  65407. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  65408. * ```javascript
  65409. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  65410. * ```
  65411. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  65412. * 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.
  65413. * @param x Rotation to add
  65414. * @param y Rotation to add
  65415. * @param z Rotation to add
  65416. * @returns the TransformNode.
  65417. */
  65418. addRotation(x: number, y: number, z: number): TransformNode;
  65419. /**
  65420. * Computes the world matrix of the node
  65421. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65422. * @returns the world matrix
  65423. */
  65424. computeWorldMatrix(force?: boolean): Matrix;
  65425. protected _afterComputeWorldMatrix(): void;
  65426. /**
  65427. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  65428. * @param func callback function to add
  65429. *
  65430. * @returns the TransformNode.
  65431. */
  65432. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65433. /**
  65434. * Removes a registered callback function.
  65435. * @param func callback function to remove
  65436. * @returns the TransformNode.
  65437. */
  65438. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  65439. /**
  65440. * Gets the position of the current mesh in camera space
  65441. * @param camera defines the camera to use
  65442. * @returns a position
  65443. */
  65444. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  65445. /**
  65446. * Returns the distance from the mesh to the active camera
  65447. * @param camera defines the camera to use
  65448. * @returns the distance
  65449. */
  65450. getDistanceToCamera(camera?: Nullable<Camera>): number;
  65451. /**
  65452. * Clone the current transform node
  65453. * @param name Name of the new clone
  65454. * @param newParent New parent for the clone
  65455. * @param doNotCloneChildren Do not clone children hierarchy
  65456. * @returns the new transform node
  65457. */
  65458. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  65459. /**
  65460. * Serializes the objects information.
  65461. * @param currentSerializationObject defines the object to serialize in
  65462. * @returns the serialized object
  65463. */
  65464. serialize(currentSerializationObject?: any): any;
  65465. /**
  65466. * Returns a new TransformNode object parsed from the source provided.
  65467. * @param parsedTransformNode is the source.
  65468. * @param scene the scne the object belongs to
  65469. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  65470. * @returns a new TransformNode object parsed from the source provided.
  65471. */
  65472. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  65473. /**
  65474. * Get all child-transformNodes of this node
  65475. * @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
  65476. * @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
  65477. * @returns an array of TransformNode
  65478. */
  65479. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  65480. /**
  65481. * Releases resources associated with this transform node.
  65482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  65483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  65484. */
  65485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  65486. }
  65487. }
  65488. declare module BABYLON {
  65489. /**
  65490. * Defines the types of pose enabled controllers that are supported
  65491. */
  65492. export enum PoseEnabledControllerType {
  65493. /**
  65494. * HTC Vive
  65495. */
  65496. VIVE = 0,
  65497. /**
  65498. * Oculus Rift
  65499. */
  65500. OCULUS = 1,
  65501. /**
  65502. * Windows mixed reality
  65503. */
  65504. WINDOWS = 2,
  65505. /**
  65506. * Samsung gear VR
  65507. */
  65508. GEAR_VR = 3,
  65509. /**
  65510. * Google Daydream
  65511. */
  65512. DAYDREAM = 4,
  65513. /**
  65514. * Generic
  65515. */
  65516. GENERIC = 5
  65517. }
  65518. /**
  65519. * Defines the MutableGamepadButton interface for the state of a gamepad button
  65520. */
  65521. export interface MutableGamepadButton {
  65522. /**
  65523. * Value of the button/trigger
  65524. */
  65525. value: number;
  65526. /**
  65527. * If the button/trigger is currently touched
  65528. */
  65529. touched: boolean;
  65530. /**
  65531. * If the button/trigger is currently pressed
  65532. */
  65533. pressed: boolean;
  65534. }
  65535. /**
  65536. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  65537. * @hidden
  65538. */
  65539. export interface ExtendedGamepadButton extends GamepadButton {
  65540. /**
  65541. * If the button/trigger is currently pressed
  65542. */
  65543. readonly pressed: boolean;
  65544. /**
  65545. * If the button/trigger is currently touched
  65546. */
  65547. readonly touched: boolean;
  65548. /**
  65549. * Value of the button/trigger
  65550. */
  65551. readonly value: number;
  65552. }
  65553. /** @hidden */
  65554. export interface _GamePadFactory {
  65555. /**
  65556. * Returns wether or not the current gamepad can be created for this type of controller.
  65557. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  65558. * @returns true if it can be created, otherwise false
  65559. */
  65560. canCreate(gamepadInfo: any): boolean;
  65561. /**
  65562. * Creates a new instance of the Gamepad.
  65563. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  65564. * @returns the new gamepad instance
  65565. */
  65566. create(gamepadInfo: any): Gamepad;
  65567. }
  65568. /**
  65569. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  65570. */
  65571. export class PoseEnabledControllerHelper {
  65572. /** @hidden */
  65573. static _ControllerFactories: _GamePadFactory[];
  65574. /** @hidden */
  65575. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  65576. /**
  65577. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  65578. * @param vrGamepad the gamepad to initialized
  65579. * @returns a vr controller of the type the gamepad identified as
  65580. */
  65581. static InitiateController(vrGamepad: any): Gamepad;
  65582. }
  65583. /**
  65584. * Defines the PoseEnabledController object that contains state of a vr capable controller
  65585. */
  65586. export class PoseEnabledController extends Gamepad implements PoseControlled {
  65587. private _deviceRoomPosition;
  65588. private _deviceRoomRotationQuaternion;
  65589. /**
  65590. * The device position in babylon space
  65591. */
  65592. devicePosition: Vector3;
  65593. /**
  65594. * The device rotation in babylon space
  65595. */
  65596. deviceRotationQuaternion: Quaternion;
  65597. /**
  65598. * The scale factor of the device in babylon space
  65599. */
  65600. deviceScaleFactor: number;
  65601. /**
  65602. * (Likely devicePosition should be used instead) The device position in its room space
  65603. */
  65604. position: Vector3;
  65605. /**
  65606. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  65607. */
  65608. rotationQuaternion: Quaternion;
  65609. /**
  65610. * The type of controller (Eg. Windows mixed reality)
  65611. */
  65612. controllerType: PoseEnabledControllerType;
  65613. protected _calculatedPosition: Vector3;
  65614. private _calculatedRotation;
  65615. /**
  65616. * The raw pose from the device
  65617. */
  65618. rawPose: DevicePose;
  65619. private _trackPosition;
  65620. private _maxRotationDistFromHeadset;
  65621. private _draggedRoomRotation;
  65622. /**
  65623. * @hidden
  65624. */
  65625. _disableTrackPosition(fixedPosition: Vector3): void;
  65626. /**
  65627. * Internal, the mesh attached to the controller
  65628. * @hidden
  65629. */
  65630. _mesh: Nullable<AbstractMesh>;
  65631. private _poseControlledCamera;
  65632. private _leftHandSystemQuaternion;
  65633. /**
  65634. * Internal, matrix used to convert room space to babylon space
  65635. * @hidden
  65636. */
  65637. _deviceToWorld: Matrix;
  65638. /**
  65639. * Node to be used when casting a ray from the controller
  65640. * @hidden
  65641. */
  65642. _pointingPoseNode: Nullable<TransformNode>;
  65643. /**
  65644. * Name of the child mesh that can be used to cast a ray from the controller
  65645. */
  65646. static readonly POINTING_POSE: string;
  65647. /**
  65648. * Creates a new PoseEnabledController from a gamepad
  65649. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  65650. */
  65651. constructor(browserGamepad: any);
  65652. private _workingMatrix;
  65653. /**
  65654. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  65655. */
  65656. update(): void;
  65657. /**
  65658. * Updates only the pose device and mesh without doing any button event checking
  65659. */
  65660. protected _updatePoseAndMesh(): void;
  65661. /**
  65662. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  65663. * @param poseData raw pose fromthe device
  65664. */
  65665. updateFromDevice(poseData: DevicePose): void;
  65666. /**
  65667. * @hidden
  65668. */
  65669. _meshAttachedObservable: Observable<AbstractMesh>;
  65670. /**
  65671. * Attaches a mesh to the controller
  65672. * @param mesh the mesh to be attached
  65673. */
  65674. attachToMesh(mesh: AbstractMesh): void;
  65675. /**
  65676. * Attaches the controllers mesh to a camera
  65677. * @param camera the camera the mesh should be attached to
  65678. */
  65679. attachToPoseControlledCamera(camera: TargetCamera): void;
  65680. /**
  65681. * Disposes of the controller
  65682. */
  65683. dispose(): void;
  65684. /**
  65685. * The mesh that is attached to the controller
  65686. */
  65687. readonly mesh: Nullable<AbstractMesh>;
  65688. /**
  65689. * Gets the ray of the controller in the direction the controller is pointing
  65690. * @param length the length the resulting ray should be
  65691. * @returns a ray in the direction the controller is pointing
  65692. */
  65693. getForwardRay(length?: number): Ray;
  65694. }
  65695. }
  65696. declare module BABYLON {
  65697. /**
  65698. * Defines the WebVRController object that represents controllers tracked in 3D space
  65699. */
  65700. export abstract class WebVRController extends PoseEnabledController {
  65701. /**
  65702. * Internal, the default controller model for the controller
  65703. */
  65704. protected _defaultModel: AbstractMesh;
  65705. /**
  65706. * Fired when the trigger state has changed
  65707. */
  65708. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  65709. /**
  65710. * Fired when the main button state has changed
  65711. */
  65712. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  65713. /**
  65714. * Fired when the secondary button state has changed
  65715. */
  65716. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  65717. /**
  65718. * Fired when the pad state has changed
  65719. */
  65720. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  65721. /**
  65722. * Fired when controllers stick values have changed
  65723. */
  65724. onPadValuesChangedObservable: Observable<StickValues>;
  65725. /**
  65726. * Array of button availible on the controller
  65727. */
  65728. protected _buttons: Array<MutableGamepadButton>;
  65729. private _onButtonStateChange;
  65730. /**
  65731. * Fired when a controller button's state has changed
  65732. * @param callback the callback containing the button that was modified
  65733. */
  65734. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  65735. /**
  65736. * X and Y axis corrisponding to the controllers joystick
  65737. */
  65738. pad: StickValues;
  65739. /**
  65740. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  65741. */
  65742. hand: string;
  65743. /**
  65744. * The default controller model for the controller
  65745. */
  65746. readonly defaultModel: AbstractMesh;
  65747. /**
  65748. * Creates a new WebVRController from a gamepad
  65749. * @param vrGamepad the gamepad that the WebVRController should be created from
  65750. */
  65751. constructor(vrGamepad: any);
  65752. /**
  65753. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  65754. */
  65755. update(): void;
  65756. /**
  65757. * Function to be called when a button is modified
  65758. */
  65759. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  65760. /**
  65761. * Loads a mesh and attaches it to the controller
  65762. * @param scene the scene the mesh should be added to
  65763. * @param meshLoaded callback for when the mesh has been loaded
  65764. */
  65765. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  65766. private _setButtonValue;
  65767. private _changes;
  65768. private _checkChanges;
  65769. /**
  65770. * Disposes of th webVRCOntroller
  65771. */
  65772. dispose(): void;
  65773. }
  65774. }
  65775. declare module BABYLON {
  65776. /**
  65777. * Interface describing all the common properties and methods a shadow light needs to implement.
  65778. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  65779. * as well as binding the different shadow properties to the effects.
  65780. */
  65781. export interface IShadowLight extends Light {
  65782. /**
  65783. * The light id in the scene (used in scene.findLighById for instance)
  65784. */
  65785. id: string;
  65786. /**
  65787. * The position the shdow will be casted from.
  65788. */
  65789. position: Vector3;
  65790. /**
  65791. * In 2d mode (needCube being false), the direction used to cast the shadow.
  65792. */
  65793. direction: Vector3;
  65794. /**
  65795. * The transformed position. Position of the light in world space taking parenting in account.
  65796. */
  65797. transformedPosition: Vector3;
  65798. /**
  65799. * The transformed direction. Direction of the light in world space taking parenting in account.
  65800. */
  65801. transformedDirection: Vector3;
  65802. /**
  65803. * The friendly name of the light in the scene.
  65804. */
  65805. name: string;
  65806. /**
  65807. * Defines the shadow projection clipping minimum z value.
  65808. */
  65809. shadowMinZ: number;
  65810. /**
  65811. * Defines the shadow projection clipping maximum z value.
  65812. */
  65813. shadowMaxZ: number;
  65814. /**
  65815. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65816. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65817. */
  65818. computeTransformedInformation(): boolean;
  65819. /**
  65820. * Gets the scene the light belongs to.
  65821. * @returns The scene
  65822. */
  65823. getScene(): Scene;
  65824. /**
  65825. * Callback defining a custom Projection Matrix Builder.
  65826. * This can be used to override the default projection matrix computation.
  65827. */
  65828. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65829. /**
  65830. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  65831. * @param matrix The materix to updated with the projection information
  65832. * @param viewMatrix The transform matrix of the light
  65833. * @param renderList The list of mesh to render in the map
  65834. * @returns The current light
  65835. */
  65836. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  65837. /**
  65838. * Gets the current depth scale used in ESM.
  65839. * @returns The scale
  65840. */
  65841. getDepthScale(): number;
  65842. /**
  65843. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65844. * @returns true if a cube texture needs to be use
  65845. */
  65846. needCube(): boolean;
  65847. /**
  65848. * Detects if the projection matrix requires to be recomputed this frame.
  65849. * @returns true if it requires to be recomputed otherwise, false.
  65850. */
  65851. needProjectionMatrixCompute(): boolean;
  65852. /**
  65853. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65854. */
  65855. forceProjectionMatrixCompute(): void;
  65856. /**
  65857. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65858. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65859. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65860. */
  65861. getShadowDirection(faceIndex?: number): Vector3;
  65862. /**
  65863. * Gets the minZ used for shadow according to both the scene and the light.
  65864. * @param activeCamera The camera we are returning the min for
  65865. * @returns the depth min z
  65866. */
  65867. getDepthMinZ(activeCamera: Camera): number;
  65868. /**
  65869. * Gets the maxZ used for shadow according to both the scene and the light.
  65870. * @param activeCamera The camera we are returning the max for
  65871. * @returns the depth max z
  65872. */
  65873. getDepthMaxZ(activeCamera: Camera): number;
  65874. }
  65875. /**
  65876. * Base implementation IShadowLight
  65877. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  65878. */
  65879. export abstract class ShadowLight extends Light implements IShadowLight {
  65880. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  65881. protected _position: Vector3;
  65882. protected _setPosition(value: Vector3): void;
  65883. /**
  65884. * Sets the position the shadow will be casted from. Also use as the light position for both
  65885. * point and spot lights.
  65886. */
  65887. /**
  65888. * Sets the position the shadow will be casted from. Also use as the light position for both
  65889. * point and spot lights.
  65890. */
  65891. position: Vector3;
  65892. protected _direction: Vector3;
  65893. protected _setDirection(value: Vector3): void;
  65894. /**
  65895. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  65896. * Also use as the light direction on spot and directional lights.
  65897. */
  65898. /**
  65899. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  65900. * Also use as the light direction on spot and directional lights.
  65901. */
  65902. direction: Vector3;
  65903. private _shadowMinZ;
  65904. /**
  65905. * Gets the shadow projection clipping minimum z value.
  65906. */
  65907. /**
  65908. * Sets the shadow projection clipping minimum z value.
  65909. */
  65910. shadowMinZ: number;
  65911. private _shadowMaxZ;
  65912. /**
  65913. * Sets the shadow projection clipping maximum z value.
  65914. */
  65915. /**
  65916. * Gets the shadow projection clipping maximum z value.
  65917. */
  65918. shadowMaxZ: number;
  65919. /**
  65920. * Callback defining a custom Projection Matrix Builder.
  65921. * This can be used to override the default projection matrix computation.
  65922. */
  65923. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  65924. /**
  65925. * The transformed position. Position of the light in world space taking parenting in account.
  65926. */
  65927. transformedPosition: Vector3;
  65928. /**
  65929. * The transformed direction. Direction of the light in world space taking parenting in account.
  65930. */
  65931. transformedDirection: Vector3;
  65932. private _needProjectionMatrixCompute;
  65933. /**
  65934. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  65935. * @returns true if the information has been computed, false if it does not need to (no parenting)
  65936. */
  65937. computeTransformedInformation(): boolean;
  65938. /**
  65939. * Return the depth scale used for the shadow map.
  65940. * @returns the depth scale.
  65941. */
  65942. getDepthScale(): number;
  65943. /**
  65944. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  65945. * @param faceIndex The index of the face we are computed the direction to generate shadow
  65946. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  65947. */
  65948. getShadowDirection(faceIndex?: number): Vector3;
  65949. /**
  65950. * Returns the ShadowLight absolute position in the World.
  65951. * @returns the position vector in world space
  65952. */
  65953. getAbsolutePosition(): Vector3;
  65954. /**
  65955. * Sets the ShadowLight direction toward the passed target.
  65956. * @param target The point tot target in local space
  65957. * @returns the updated ShadowLight direction
  65958. */
  65959. setDirectionToTarget(target: Vector3): Vector3;
  65960. /**
  65961. * Returns the light rotation in euler definition.
  65962. * @returns the x y z rotation in local space.
  65963. */
  65964. getRotation(): Vector3;
  65965. /**
  65966. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  65967. * @returns true if a cube texture needs to be use
  65968. */
  65969. needCube(): boolean;
  65970. /**
  65971. * Detects if the projection matrix requires to be recomputed this frame.
  65972. * @returns true if it requires to be recomputed otherwise, false.
  65973. */
  65974. needProjectionMatrixCompute(): boolean;
  65975. /**
  65976. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  65977. */
  65978. forceProjectionMatrixCompute(): void;
  65979. /** @hidden */
  65980. _initCache(): void;
  65981. /** @hidden */
  65982. _isSynchronized(): boolean;
  65983. /**
  65984. * Computes the world matrix of the node
  65985. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  65986. * @returns the world matrix
  65987. */
  65988. computeWorldMatrix(force?: boolean): Matrix;
  65989. /**
  65990. * Gets the minZ used for shadow according to both the scene and the light.
  65991. * @param activeCamera The camera we are returning the min for
  65992. * @returns the depth min z
  65993. */
  65994. getDepthMinZ(activeCamera: Camera): number;
  65995. /**
  65996. * Gets the maxZ used for shadow according to both the scene and the light.
  65997. * @param activeCamera The camera we are returning the max for
  65998. * @returns the depth max z
  65999. */
  66000. getDepthMaxZ(activeCamera: Camera): number;
  66001. /**
  66002. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  66003. * @param matrix The materix to updated with the projection information
  66004. * @param viewMatrix The transform matrix of the light
  66005. * @param renderList The list of mesh to render in the map
  66006. * @returns The current light
  66007. */
  66008. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  66009. }
  66010. }
  66011. declare module BABYLON {
  66012. /**
  66013. * "Static Class" containing the most commonly used helper while dealing with material for
  66014. * rendering purpose.
  66015. *
  66016. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  66017. *
  66018. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  66019. */
  66020. export class MaterialHelper {
  66021. /**
  66022. * Bind the current view position to an effect.
  66023. * @param effect The effect to be bound
  66024. * @param scene The scene the eyes position is used from
  66025. */
  66026. static BindEyePosition(effect: Effect, scene: Scene): void;
  66027. /**
  66028. * Helps preparing the defines values about the UVs in used in the effect.
  66029. * UVs are shared as much as we can accross channels in the shaders.
  66030. * @param texture The texture we are preparing the UVs for
  66031. * @param defines The defines to update
  66032. * @param key The channel key "diffuse", "specular"... used in the shader
  66033. */
  66034. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  66035. /**
  66036. * Binds a texture matrix value to its corrsponding uniform
  66037. * @param texture The texture to bind the matrix for
  66038. * @param uniformBuffer The uniform buffer receivin the data
  66039. * @param key The channel key "diffuse", "specular"... used in the shader
  66040. */
  66041. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  66042. /**
  66043. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  66044. * @param mesh defines the current mesh
  66045. * @param scene defines the current scene
  66046. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  66047. * @param pointsCloud defines if point cloud rendering has to be turned on
  66048. * @param fogEnabled defines if fog has to be turned on
  66049. * @param alphaTest defines if alpha testing has to be turned on
  66050. * @param defines defines the current list of defines
  66051. */
  66052. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  66053. /**
  66054. * Helper used to prepare the list of defines associated with frame values for shader compilation
  66055. * @param scene defines the current scene
  66056. * @param engine defines the current engine
  66057. * @param defines specifies the list of active defines
  66058. * @param useInstances defines if instances have to be turned on
  66059. * @param useClipPlane defines if clip plane have to be turned on
  66060. */
  66061. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  66062. /**
  66063. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  66064. * @param mesh The mesh containing the geometry data we will draw
  66065. * @param defines The defines to update
  66066. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  66067. * @param useBones Precise whether bones should be used or not (override mesh info)
  66068. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  66069. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  66070. * @returns false if defines are considered not dirty and have not been checked
  66071. */
  66072. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  66073. /**
  66074. * Prepares the defines related to the light information passed in parameter
  66075. * @param scene The scene we are intending to draw
  66076. * @param mesh The mesh the effect is compiling for
  66077. * @param defines The defines to update
  66078. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  66079. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  66080. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  66081. * @returns true if normals will be required for the rest of the effect
  66082. */
  66083. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  66084. /**
  66085. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  66086. * that won t be acctive due to defines being turned off.
  66087. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  66088. * @param samplersList The samplers list
  66089. * @param defines The defines helping in the list generation
  66090. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  66091. */
  66092. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  66093. /**
  66094. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  66095. * @param defines The defines to update while falling back
  66096. * @param fallbacks The authorized effect fallbacks
  66097. * @param maxSimultaneousLights The maximum number of lights allowed
  66098. * @param rank the current rank of the Effect
  66099. * @returns The newly affected rank
  66100. */
  66101. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  66102. /**
  66103. * Prepares the list of attributes required for morph targets according to the effect defines.
  66104. * @param attribs The current list of supported attribs
  66105. * @param mesh The mesh to prepare the morph targets attributes for
  66106. * @param defines The current Defines of the effect
  66107. */
  66108. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  66109. /**
  66110. * Prepares the list of attributes required for bones according to the effect defines.
  66111. * @param attribs The current list of supported attribs
  66112. * @param mesh The mesh to prepare the bones attributes for
  66113. * @param defines The current Defines of the effect
  66114. * @param fallbacks The current efffect fallback strategy
  66115. */
  66116. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  66117. /**
  66118. * Prepares the list of attributes required for instances according to the effect defines.
  66119. * @param attribs The current list of supported attribs
  66120. * @param defines The current Defines of the effect
  66121. */
  66122. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  66123. /**
  66124. * Binds the light shadow information to the effect for the given mesh.
  66125. * @param light The light containing the generator
  66126. * @param scene The scene the lights belongs to
  66127. * @param mesh The mesh we are binding the information to render
  66128. * @param lightIndex The light index in the effect used to render the mesh
  66129. * @param effect The effect we are binding the data to
  66130. */
  66131. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  66132. /**
  66133. * Binds the light information to the effect.
  66134. * @param light The light containing the generator
  66135. * @param effect The effect we are binding the data to
  66136. * @param lightIndex The light index in the effect used to render
  66137. */
  66138. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  66139. /**
  66140. * Binds the lights information from the scene to the effect for the given mesh.
  66141. * @param scene The scene the lights belongs to
  66142. * @param mesh The mesh we are binding the information to render
  66143. * @param effect The effect we are binding the data to
  66144. * @param defines The generated defines for the effect
  66145. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  66146. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  66147. */
  66148. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  66149. private static _tempFogColor;
  66150. /**
  66151. * Binds the fog information from the scene to the effect for the given mesh.
  66152. * @param scene The scene the lights belongs to
  66153. * @param mesh The mesh we are binding the information to render
  66154. * @param effect The effect we are binding the data to
  66155. * @param linearSpace Defines if the fog effect is applied in linear space
  66156. */
  66157. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  66158. /**
  66159. * Binds the bones information from the mesh to the effect.
  66160. * @param mesh The mesh we are binding the information to render
  66161. * @param effect The effect we are binding the data to
  66162. */
  66163. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  66164. /**
  66165. * Binds the morph targets information from the mesh to the effect.
  66166. * @param abstractMesh The mesh we are binding the information to render
  66167. * @param effect The effect we are binding the data to
  66168. */
  66169. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  66170. /**
  66171. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  66172. * @param defines The generated defines used in the effect
  66173. * @param effect The effect we are binding the data to
  66174. * @param scene The scene we are willing to render with logarithmic scale for
  66175. */
  66176. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  66177. /**
  66178. * Binds the clip plane information from the scene to the effect.
  66179. * @param scene The scene the clip plane information are extracted from
  66180. * @param effect The effect we are binding the data to
  66181. */
  66182. static BindClipPlane(effect: Effect, scene: Scene): void;
  66183. }
  66184. }
  66185. declare module BABYLON {
  66186. /** @hidden */
  66187. export var shadowMapPixelShader: {
  66188. name: string;
  66189. shader: string;
  66190. };
  66191. }
  66192. declare module BABYLON {
  66193. /** @hidden */
  66194. export var bonesDeclaration: {
  66195. name: string;
  66196. shader: string;
  66197. };
  66198. }
  66199. declare module BABYLON {
  66200. /** @hidden */
  66201. export var morphTargetsVertexGlobalDeclaration: {
  66202. name: string;
  66203. shader: string;
  66204. };
  66205. }
  66206. declare module BABYLON {
  66207. /** @hidden */
  66208. export var morphTargetsVertexDeclaration: {
  66209. name: string;
  66210. shader: string;
  66211. };
  66212. }
  66213. declare module BABYLON {
  66214. /** @hidden */
  66215. export var instancesDeclaration: {
  66216. name: string;
  66217. shader: string;
  66218. };
  66219. }
  66220. declare module BABYLON {
  66221. /** @hidden */
  66222. export var helperFunctions: {
  66223. name: string;
  66224. shader: string;
  66225. };
  66226. }
  66227. declare module BABYLON {
  66228. /** @hidden */
  66229. export var morphTargetsVertex: {
  66230. name: string;
  66231. shader: string;
  66232. };
  66233. }
  66234. declare module BABYLON {
  66235. /** @hidden */
  66236. export var instancesVertex: {
  66237. name: string;
  66238. shader: string;
  66239. };
  66240. }
  66241. declare module BABYLON {
  66242. /** @hidden */
  66243. export var bonesVertex: {
  66244. name: string;
  66245. shader: string;
  66246. };
  66247. }
  66248. declare module BABYLON {
  66249. /** @hidden */
  66250. export var shadowMapVertexShader: {
  66251. name: string;
  66252. shader: string;
  66253. };
  66254. }
  66255. declare module BABYLON {
  66256. /** @hidden */
  66257. export var depthBoxBlurPixelShader: {
  66258. name: string;
  66259. shader: string;
  66260. };
  66261. }
  66262. declare module BABYLON {
  66263. /**
  66264. * Defines the options associated with the creation of a custom shader for a shadow generator.
  66265. */
  66266. export interface ICustomShaderOptions {
  66267. /**
  66268. * Gets or sets the custom shader name to use
  66269. */
  66270. shaderName: string;
  66271. /**
  66272. * The list of attribute names used in the shader
  66273. */
  66274. attributes?: string[];
  66275. /**
  66276. * The list of unifrom names used in the shader
  66277. */
  66278. uniforms?: string[];
  66279. /**
  66280. * The list of sampler names used in the shader
  66281. */
  66282. samplers?: string[];
  66283. /**
  66284. * The list of defines used in the shader
  66285. */
  66286. defines?: string[];
  66287. }
  66288. /**
  66289. * Interface to implement to create a shadow generator compatible with BJS.
  66290. */
  66291. export interface IShadowGenerator {
  66292. /**
  66293. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66294. * @returns The render target texture if present otherwise, null
  66295. */
  66296. getShadowMap(): Nullable<RenderTargetTexture>;
  66297. /**
  66298. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66299. * @returns The render target texture if the shadow map is present otherwise, null
  66300. */
  66301. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66302. /**
  66303. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66304. * @param subMesh The submesh we want to render in the shadow map
  66305. * @param useInstances Defines wether will draw in the map using instances
  66306. * @returns true if ready otherwise, false
  66307. */
  66308. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66309. /**
  66310. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66311. * @param defines Defines of the material we want to update
  66312. * @param lightIndex Index of the light in the enabled light list of the material
  66313. */
  66314. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  66315. /**
  66316. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66317. * defined in the generator but impacting the effect).
  66318. * It implies the unifroms available on the materials are the standard BJS ones.
  66319. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66320. * @param effect The effect we are binfing the information for
  66321. */
  66322. bindShadowLight(lightIndex: string, effect: Effect): void;
  66323. /**
  66324. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66325. * (eq to shadow prjection matrix * light transform matrix)
  66326. * @returns The transform matrix used to create the shadow map
  66327. */
  66328. getTransformMatrix(): Matrix;
  66329. /**
  66330. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66331. * Cube and 2D textures for instance.
  66332. */
  66333. recreateShadowMap(): void;
  66334. /**
  66335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66336. * @param onCompiled Callback triggered at the and of the effects compilation
  66337. * @param options Sets of optional options forcing the compilation with different modes
  66338. */
  66339. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66340. useInstances: boolean;
  66341. }>): void;
  66342. /**
  66343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66344. * @param options Sets of optional options forcing the compilation with different modes
  66345. * @returns A promise that resolves when the compilation completes
  66346. */
  66347. forceCompilationAsync(options?: Partial<{
  66348. useInstances: boolean;
  66349. }>): Promise<void>;
  66350. /**
  66351. * Serializes the shadow generator setup to a json object.
  66352. * @returns The serialized JSON object
  66353. */
  66354. serialize(): any;
  66355. /**
  66356. * Disposes the Shadow map and related Textures and effects.
  66357. */
  66358. dispose(): void;
  66359. }
  66360. /**
  66361. * Default implementation IShadowGenerator.
  66362. * This is the main object responsible of generating shadows in the framework.
  66363. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  66364. */
  66365. export class ShadowGenerator implements IShadowGenerator {
  66366. /**
  66367. * Shadow generator mode None: no filtering applied.
  66368. */
  66369. static readonly FILTER_NONE: number;
  66370. /**
  66371. * Shadow generator mode ESM: Exponential Shadow Mapping.
  66372. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66373. */
  66374. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  66375. /**
  66376. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  66377. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  66378. */
  66379. static readonly FILTER_POISSONSAMPLING: number;
  66380. /**
  66381. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  66382. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66383. */
  66384. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  66385. /**
  66386. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  66387. * edge artifacts on steep falloff.
  66388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66389. */
  66390. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  66391. /**
  66392. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  66393. * edge artifacts on steep falloff.
  66394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  66395. */
  66396. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  66397. /**
  66398. * Shadow generator mode PCF: Percentage Closer Filtering
  66399. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66400. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  66401. */
  66402. static readonly FILTER_PCF: number;
  66403. /**
  66404. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  66405. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  66406. * Contact Hardening
  66407. */
  66408. static readonly FILTER_PCSS: number;
  66409. /**
  66410. * Reserved for PCF and PCSS
  66411. * Highest Quality.
  66412. *
  66413. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  66414. *
  66415. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  66416. */
  66417. static readonly QUALITY_HIGH: number;
  66418. /**
  66419. * Reserved for PCF and PCSS
  66420. * Good tradeoff for quality/perf cross devices
  66421. *
  66422. * Execute PCF on a 3*3 kernel.
  66423. *
  66424. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  66425. */
  66426. static readonly QUALITY_MEDIUM: number;
  66427. /**
  66428. * Reserved for PCF and PCSS
  66429. * The lowest quality but the fastest.
  66430. *
  66431. * Execute PCF on a 1*1 kernel.
  66432. *
  66433. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  66434. */
  66435. static readonly QUALITY_LOW: number;
  66436. /** Gets or sets the custom shader name to use */
  66437. customShaderOptions: ICustomShaderOptions;
  66438. /**
  66439. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  66440. */
  66441. onBeforeShadowMapRenderObservable: Observable<Effect>;
  66442. private _bias;
  66443. /**
  66444. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  66445. */
  66446. /**
  66447. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  66448. */
  66449. bias: number;
  66450. private _normalBias;
  66451. /**
  66452. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66453. */
  66454. /**
  66455. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  66456. */
  66457. normalBias: number;
  66458. private _blurBoxOffset;
  66459. /**
  66460. * Gets the blur box offset: offset applied during the blur pass.
  66461. * Only useful if useKernelBlur = false
  66462. */
  66463. /**
  66464. * Sets the blur box offset: offset applied during the blur pass.
  66465. * Only useful if useKernelBlur = false
  66466. */
  66467. blurBoxOffset: number;
  66468. private _blurScale;
  66469. /**
  66470. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  66471. * 2 means half of the size.
  66472. */
  66473. /**
  66474. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  66475. * 2 means half of the size.
  66476. */
  66477. blurScale: number;
  66478. private _blurKernel;
  66479. /**
  66480. * Gets the blur kernel: kernel size of the blur pass.
  66481. * Only useful if useKernelBlur = true
  66482. */
  66483. /**
  66484. * Sets the blur kernel: kernel size of the blur pass.
  66485. * Only useful if useKernelBlur = true
  66486. */
  66487. blurKernel: number;
  66488. private _useKernelBlur;
  66489. /**
  66490. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  66491. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66492. */
  66493. /**
  66494. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  66495. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  66496. */
  66497. useKernelBlur: boolean;
  66498. private _depthScale;
  66499. /**
  66500. * Gets the depth scale used in ESM mode.
  66501. */
  66502. /**
  66503. * Sets the depth scale used in ESM mode.
  66504. * This can override the scale stored on the light.
  66505. */
  66506. depthScale: number;
  66507. private _filter;
  66508. /**
  66509. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  66510. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66511. */
  66512. /**
  66513. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  66514. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  66515. */
  66516. filter: number;
  66517. /**
  66518. * Gets if the current filter is set to Poisson Sampling.
  66519. */
  66520. /**
  66521. * Sets the current filter to Poisson Sampling.
  66522. */
  66523. usePoissonSampling: boolean;
  66524. /**
  66525. * Gets if the current filter is set to ESM.
  66526. */
  66527. /**
  66528. * Sets the current filter is to ESM.
  66529. */
  66530. useExponentialShadowMap: boolean;
  66531. /**
  66532. * Gets if the current filter is set to filtered ESM.
  66533. */
  66534. /**
  66535. * Gets if the current filter is set to filtered ESM.
  66536. */
  66537. useBlurExponentialShadowMap: boolean;
  66538. /**
  66539. * Gets if the current filter is set to "close ESM" (using the inverse of the
  66540. * exponential to prevent steep falloff artifacts).
  66541. */
  66542. /**
  66543. * Sets the current filter to "close ESM" (using the inverse of the
  66544. * exponential to prevent steep falloff artifacts).
  66545. */
  66546. useCloseExponentialShadowMap: boolean;
  66547. /**
  66548. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  66549. * exponential to prevent steep falloff artifacts).
  66550. */
  66551. /**
  66552. * Sets the current filter to filtered "close ESM" (using the inverse of the
  66553. * exponential to prevent steep falloff artifacts).
  66554. */
  66555. useBlurCloseExponentialShadowMap: boolean;
  66556. /**
  66557. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  66558. */
  66559. /**
  66560. * Sets the current filter to "PCF" (percentage closer filtering).
  66561. */
  66562. usePercentageCloserFiltering: boolean;
  66563. private _filteringQuality;
  66564. /**
  66565. * Gets the PCF or PCSS Quality.
  66566. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66567. */
  66568. /**
  66569. * Sets the PCF or PCSS Quality.
  66570. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  66571. */
  66572. filteringQuality: number;
  66573. /**
  66574. * Gets if the current filter is set to "PCSS" (contact hardening).
  66575. */
  66576. /**
  66577. * Sets the current filter to "PCSS" (contact hardening).
  66578. */
  66579. useContactHardeningShadow: boolean;
  66580. private _contactHardeningLightSizeUVRatio;
  66581. /**
  66582. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66583. * Using a ratio helps keeping shape stability independently of the map size.
  66584. *
  66585. * It does not account for the light projection as it was having too much
  66586. * instability during the light setup or during light position changes.
  66587. *
  66588. * Only valid if useContactHardeningShadow is true.
  66589. */
  66590. /**
  66591. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  66592. * Using a ratio helps keeping shape stability independently of the map size.
  66593. *
  66594. * It does not account for the light projection as it was having too much
  66595. * instability during the light setup or during light position changes.
  66596. *
  66597. * Only valid if useContactHardeningShadow is true.
  66598. */
  66599. contactHardeningLightSizeUVRatio: number;
  66600. private _darkness;
  66601. /**
  66602. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  66603. * 0 means strongest and 1 would means no shadow.
  66604. * @returns the darkness.
  66605. */
  66606. getDarkness(): number;
  66607. /**
  66608. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  66609. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  66610. * @returns the shadow generator allowing fluent coding.
  66611. */
  66612. setDarkness(darkness: number): ShadowGenerator;
  66613. private _transparencyShadow;
  66614. /**
  66615. * Sets the ability to have transparent shadow (boolean).
  66616. * @param transparent True if transparent else False
  66617. * @returns the shadow generator allowing fluent coding
  66618. */
  66619. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  66620. private _shadowMap;
  66621. private _shadowMap2;
  66622. /**
  66623. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  66624. * @returns The render target texture if present otherwise, null
  66625. */
  66626. getShadowMap(): Nullable<RenderTargetTexture>;
  66627. /**
  66628. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  66629. * @returns The render target texture if the shadow map is present otherwise, null
  66630. */
  66631. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  66632. /**
  66633. * Helper function to add a mesh and its descendants to the list of shadow casters.
  66634. * @param mesh Mesh to add
  66635. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  66636. * @returns the Shadow Generator itself
  66637. */
  66638. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66639. /**
  66640. * Helper function to remove a mesh and its descendants from the list of shadow casters
  66641. * @param mesh Mesh to remove
  66642. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  66643. * @returns the Shadow Generator itself
  66644. */
  66645. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  66646. /**
  66647. * Controls the extent to which the shadows fade out at the edge of the frustum
  66648. * Used only by directionals and spots
  66649. */
  66650. frustumEdgeFalloff: number;
  66651. private _light;
  66652. /**
  66653. * Returns the associated light object.
  66654. * @returns the light generating the shadow
  66655. */
  66656. getLight(): IShadowLight;
  66657. /**
  66658. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  66659. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  66660. * It might on the other hand introduce peter panning.
  66661. */
  66662. forceBackFacesOnly: boolean;
  66663. private _scene;
  66664. private _lightDirection;
  66665. private _effect;
  66666. private _viewMatrix;
  66667. private _projectionMatrix;
  66668. private _transformMatrix;
  66669. private _cachedPosition;
  66670. private _cachedDirection;
  66671. private _cachedDefines;
  66672. private _currentRenderID;
  66673. private _boxBlurPostprocess;
  66674. private _kernelBlurXPostprocess;
  66675. private _kernelBlurYPostprocess;
  66676. private _blurPostProcesses;
  66677. private _mapSize;
  66678. private _currentFaceIndex;
  66679. private _currentFaceIndexCache;
  66680. private _textureType;
  66681. private _defaultTextureMatrix;
  66682. /** @hidden */
  66683. static _SceneComponentInitialization: (scene: Scene) => void;
  66684. /**
  66685. * Creates a ShadowGenerator object.
  66686. * A ShadowGenerator is the required tool to use the shadows.
  66687. * Each light casting shadows needs to use its own ShadowGenerator.
  66688. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  66689. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  66690. * @param light The light object generating the shadows.
  66691. * @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.
  66692. */
  66693. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  66694. private _initializeGenerator;
  66695. private _initializeShadowMap;
  66696. private _initializeBlurRTTAndPostProcesses;
  66697. private _renderForShadowMap;
  66698. private _renderSubMeshForShadowMap;
  66699. private _applyFilterValues;
  66700. /**
  66701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66702. * @param onCompiled Callback triggered at the and of the effects compilation
  66703. * @param options Sets of optional options forcing the compilation with different modes
  66704. */
  66705. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  66706. useInstances: boolean;
  66707. }>): void;
  66708. /**
  66709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  66710. * @param options Sets of optional options forcing the compilation with different modes
  66711. * @returns A promise that resolves when the compilation completes
  66712. */
  66713. forceCompilationAsync(options?: Partial<{
  66714. useInstances: boolean;
  66715. }>): Promise<void>;
  66716. /**
  66717. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  66718. * @param subMesh The submesh we want to render in the shadow map
  66719. * @param useInstances Defines wether will draw in the map using instances
  66720. * @returns true if ready otherwise, false
  66721. */
  66722. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66723. /**
  66724. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  66725. * @param defines Defines of the material we want to update
  66726. * @param lightIndex Index of the light in the enabled light list of the material
  66727. */
  66728. prepareDefines(defines: any, lightIndex: number): void;
  66729. /**
  66730. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  66731. * defined in the generator but impacting the effect).
  66732. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  66733. * @param effect The effect we are binfing the information for
  66734. */
  66735. bindShadowLight(lightIndex: string, effect: Effect): void;
  66736. /**
  66737. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  66738. * (eq to shadow prjection matrix * light transform matrix)
  66739. * @returns The transform matrix used to create the shadow map
  66740. */
  66741. getTransformMatrix(): Matrix;
  66742. /**
  66743. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  66744. * Cube and 2D textures for instance.
  66745. */
  66746. recreateShadowMap(): void;
  66747. private _disposeBlurPostProcesses;
  66748. private _disposeRTTandPostProcesses;
  66749. /**
  66750. * Disposes the ShadowGenerator.
  66751. * Returns nothing.
  66752. */
  66753. dispose(): void;
  66754. /**
  66755. * Serializes the shadow generator setup to a json object.
  66756. * @returns The serialized JSON object
  66757. */
  66758. serialize(): any;
  66759. /**
  66760. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  66761. * @param parsedShadowGenerator The JSON object to parse
  66762. * @param scene The scene to create the shadow map for
  66763. * @returns The parsed shadow generator
  66764. */
  66765. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  66766. }
  66767. }
  66768. declare module BABYLON {
  66769. /**
  66770. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  66771. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  66772. * 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.
  66773. */
  66774. export abstract class Light extends Node {
  66775. /**
  66776. * Falloff Default: light is falling off following the material specification:
  66777. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  66778. */
  66779. static readonly FALLOFF_DEFAULT: number;
  66780. /**
  66781. * Falloff Physical: light is falling off following the inverse squared distance law.
  66782. */
  66783. static readonly FALLOFF_PHYSICAL: number;
  66784. /**
  66785. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  66786. * to enhance interoperability with other engines.
  66787. */
  66788. static readonly FALLOFF_GLTF: number;
  66789. /**
  66790. * Falloff Standard: light is falling off like in the standard material
  66791. * to enhance interoperability with other materials.
  66792. */
  66793. static readonly FALLOFF_STANDARD: number;
  66794. /**
  66795. * If every light affecting the material is in this lightmapMode,
  66796. * material.lightmapTexture adds or multiplies
  66797. * (depends on material.useLightmapAsShadowmap)
  66798. * after every other light calculations.
  66799. */
  66800. static readonly LIGHTMAP_DEFAULT: number;
  66801. /**
  66802. * material.lightmapTexture as only diffuse lighting from this light
  66803. * adds only specular lighting from this light
  66804. * adds dynamic shadows
  66805. */
  66806. static readonly LIGHTMAP_SPECULAR: number;
  66807. /**
  66808. * material.lightmapTexture as only lighting
  66809. * no light calculation from this light
  66810. * only adds dynamic shadows from this light
  66811. */
  66812. static readonly LIGHTMAP_SHADOWSONLY: number;
  66813. /**
  66814. * Each light type uses the default quantity according to its type:
  66815. * point/spot lights use luminous intensity
  66816. * directional lights use illuminance
  66817. */
  66818. static readonly INTENSITYMODE_AUTOMATIC: number;
  66819. /**
  66820. * lumen (lm)
  66821. */
  66822. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  66823. /**
  66824. * candela (lm/sr)
  66825. */
  66826. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  66827. /**
  66828. * lux (lm/m^2)
  66829. */
  66830. static readonly INTENSITYMODE_ILLUMINANCE: number;
  66831. /**
  66832. * nit (cd/m^2)
  66833. */
  66834. static readonly INTENSITYMODE_LUMINANCE: number;
  66835. /**
  66836. * Light type const id of the point light.
  66837. */
  66838. static readonly LIGHTTYPEID_POINTLIGHT: number;
  66839. /**
  66840. * Light type const id of the directional light.
  66841. */
  66842. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  66843. /**
  66844. * Light type const id of the spot light.
  66845. */
  66846. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  66847. /**
  66848. * Light type const id of the hemispheric light.
  66849. */
  66850. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  66851. /**
  66852. * Diffuse gives the basic color to an object.
  66853. */
  66854. diffuse: Color3;
  66855. /**
  66856. * Specular produces a highlight color on an object.
  66857. * Note: This is note affecting PBR materials.
  66858. */
  66859. specular: Color3;
  66860. /**
  66861. * Defines the falloff type for this light. This lets overrriding how punctual light are
  66862. * falling off base on range or angle.
  66863. * This can be set to any values in Light.FALLOFF_x.
  66864. *
  66865. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  66866. * other types of materials.
  66867. */
  66868. falloffType: number;
  66869. /**
  66870. * Strength of the light.
  66871. * Note: By default it is define in the framework own unit.
  66872. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  66873. */
  66874. intensity: number;
  66875. private _range;
  66876. protected _inverseSquaredRange: number;
  66877. /**
  66878. * Defines how far from the source the light is impacting in scene units.
  66879. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66880. */
  66881. /**
  66882. * Defines how far from the source the light is impacting in scene units.
  66883. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  66884. */
  66885. range: number;
  66886. /**
  66887. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  66888. * of light.
  66889. */
  66890. private _photometricScale;
  66891. private _intensityMode;
  66892. /**
  66893. * Gets the photometric scale used to interpret the intensity.
  66894. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66895. */
  66896. /**
  66897. * Sets the photometric scale used to interpret the intensity.
  66898. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  66899. */
  66900. intensityMode: number;
  66901. private _radius;
  66902. /**
  66903. * Gets the light radius used by PBR Materials to simulate soft area lights.
  66904. */
  66905. /**
  66906. * sets the light radius used by PBR Materials to simulate soft area lights.
  66907. */
  66908. radius: number;
  66909. private _renderPriority;
  66910. /**
  66911. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  66912. * exceeding the number allowed of the materials.
  66913. */
  66914. renderPriority: number;
  66915. private _shadowEnabled;
  66916. /**
  66917. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66918. * the current shadow generator.
  66919. */
  66920. /**
  66921. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  66922. * the current shadow generator.
  66923. */
  66924. shadowEnabled: boolean;
  66925. private _includedOnlyMeshes;
  66926. /**
  66927. * Gets the only meshes impacted by this light.
  66928. */
  66929. /**
  66930. * Sets the only meshes impacted by this light.
  66931. */
  66932. includedOnlyMeshes: AbstractMesh[];
  66933. private _excludedMeshes;
  66934. /**
  66935. * Gets the meshes not impacted by this light.
  66936. */
  66937. /**
  66938. * Sets the meshes not impacted by this light.
  66939. */
  66940. excludedMeshes: AbstractMesh[];
  66941. private _excludeWithLayerMask;
  66942. /**
  66943. * Gets the layer id use to find what meshes are not impacted by the light.
  66944. * Inactive if 0
  66945. */
  66946. /**
  66947. * Sets the layer id use to find what meshes are not impacted by the light.
  66948. * Inactive if 0
  66949. */
  66950. excludeWithLayerMask: number;
  66951. private _includeOnlyWithLayerMask;
  66952. /**
  66953. * Gets the layer id use to find what meshes are impacted by the light.
  66954. * Inactive if 0
  66955. */
  66956. /**
  66957. * Sets the layer id use to find what meshes are impacted by the light.
  66958. * Inactive if 0
  66959. */
  66960. includeOnlyWithLayerMask: number;
  66961. private _lightmapMode;
  66962. /**
  66963. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66964. */
  66965. /**
  66966. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  66967. */
  66968. lightmapMode: number;
  66969. /**
  66970. * Shadow generator associted to the light.
  66971. * @hidden Internal use only.
  66972. */
  66973. _shadowGenerator: Nullable<IShadowGenerator>;
  66974. /**
  66975. * @hidden Internal use only.
  66976. */
  66977. _excludedMeshesIds: string[];
  66978. /**
  66979. * @hidden Internal use only.
  66980. */
  66981. _includedOnlyMeshesIds: string[];
  66982. /**
  66983. * The current light unifom buffer.
  66984. * @hidden Internal use only.
  66985. */
  66986. _uniformBuffer: UniformBuffer;
  66987. /**
  66988. * Creates a Light object in the scene.
  66989. * Documentation : https://doc.babylonjs.com/babylon101/lights
  66990. * @param name The firendly name of the light
  66991. * @param scene The scene the light belongs too
  66992. */
  66993. constructor(name: string, scene: Scene);
  66994. protected abstract _buildUniformLayout(): void;
  66995. /**
  66996. * Sets the passed Effect "effect" with the Light information.
  66997. * @param effect The effect to update
  66998. * @param lightIndex The index of the light in the effect to update
  66999. * @returns The light
  67000. */
  67001. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  67002. /**
  67003. * Returns the string "Light".
  67004. * @returns the class name
  67005. */
  67006. getClassName(): string;
  67007. /** @hidden */
  67008. readonly _isLight: boolean;
  67009. /**
  67010. * Converts the light information to a readable string for debug purpose.
  67011. * @param fullDetails Supports for multiple levels of logging within scene loading
  67012. * @returns the human readable light info
  67013. */
  67014. toString(fullDetails?: boolean): string;
  67015. /** @hidden */
  67016. protected _syncParentEnabledState(): void;
  67017. /**
  67018. * Set the enabled state of this node.
  67019. * @param value - the new enabled state
  67020. */
  67021. setEnabled(value: boolean): void;
  67022. /**
  67023. * Returns the Light associated shadow generator if any.
  67024. * @return the associated shadow generator.
  67025. */
  67026. getShadowGenerator(): Nullable<IShadowGenerator>;
  67027. /**
  67028. * Returns a Vector3, the absolute light position in the World.
  67029. * @returns the world space position of the light
  67030. */
  67031. getAbsolutePosition(): Vector3;
  67032. /**
  67033. * Specifies if the light will affect the passed mesh.
  67034. * @param mesh The mesh to test against the light
  67035. * @return true the mesh is affected otherwise, false.
  67036. */
  67037. canAffectMesh(mesh: AbstractMesh): boolean;
  67038. /**
  67039. * Sort function to order lights for rendering.
  67040. * @param a First Light object to compare to second.
  67041. * @param b Second Light object to compare first.
  67042. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  67043. */
  67044. static CompareLightsPriority(a: Light, b: Light): number;
  67045. /**
  67046. * Releases resources associated with this node.
  67047. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67048. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67049. */
  67050. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67051. /**
  67052. * Returns the light type ID (integer).
  67053. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67054. */
  67055. getTypeID(): number;
  67056. /**
  67057. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  67058. * @returns the scaled intensity in intensity mode unit
  67059. */
  67060. getScaledIntensity(): number;
  67061. /**
  67062. * Returns a new Light object, named "name", from the current one.
  67063. * @param name The name of the cloned light
  67064. * @returns the new created light
  67065. */
  67066. clone(name: string): Nullable<Light>;
  67067. /**
  67068. * Serializes the current light into a Serialization object.
  67069. * @returns the serialized object.
  67070. */
  67071. serialize(): any;
  67072. /**
  67073. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  67074. * This new light is named "name" and added to the passed scene.
  67075. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  67076. * @param name The friendly name of the light
  67077. * @param scene The scene the new light will belong to
  67078. * @returns the constructor function
  67079. */
  67080. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  67081. /**
  67082. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  67083. * @param parsedLight The JSON representation of the light
  67084. * @param scene The scene to create the parsed light in
  67085. * @returns the created light after parsing
  67086. */
  67087. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  67088. private _hookArrayForExcluded;
  67089. private _hookArrayForIncludedOnly;
  67090. private _resyncMeshes;
  67091. /**
  67092. * Forces the meshes to update their light related information in their rendering used effects
  67093. * @hidden Internal Use Only
  67094. */
  67095. _markMeshesAsLightDirty(): void;
  67096. /**
  67097. * Recomputes the cached photometric scale if needed.
  67098. */
  67099. private _computePhotometricScale;
  67100. /**
  67101. * Returns the Photometric Scale according to the light type and intensity mode.
  67102. */
  67103. private _getPhotometricScale;
  67104. /**
  67105. * Reorder the light in the scene according to their defined priority.
  67106. * @hidden Internal Use Only
  67107. */
  67108. _reorderLightsInScene(): void;
  67109. /**
  67110. * Prepares the list of defines specific to the light type.
  67111. * @param defines the list of defines
  67112. * @param lightIndex defines the index of the light for the effect
  67113. */
  67114. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67115. }
  67116. }
  67117. declare module BABYLON {
  67118. /**
  67119. * The HemisphericLight simulates the ambient environment light,
  67120. * so the passed direction is the light reflection direction, not the incoming direction.
  67121. */
  67122. export class HemisphericLight extends Light {
  67123. /**
  67124. * The groundColor is the light in the opposite direction to the one specified during creation.
  67125. * 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.
  67126. */
  67127. groundColor: Color3;
  67128. /**
  67129. * The light reflection direction, not the incoming direction.
  67130. */
  67131. direction: Vector3;
  67132. /**
  67133. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  67134. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  67135. * The HemisphericLight can't cast shadows.
  67136. * Documentation : https://doc.babylonjs.com/babylon101/lights
  67137. * @param name The friendly name of the light
  67138. * @param direction The direction of the light reflection
  67139. * @param scene The scene the light belongs to
  67140. */
  67141. constructor(name: string, direction: Vector3, scene: Scene);
  67142. protected _buildUniformLayout(): void;
  67143. /**
  67144. * Returns the string "HemisphericLight".
  67145. * @return The class name
  67146. */
  67147. getClassName(): string;
  67148. /**
  67149. * Sets the HemisphericLight direction towards the passed target (Vector3).
  67150. * Returns the updated direction.
  67151. * @param target The target the direction should point to
  67152. * @return The computed direction
  67153. */
  67154. setDirectionToTarget(target: Vector3): Vector3;
  67155. /**
  67156. * Returns the shadow generator associated to the light.
  67157. * @returns Always null for hemispheric lights because it does not support shadows.
  67158. */
  67159. getShadowGenerator(): Nullable<IShadowGenerator>;
  67160. /**
  67161. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  67162. * @param effect The effect to update
  67163. * @param lightIndex The index of the light in the effect to update
  67164. * @returns The hemispheric light
  67165. */
  67166. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  67167. /**
  67168. * Computes the world matrix of the node
  67169. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67170. * @param useWasUpdatedFlag defines a reserved property
  67171. * @returns the world matrix
  67172. */
  67173. computeWorldMatrix(): Matrix;
  67174. /**
  67175. * Returns the integer 3.
  67176. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  67177. */
  67178. getTypeID(): number;
  67179. /**
  67180. * Prepares the list of defines specific to the light type.
  67181. * @param defines the list of defines
  67182. * @param lightIndex defines the index of the light for the effect
  67183. */
  67184. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  67185. }
  67186. }
  67187. declare module BABYLON {
  67188. /**
  67189. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  67190. * IMPORTANT!! The data is right-hand data.
  67191. * @export
  67192. * @interface DevicePose
  67193. */
  67194. export interface DevicePose {
  67195. /**
  67196. * The position of the device, values in array are [x,y,z].
  67197. */
  67198. readonly position: Nullable<Float32Array>;
  67199. /**
  67200. * The linearVelocity of the device, values in array are [x,y,z].
  67201. */
  67202. readonly linearVelocity: Nullable<Float32Array>;
  67203. /**
  67204. * The linearAcceleration of the device, values in array are [x,y,z].
  67205. */
  67206. readonly linearAcceleration: Nullable<Float32Array>;
  67207. /**
  67208. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  67209. */
  67210. readonly orientation: Nullable<Float32Array>;
  67211. /**
  67212. * The angularVelocity of the device, values in array are [x,y,z].
  67213. */
  67214. readonly angularVelocity: Nullable<Float32Array>;
  67215. /**
  67216. * The angularAcceleration of the device, values in array are [x,y,z].
  67217. */
  67218. readonly angularAcceleration: Nullable<Float32Array>;
  67219. }
  67220. /**
  67221. * Interface representing a pose controlled object in Babylon.
  67222. * A pose controlled object has both regular pose values as well as pose values
  67223. * from an external device such as a VR head mounted display
  67224. */
  67225. export interface PoseControlled {
  67226. /**
  67227. * The position of the object in babylon space.
  67228. */
  67229. position: Vector3;
  67230. /**
  67231. * The rotation quaternion of the object in babylon space.
  67232. */
  67233. rotationQuaternion: Quaternion;
  67234. /**
  67235. * The position of the device in babylon space.
  67236. */
  67237. devicePosition?: Vector3;
  67238. /**
  67239. * The rotation quaternion of the device in babylon space.
  67240. */
  67241. deviceRotationQuaternion: Quaternion;
  67242. /**
  67243. * The raw pose coming from the device.
  67244. */
  67245. rawPose: Nullable<DevicePose>;
  67246. /**
  67247. * The scale of the device to be used when translating from device space to babylon space.
  67248. */
  67249. deviceScaleFactor: number;
  67250. /**
  67251. * Updates the poseControlled values based on the input device pose.
  67252. * @param poseData the pose data to update the object with
  67253. */
  67254. updateFromDevice(poseData: DevicePose): void;
  67255. }
  67256. /**
  67257. * Set of options to customize the webVRCamera
  67258. */
  67259. export interface WebVROptions {
  67260. /**
  67261. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  67262. */
  67263. trackPosition?: boolean;
  67264. /**
  67265. * Sets the scale of the vrDevice in babylon space. (default: 1)
  67266. */
  67267. positionScale?: number;
  67268. /**
  67269. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  67270. */
  67271. displayName?: string;
  67272. /**
  67273. * Should the native controller meshes be initialized. (default: true)
  67274. */
  67275. controllerMeshes?: boolean;
  67276. /**
  67277. * Creating a default HemiLight only on controllers. (default: true)
  67278. */
  67279. defaultLightingOnControllers?: boolean;
  67280. /**
  67281. * If you don't want to use the default VR button of the helper. (default: false)
  67282. */
  67283. useCustomVRButton?: boolean;
  67284. /**
  67285. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  67286. */
  67287. customVRButton?: HTMLButtonElement;
  67288. /**
  67289. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  67290. */
  67291. rayLength?: number;
  67292. /**
  67293. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  67294. */
  67295. defaultHeight?: number;
  67296. }
  67297. /**
  67298. * This represents a WebVR camera.
  67299. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  67300. * @example http://doc.babylonjs.com/how_to/webvr_camera
  67301. */
  67302. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  67303. private webVROptions;
  67304. /**
  67305. * @hidden
  67306. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  67307. */
  67308. _vrDevice: any;
  67309. /**
  67310. * The rawPose of the vrDevice.
  67311. */
  67312. rawPose: Nullable<DevicePose>;
  67313. private _onVREnabled;
  67314. private _specsVersion;
  67315. private _attached;
  67316. private _frameData;
  67317. protected _descendants: Array<Node>;
  67318. private _deviceRoomPosition;
  67319. /** @hidden */
  67320. _deviceRoomRotationQuaternion: Quaternion;
  67321. private _standingMatrix;
  67322. /**
  67323. * Represents device position in babylon space.
  67324. */
  67325. devicePosition: Vector3;
  67326. /**
  67327. * Represents device rotation in babylon space.
  67328. */
  67329. deviceRotationQuaternion: Quaternion;
  67330. /**
  67331. * The scale of the device to be used when translating from device space to babylon space.
  67332. */
  67333. deviceScaleFactor: number;
  67334. private _deviceToWorld;
  67335. private _worldToDevice;
  67336. /**
  67337. * References to the webVR controllers for the vrDevice.
  67338. */
  67339. controllers: Array<WebVRController>;
  67340. /**
  67341. * Emits an event when a controller is attached.
  67342. */
  67343. onControllersAttachedObservable: Observable<WebVRController[]>;
  67344. /**
  67345. * Emits an event when a controller's mesh has been loaded;
  67346. */
  67347. onControllerMeshLoadedObservable: Observable<WebVRController>;
  67348. /**
  67349. * Emits an event when the HMD's pose has been updated.
  67350. */
  67351. onPoseUpdatedFromDeviceObservable: Observable<any>;
  67352. private _poseSet;
  67353. /**
  67354. * If the rig cameras be used as parent instead of this camera.
  67355. */
  67356. rigParenting: boolean;
  67357. private _lightOnControllers;
  67358. private _defaultHeight?;
  67359. /**
  67360. * Instantiates a WebVRFreeCamera.
  67361. * @param name The name of the WebVRFreeCamera
  67362. * @param position The starting anchor position for the camera
  67363. * @param scene The scene the camera belongs to
  67364. * @param webVROptions a set of customizable options for the webVRCamera
  67365. */
  67366. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  67367. /**
  67368. * Gets the device distance from the ground in meters.
  67369. * @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.
  67370. */
  67371. deviceDistanceToRoomGround(): number;
  67372. /**
  67373. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  67374. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  67375. */
  67376. useStandingMatrix(callback?: (bool: boolean) => void): void;
  67377. /**
  67378. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  67379. * @returns A promise with a boolean set to if the standing matrix is supported.
  67380. */
  67381. useStandingMatrixAsync(): Promise<boolean>;
  67382. /**
  67383. * Disposes the camera
  67384. */
  67385. dispose(): void;
  67386. /**
  67387. * Gets a vrController by name.
  67388. * @param name The name of the controller to retreive
  67389. * @returns the controller matching the name specified or null if not found
  67390. */
  67391. getControllerByName(name: string): Nullable<WebVRController>;
  67392. private _leftController;
  67393. /**
  67394. * The controller corrisponding to the users left hand.
  67395. */
  67396. readonly leftController: Nullable<WebVRController>;
  67397. private _rightController;
  67398. /**
  67399. * The controller corrisponding to the users right hand.
  67400. */
  67401. readonly rightController: Nullable<WebVRController>;
  67402. /**
  67403. * Casts a ray forward from the vrCamera's gaze.
  67404. * @param length Length of the ray (default: 100)
  67405. * @returns the ray corrisponding to the gaze
  67406. */
  67407. getForwardRay(length?: number): Ray;
  67408. /**
  67409. * @hidden
  67410. * Updates the camera based on device's frame data
  67411. */
  67412. _checkInputs(): void;
  67413. /**
  67414. * Updates the poseControlled values based on the input device pose.
  67415. * @param poseData Pose coming from the device
  67416. */
  67417. updateFromDevice(poseData: DevicePose): void;
  67418. private _htmlElementAttached;
  67419. private _detachIfAttached;
  67420. /**
  67421. * WebVR's attach control will start broadcasting frames to the device.
  67422. * Note that in certain browsers (chrome for example) this function must be called
  67423. * within a user-interaction callback. Example:
  67424. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  67425. *
  67426. * @param element html element to attach the vrDevice to
  67427. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  67428. */
  67429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  67430. /**
  67431. * Detaches the camera from the html element and disables VR
  67432. *
  67433. * @param element html element to detach from
  67434. */
  67435. detachControl(element: HTMLElement): void;
  67436. /**
  67437. * @returns the name of this class
  67438. */
  67439. getClassName(): string;
  67440. /**
  67441. * Calls resetPose on the vrDisplay
  67442. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  67443. */
  67444. resetToCurrentRotation(): void;
  67445. /**
  67446. * @hidden
  67447. * Updates the rig cameras (left and right eye)
  67448. */
  67449. _updateRigCameras(): void;
  67450. private _workingVector;
  67451. private _oneVector;
  67452. private _workingMatrix;
  67453. private updateCacheCalled;
  67454. private _correctPositionIfNotTrackPosition;
  67455. /**
  67456. * @hidden
  67457. * Updates the cached values of the camera
  67458. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  67459. */
  67460. _updateCache(ignoreParentClass?: boolean): void;
  67461. /**
  67462. * @hidden
  67463. * Get current device position in babylon world
  67464. */
  67465. _computeDevicePosition(): void;
  67466. /**
  67467. * Updates the current device position and rotation in the babylon world
  67468. */
  67469. update(): void;
  67470. /**
  67471. * @hidden
  67472. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  67473. * @returns an identity matrix
  67474. */
  67475. _getViewMatrix(): Matrix;
  67476. private _tmpMatrix;
  67477. /**
  67478. * This function is called by the two RIG cameras.
  67479. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  67480. * @hidden
  67481. */
  67482. _getWebVRViewMatrix(): Matrix;
  67483. /** @hidden */
  67484. _getWebVRProjectionMatrix(): Matrix;
  67485. private _onGamepadConnectedObserver;
  67486. private _onGamepadDisconnectedObserver;
  67487. private _updateCacheWhenTrackingDisabledObserver;
  67488. /**
  67489. * Initializes the controllers and their meshes
  67490. */
  67491. initControllers(): void;
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /**
  67496. * Size options for a post process
  67497. */
  67498. export type PostProcessOptions = {
  67499. width: number;
  67500. height: number;
  67501. };
  67502. /**
  67503. * PostProcess can be used to apply a shader to a texture after it has been rendered
  67504. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67505. */
  67506. export class PostProcess {
  67507. /** Name of the PostProcess. */
  67508. name: string;
  67509. /**
  67510. * Width of the texture to apply the post process on
  67511. */
  67512. width: number;
  67513. /**
  67514. * Height of the texture to apply the post process on
  67515. */
  67516. height: number;
  67517. /**
  67518. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  67519. * @hidden
  67520. */
  67521. _outputTexture: Nullable<InternalTexture>;
  67522. /**
  67523. * Sampling mode used by the shader
  67524. * See https://doc.babylonjs.com/classes/3.1/texture
  67525. */
  67526. renderTargetSamplingMode: number;
  67527. /**
  67528. * Clear color to use when screen clearing
  67529. */
  67530. clearColor: Color4;
  67531. /**
  67532. * If the buffer needs to be cleared before applying the post process. (default: true)
  67533. * Should be set to false if shader will overwrite all previous pixels.
  67534. */
  67535. autoClear: boolean;
  67536. /**
  67537. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  67538. */
  67539. alphaMode: number;
  67540. /**
  67541. * Sets the setAlphaBlendConstants of the babylon engine
  67542. */
  67543. alphaConstants: Color4;
  67544. /**
  67545. * Animations to be used for the post processing
  67546. */
  67547. animations: Animation[];
  67548. /**
  67549. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  67550. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  67551. */
  67552. enablePixelPerfectMode: boolean;
  67553. /**
  67554. * Force the postprocess to be applied without taking in account viewport
  67555. */
  67556. forceFullscreenViewport: boolean;
  67557. /**
  67558. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  67559. *
  67560. * | Value | Type | Description |
  67561. * | ----- | ----------------------------------- | ----------- |
  67562. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  67563. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  67564. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  67565. *
  67566. */
  67567. scaleMode: number;
  67568. /**
  67569. * Force textures to be a power of two (default: false)
  67570. */
  67571. alwaysForcePOT: boolean;
  67572. private _samples;
  67573. /**
  67574. * Number of sample textures (default: 1)
  67575. */
  67576. samples: number;
  67577. /**
  67578. * Modify the scale of the post process to be the same as the viewport (default: false)
  67579. */
  67580. adaptScaleToCurrentViewport: boolean;
  67581. private _camera;
  67582. private _scene;
  67583. private _engine;
  67584. private _options;
  67585. private _reusable;
  67586. private _textureType;
  67587. /**
  67588. * Smart array of input and output textures for the post process.
  67589. * @hidden
  67590. */
  67591. _textures: SmartArray<InternalTexture>;
  67592. /**
  67593. * The index in _textures that corresponds to the output texture.
  67594. * @hidden
  67595. */
  67596. _currentRenderTextureInd: number;
  67597. private _effect;
  67598. private _samplers;
  67599. private _fragmentUrl;
  67600. private _vertexUrl;
  67601. private _parameters;
  67602. private _scaleRatio;
  67603. protected _indexParameters: any;
  67604. private _shareOutputWithPostProcess;
  67605. private _texelSize;
  67606. private _forcedOutputTexture;
  67607. /**
  67608. * Returns the fragment url or shader name used in the post process.
  67609. * @returns the fragment url or name in the shader store.
  67610. */
  67611. getEffectName(): string;
  67612. /**
  67613. * An event triggered when the postprocess is activated.
  67614. */
  67615. onActivateObservable: Observable<Camera>;
  67616. private _onActivateObserver;
  67617. /**
  67618. * A function that is added to the onActivateObservable
  67619. */
  67620. onActivate: Nullable<(camera: Camera) => void>;
  67621. /**
  67622. * An event triggered when the postprocess changes its size.
  67623. */
  67624. onSizeChangedObservable: Observable<PostProcess>;
  67625. private _onSizeChangedObserver;
  67626. /**
  67627. * A function that is added to the onSizeChangedObservable
  67628. */
  67629. onSizeChanged: (postProcess: PostProcess) => void;
  67630. /**
  67631. * An event triggered when the postprocess applies its effect.
  67632. */
  67633. onApplyObservable: Observable<Effect>;
  67634. private _onApplyObserver;
  67635. /**
  67636. * A function that is added to the onApplyObservable
  67637. */
  67638. onApply: (effect: Effect) => void;
  67639. /**
  67640. * An event triggered before rendering the postprocess
  67641. */
  67642. onBeforeRenderObservable: Observable<Effect>;
  67643. private _onBeforeRenderObserver;
  67644. /**
  67645. * A function that is added to the onBeforeRenderObservable
  67646. */
  67647. onBeforeRender: (effect: Effect) => void;
  67648. /**
  67649. * An event triggered after rendering the postprocess
  67650. */
  67651. onAfterRenderObservable: Observable<Effect>;
  67652. private _onAfterRenderObserver;
  67653. /**
  67654. * A function that is added to the onAfterRenderObservable
  67655. */
  67656. onAfterRender: (efect: Effect) => void;
  67657. /**
  67658. * 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
  67659. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  67660. */
  67661. inputTexture: InternalTexture;
  67662. /**
  67663. * Gets the camera which post process is applied to.
  67664. * @returns The camera the post process is applied to.
  67665. */
  67666. getCamera(): Camera;
  67667. /**
  67668. * Gets the texel size of the postprocess.
  67669. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  67670. */
  67671. readonly texelSize: Vector2;
  67672. /**
  67673. * Creates a new instance PostProcess
  67674. * @param name The name of the PostProcess.
  67675. * @param fragmentUrl The url of the fragment shader to be used.
  67676. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  67677. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  67678. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67679. * @param camera The camera to apply the render pass to.
  67680. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67681. * @param engine The engine which the post process will be applied. (default: current engine)
  67682. * @param reusable If the post process can be reused on the same frame. (default: false)
  67683. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  67684. * @param textureType Type of textures used when performing the post process. (default: 0)
  67685. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  67686. * @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
  67687. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  67688. */
  67689. constructor(
  67690. /** Name of the PostProcess. */
  67691. 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);
  67692. /**
  67693. * Gets the engine which this post process belongs to.
  67694. * @returns The engine the post process was enabled with.
  67695. */
  67696. getEngine(): Engine;
  67697. /**
  67698. * The effect that is created when initializing the post process.
  67699. * @returns The created effect corrisponding the the postprocess.
  67700. */
  67701. getEffect(): Effect;
  67702. /**
  67703. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  67704. * @param postProcess The post process to share the output with.
  67705. * @returns This post process.
  67706. */
  67707. shareOutputWith(postProcess: PostProcess): PostProcess;
  67708. /**
  67709. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  67710. * This should be called if the post process that shares output with this post process is disabled/disposed.
  67711. */
  67712. useOwnOutput(): void;
  67713. /**
  67714. * Updates the effect with the current post process compile time values and recompiles the shader.
  67715. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67716. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67717. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67718. * @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
  67719. * @param onCompiled Called when the shader has been compiled.
  67720. * @param onError Called if there is an error when compiling a shader.
  67721. */
  67722. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67723. /**
  67724. * The post process is reusable if it can be used multiple times within one frame.
  67725. * @returns If the post process is reusable
  67726. */
  67727. isReusable(): boolean;
  67728. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  67729. markTextureDirty(): void;
  67730. /**
  67731. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  67732. * 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.
  67733. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  67734. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  67735. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  67736. * @returns The target texture that was bound to be written to.
  67737. */
  67738. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  67739. /**
  67740. * If the post process is supported.
  67741. */
  67742. readonly isSupported: boolean;
  67743. /**
  67744. * The aspect ratio of the output texture.
  67745. */
  67746. readonly aspectRatio: number;
  67747. /**
  67748. * Get a value indicating if the post-process is ready to be used
  67749. * @returns true if the post-process is ready (shader is compiled)
  67750. */
  67751. isReady(): boolean;
  67752. /**
  67753. * Binds all textures and uniforms to the shader, this will be run on every pass.
  67754. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  67755. */
  67756. apply(): Nullable<Effect>;
  67757. private _disposeTextures;
  67758. /**
  67759. * Disposes the post process.
  67760. * @param camera The camera to dispose the post process on.
  67761. */
  67762. dispose(camera?: Camera): void;
  67763. }
  67764. }
  67765. declare module BABYLON {
  67766. /** @hidden */
  67767. export var kernelBlurVaryingDeclaration: {
  67768. name: string;
  67769. shader: string;
  67770. };
  67771. }
  67772. declare module BABYLON {
  67773. /** @hidden */
  67774. export var kernelBlurFragment: {
  67775. name: string;
  67776. shader: string;
  67777. };
  67778. }
  67779. declare module BABYLON {
  67780. /** @hidden */
  67781. export var kernelBlurFragment2: {
  67782. name: string;
  67783. shader: string;
  67784. };
  67785. }
  67786. declare module BABYLON {
  67787. /** @hidden */
  67788. export var kernelBlurPixelShader: {
  67789. name: string;
  67790. shader: string;
  67791. };
  67792. }
  67793. declare module BABYLON {
  67794. /** @hidden */
  67795. export var kernelBlurVertex: {
  67796. name: string;
  67797. shader: string;
  67798. };
  67799. }
  67800. declare module BABYLON {
  67801. /** @hidden */
  67802. export var kernelBlurVertexShader: {
  67803. name: string;
  67804. shader: string;
  67805. };
  67806. }
  67807. declare module BABYLON {
  67808. /**
  67809. * The Blur Post Process which blurs an image based on a kernel and direction.
  67810. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  67811. */
  67812. export class BlurPostProcess extends PostProcess {
  67813. /** The direction in which to blur the image. */
  67814. direction: Vector2;
  67815. private blockCompilation;
  67816. protected _kernel: number;
  67817. protected _idealKernel: number;
  67818. protected _packedFloat: boolean;
  67819. private _staticDefines;
  67820. /**
  67821. * Sets the length in pixels of the blur sample region
  67822. */
  67823. /**
  67824. * Gets the length in pixels of the blur sample region
  67825. */
  67826. kernel: number;
  67827. /**
  67828. * Sets wether or not the blur needs to unpack/repack floats
  67829. */
  67830. /**
  67831. * Gets wether or not the blur is unpacking/repacking floats
  67832. */
  67833. packedFloat: boolean;
  67834. /**
  67835. * Creates a new instance BlurPostProcess
  67836. * @param name The name of the effect.
  67837. * @param direction The direction in which to blur the image.
  67838. * @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.
  67839. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  67840. * @param camera The camera to apply the render pass to.
  67841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67842. * @param engine The engine which the post process will be applied. (default: current engine)
  67843. * @param reusable If the post process can be reused on the same frame. (default: false)
  67844. * @param textureType Type of textures used when performing the post process. (default: 0)
  67845. * @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)
  67846. */
  67847. constructor(name: string,
  67848. /** The direction in which to blur the image. */
  67849. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  67850. /**
  67851. * Updates the effect with the current post process compile time values and recompiles the shader.
  67852. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67853. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67854. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67855. * @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
  67856. * @param onCompiled Called when the shader has been compiled.
  67857. * @param onError Called if there is an error when compiling a shader.
  67858. */
  67859. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67860. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67861. /**
  67862. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  67863. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  67864. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  67865. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  67866. * The gaps between physical kernels are compensated for in the weighting of the samples
  67867. * @param idealKernel Ideal blur kernel.
  67868. * @return Nearest best kernel.
  67869. */
  67870. protected _nearestBestKernel(idealKernel: number): number;
  67871. /**
  67872. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  67873. * @param x The point on the Gaussian distribution to sample.
  67874. * @return the value of the Gaussian function at x.
  67875. */
  67876. protected _gaussianWeight(x: number): number;
  67877. /**
  67878. * Generates a string that can be used as a floating point number in GLSL.
  67879. * @param x Value to print.
  67880. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  67881. * @return GLSL float string.
  67882. */
  67883. protected _glslFloat(x: number, decimalFigures?: number): string;
  67884. }
  67885. }
  67886. declare module BABYLON {
  67887. /**
  67888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  67889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  67890. * You can then easily use it as a reflectionTexture on a flat surface.
  67891. * In case the surface is not a plane, please consider relying on reflection probes.
  67892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  67893. */
  67894. export class MirrorTexture extends RenderTargetTexture {
  67895. private scene;
  67896. /**
  67897. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  67898. * 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.
  67899. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  67900. */
  67901. mirrorPlane: Plane;
  67902. /**
  67903. * Define the blur ratio used to blur the reflection if needed.
  67904. */
  67905. blurRatio: number;
  67906. /**
  67907. * Define the adaptive blur kernel used to blur the reflection if needed.
  67908. * This will autocompute the closest best match for the `blurKernel`
  67909. */
  67910. adaptiveBlurKernel: number;
  67911. /**
  67912. * Define the blur kernel used to blur the reflection if needed.
  67913. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  67914. */
  67915. blurKernel: number;
  67916. /**
  67917. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  67918. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  67919. */
  67920. blurKernelX: number;
  67921. /**
  67922. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  67923. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  67924. */
  67925. blurKernelY: number;
  67926. private _autoComputeBlurKernel;
  67927. protected _onRatioRescale(): void;
  67928. private _updateGammaSpace;
  67929. private _imageProcessingConfigChangeObserver;
  67930. private _transformMatrix;
  67931. private _mirrorMatrix;
  67932. private _savedViewMatrix;
  67933. private _blurX;
  67934. private _blurY;
  67935. private _adaptiveBlurKernel;
  67936. private _blurKernelX;
  67937. private _blurKernelY;
  67938. private _blurRatio;
  67939. /**
  67940. * Instantiates a Mirror Texture.
  67941. * Mirror texture can be used to simulate the view from a mirror in a scene.
  67942. * It will dynamically be rendered every frame to adapt to the camera point of view.
  67943. * You can then easily use it as a reflectionTexture on a flat surface.
  67944. * In case the surface is not a plane, please consider relying on reflection probes.
  67945. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  67946. * @param name
  67947. * @param size
  67948. * @param scene
  67949. * @param generateMipMaps
  67950. * @param type
  67951. * @param samplingMode
  67952. * @param generateDepthBuffer
  67953. */
  67954. constructor(name: string, size: number | {
  67955. width: number;
  67956. height: number;
  67957. } | {
  67958. ratio: number;
  67959. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  67960. private _preparePostProcesses;
  67961. /**
  67962. * Clone the mirror texture.
  67963. * @returns the cloned texture
  67964. */
  67965. clone(): MirrorTexture;
  67966. /**
  67967. * Serialize the texture to a JSON representation you could use in Parse later on
  67968. * @returns the serialized JSON representation
  67969. */
  67970. serialize(): any;
  67971. /**
  67972. * Dispose the texture and release its associated resources.
  67973. */
  67974. dispose(): void;
  67975. }
  67976. }
  67977. declare module BABYLON {
  67978. /**
  67979. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  67980. * @see http://doc.babylonjs.com/babylon101/materials#texture
  67981. */
  67982. export class Texture extends BaseTexture {
  67983. /** @hidden */
  67984. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  67985. /** @hidden */
  67986. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  67987. /** @hidden */
  67988. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  67989. /** nearest is mag = nearest and min = nearest and mip = linear */
  67990. static readonly NEAREST_SAMPLINGMODE: number;
  67991. /** nearest is mag = nearest and min = nearest and mip = linear */
  67992. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  67993. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67994. static readonly BILINEAR_SAMPLINGMODE: number;
  67995. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67996. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  67997. /** Trilinear is mag = linear and min = linear and mip = linear */
  67998. static readonly TRILINEAR_SAMPLINGMODE: number;
  67999. /** Trilinear is mag = linear and min = linear and mip = linear */
  68000. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  68001. /** mag = nearest and min = nearest and mip = nearest */
  68002. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  68003. /** mag = nearest and min = linear and mip = nearest */
  68004. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  68005. /** mag = nearest and min = linear and mip = linear */
  68006. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  68007. /** mag = nearest and min = linear and mip = none */
  68008. static readonly NEAREST_LINEAR: number;
  68009. /** mag = nearest and min = nearest and mip = none */
  68010. static readonly NEAREST_NEAREST: number;
  68011. /** mag = linear and min = nearest and mip = nearest */
  68012. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  68013. /** mag = linear and min = nearest and mip = linear */
  68014. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  68015. /** mag = linear and min = linear and mip = none */
  68016. static readonly LINEAR_LINEAR: number;
  68017. /** mag = linear and min = nearest and mip = none */
  68018. static readonly LINEAR_NEAREST: number;
  68019. /** Explicit coordinates mode */
  68020. static readonly EXPLICIT_MODE: number;
  68021. /** Spherical coordinates mode */
  68022. static readonly SPHERICAL_MODE: number;
  68023. /** Planar coordinates mode */
  68024. static readonly PLANAR_MODE: number;
  68025. /** Cubic coordinates mode */
  68026. static readonly CUBIC_MODE: number;
  68027. /** Projection coordinates mode */
  68028. static readonly PROJECTION_MODE: number;
  68029. /** Inverse Cubic coordinates mode */
  68030. static readonly SKYBOX_MODE: number;
  68031. /** Inverse Cubic coordinates mode */
  68032. static readonly INVCUBIC_MODE: number;
  68033. /** Equirectangular coordinates mode */
  68034. static readonly EQUIRECTANGULAR_MODE: number;
  68035. /** Equirectangular Fixed coordinates mode */
  68036. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  68037. /** Equirectangular Fixed Mirrored coordinates mode */
  68038. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  68039. /** Texture is not repeating outside of 0..1 UVs */
  68040. static readonly CLAMP_ADDRESSMODE: number;
  68041. /** Texture is repeating outside of 0..1 UVs */
  68042. static readonly WRAP_ADDRESSMODE: number;
  68043. /** Texture is repeating and mirrored */
  68044. static readonly MIRROR_ADDRESSMODE: number;
  68045. /**
  68046. * 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
  68047. */
  68048. static UseSerializedUrlIfAny: boolean;
  68049. /**
  68050. * Define the url of the texture.
  68051. */
  68052. url: Nullable<string>;
  68053. /**
  68054. * Define an offset on the texture to offset the u coordinates of the UVs
  68055. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  68056. */
  68057. uOffset: number;
  68058. /**
  68059. * Define an offset on the texture to offset the v coordinates of the UVs
  68060. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  68061. */
  68062. vOffset: number;
  68063. /**
  68064. * Define an offset on the texture to scale the u coordinates of the UVs
  68065. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  68066. */
  68067. uScale: number;
  68068. /**
  68069. * Define an offset on the texture to scale the v coordinates of the UVs
  68070. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  68071. */
  68072. vScale: number;
  68073. /**
  68074. * Define an offset on the texture to rotate around the u coordinates of the UVs
  68075. * @see http://doc.babylonjs.com/how_to/more_materials
  68076. */
  68077. uAng: number;
  68078. /**
  68079. * Define an offset on the texture to rotate around the v coordinates of the UVs
  68080. * @see http://doc.babylonjs.com/how_to/more_materials
  68081. */
  68082. vAng: number;
  68083. /**
  68084. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  68085. * @see http://doc.babylonjs.com/how_to/more_materials
  68086. */
  68087. wAng: number;
  68088. /**
  68089. * Defines the center of rotation (U)
  68090. */
  68091. uRotationCenter: number;
  68092. /**
  68093. * Defines the center of rotation (V)
  68094. */
  68095. vRotationCenter: number;
  68096. /**
  68097. * Defines the center of rotation (W)
  68098. */
  68099. wRotationCenter: number;
  68100. /**
  68101. * Are mip maps generated for this texture or not.
  68102. */
  68103. readonly noMipmap: boolean;
  68104. private _noMipmap;
  68105. /** @hidden */
  68106. _invertY: boolean;
  68107. private _rowGenerationMatrix;
  68108. private _cachedTextureMatrix;
  68109. private _projectionModeMatrix;
  68110. private _t0;
  68111. private _t1;
  68112. private _t2;
  68113. private _cachedUOffset;
  68114. private _cachedVOffset;
  68115. private _cachedUScale;
  68116. private _cachedVScale;
  68117. private _cachedUAng;
  68118. private _cachedVAng;
  68119. private _cachedWAng;
  68120. private _cachedProjectionMatrixId;
  68121. private _cachedCoordinatesMode;
  68122. /** @hidden */
  68123. protected _initialSamplingMode: number;
  68124. /** @hidden */
  68125. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68126. private _deleteBuffer;
  68127. protected _format: Nullable<number>;
  68128. private _delayedOnLoad;
  68129. private _delayedOnError;
  68130. /**
  68131. * Observable triggered once the texture has been loaded.
  68132. */
  68133. onLoadObservable: Observable<Texture>;
  68134. protected _isBlocking: boolean;
  68135. /**
  68136. * Is the texture preventing material to render while loading.
  68137. * If false, a default texture will be used instead of the loading one during the preparation step.
  68138. */
  68139. isBlocking: boolean;
  68140. /**
  68141. * Get the current sampling mode associated with the texture.
  68142. */
  68143. readonly samplingMode: number;
  68144. /**
  68145. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  68146. */
  68147. readonly invertY: boolean;
  68148. /**
  68149. * Instantiates a new texture.
  68150. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  68151. * @see http://doc.babylonjs.com/babylon101/materials#texture
  68152. * @param url define the url of the picture to load as a texture
  68153. * @param scene define the scene the texture will belong to
  68154. * @param noMipmap define if the texture will require mip maps or not
  68155. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68156. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68157. * @param onLoad define a callback triggered when the texture has been loaded
  68158. * @param onError define a callback triggered when an error occurred during the loading session
  68159. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  68160. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  68161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68162. */
  68163. 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);
  68164. /**
  68165. * Update the url (and optional buffer) of this texture if url was null during construction.
  68166. * @param url the url of the texture
  68167. * @param buffer the buffer of the texture (defaults to null)
  68168. * @param onLoad callback called when the texture is loaded (defaults to null)
  68169. */
  68170. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  68171. /**
  68172. * Finish the loading sequence of a texture flagged as delayed load.
  68173. * @hidden
  68174. */
  68175. delayLoad(): void;
  68176. private _prepareRowForTextureGeneration;
  68177. /**
  68178. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  68179. * @returns the transform matrix of the texture.
  68180. */
  68181. getTextureMatrix(): Matrix;
  68182. /**
  68183. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  68184. * @returns The reflection texture transform
  68185. */
  68186. getReflectionTextureMatrix(): Matrix;
  68187. /**
  68188. * Clones the texture.
  68189. * @returns the cloned texture
  68190. */
  68191. clone(): Texture;
  68192. /**
  68193. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  68194. * @returns The JSON representation of the texture
  68195. */
  68196. serialize(): any;
  68197. /**
  68198. * Get the current class name of the texture useful for serialization or dynamic coding.
  68199. * @returns "Texture"
  68200. */
  68201. getClassName(): string;
  68202. /**
  68203. * Dispose the texture and release its associated resources.
  68204. */
  68205. dispose(): void;
  68206. /**
  68207. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  68208. * @param parsedTexture Define the JSON representation of the texture
  68209. * @param scene Define the scene the parsed texture should be instantiated in
  68210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  68211. * @returns The parsed texture if successful
  68212. */
  68213. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  68214. /**
  68215. * Creates a texture from its base 64 representation.
  68216. * @param data Define the base64 payload without the data: prefix
  68217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  68218. * @param scene Define the scene the texture should belong to
  68219. * @param noMipmap Forces the texture to not create mip map information if true
  68220. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68221. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68222. * @param onLoad define a callback triggered when the texture has been loaded
  68223. * @param onError define a callback triggered when an error occurred during the loading session
  68224. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68225. * @returns the created texture
  68226. */
  68227. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  68228. /**
  68229. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  68230. * @param data Define the base64 payload without the data: prefix
  68231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  68232. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  68233. * @param scene Define the scene the texture should belong to
  68234. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  68235. * @param noMipmap Forces the texture to not create mip map information if true
  68236. * @param invertY define if the texture needs to be inverted on the y axis during loading
  68237. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  68238. * @param onLoad define a callback triggered when the texture has been loaded
  68239. * @param onError define a callback triggered when an error occurred during the loading session
  68240. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  68241. * @returns the created texture
  68242. */
  68243. 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;
  68244. }
  68245. }
  68246. declare module BABYLON {
  68247. /**
  68248. * PostProcessManager is used to manage one or more post processes or post process pipelines
  68249. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68250. */
  68251. export class PostProcessManager {
  68252. private _scene;
  68253. private _indexBuffer;
  68254. private _vertexBuffers;
  68255. /**
  68256. * Creates a new instance PostProcess
  68257. * @param scene The scene that the post process is associated with.
  68258. */
  68259. constructor(scene: Scene);
  68260. private _prepareBuffers;
  68261. private _buildIndexBuffer;
  68262. /**
  68263. * Rebuilds the vertex buffers of the manager.
  68264. * @hidden
  68265. */
  68266. _rebuild(): void;
  68267. /**
  68268. * Prepares a frame to be run through a post process.
  68269. * @param sourceTexture The input texture to the post procesess. (default: null)
  68270. * @param postProcesses An array of post processes to be run. (default: null)
  68271. * @returns True if the post processes were able to be run.
  68272. * @hidden
  68273. */
  68274. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  68275. /**
  68276. * Manually render a set of post processes to a texture.
  68277. * @param postProcesses An array of post processes to be run.
  68278. * @param targetTexture The target texture to render to.
  68279. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  68280. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  68281. * @param lodLevel defines which lod of the texture to render to
  68282. */
  68283. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  68284. /**
  68285. * Finalize the result of the output of the postprocesses.
  68286. * @param doNotPresent If true the result will not be displayed to the screen.
  68287. * @param targetTexture The target texture to render to.
  68288. * @param faceIndex The index of the face to bind the target texture to.
  68289. * @param postProcesses The array of post processes to render.
  68290. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  68291. * @hidden
  68292. */
  68293. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  68294. /**
  68295. * Disposes of the post process manager.
  68296. */
  68297. dispose(): void;
  68298. }
  68299. }
  68300. declare module BABYLON {
  68301. /**
  68302. * Groups all the scene component constants in one place to ease maintenance.
  68303. * @hidden
  68304. */
  68305. export class SceneComponentConstants {
  68306. static readonly NAME_EFFECTLAYER: string;
  68307. static readonly NAME_LAYER: string;
  68308. static readonly NAME_LENSFLARESYSTEM: string;
  68309. static readonly NAME_BOUNDINGBOXRENDERER: string;
  68310. static readonly NAME_PARTICLESYSTEM: string;
  68311. static readonly NAME_GAMEPAD: string;
  68312. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  68313. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  68314. static readonly NAME_DEPTHRENDERER: string;
  68315. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  68316. static readonly NAME_SPRITE: string;
  68317. static readonly NAME_OUTLINERENDERER: string;
  68318. static readonly NAME_PROCEDURALTEXTURE: string;
  68319. static readonly NAME_SHADOWGENERATOR: string;
  68320. static readonly NAME_OCTREE: string;
  68321. static readonly NAME_PHYSICSENGINE: string;
  68322. static readonly NAME_AUDIO: string;
  68323. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  68324. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68325. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  68326. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  68327. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  68328. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  68329. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  68330. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  68331. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  68332. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  68333. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  68334. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  68335. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  68336. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  68337. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  68338. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  68339. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  68340. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  68341. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  68342. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  68343. static readonly STEP_AFTERRENDER_AUDIO: number;
  68344. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  68345. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  68346. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  68347. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  68348. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  68349. static readonly STEP_POINTERMOVE_SPRITE: number;
  68350. static readonly STEP_POINTERDOWN_SPRITE: number;
  68351. static readonly STEP_POINTERUP_SPRITE: number;
  68352. }
  68353. /**
  68354. * This represents a scene component.
  68355. *
  68356. * This is used to decouple the dependency the scene is having on the different workloads like
  68357. * layers, post processes...
  68358. */
  68359. export interface ISceneComponent {
  68360. /**
  68361. * The name of the component. Each component must have a unique name.
  68362. */
  68363. name: string;
  68364. /**
  68365. * The scene the component belongs to.
  68366. */
  68367. scene: Scene;
  68368. /**
  68369. * Register the component to one instance of a scene.
  68370. */
  68371. register(): void;
  68372. /**
  68373. * Rebuilds the elements related to this component in case of
  68374. * context lost for instance.
  68375. */
  68376. rebuild(): void;
  68377. /**
  68378. * Disposes the component and the associated ressources.
  68379. */
  68380. dispose(): void;
  68381. }
  68382. /**
  68383. * This represents a SERIALIZABLE scene component.
  68384. *
  68385. * This extends Scene Component to add Serialization methods on top.
  68386. */
  68387. export interface ISceneSerializableComponent extends ISceneComponent {
  68388. /**
  68389. * Adds all the element from the container to the scene
  68390. * @param container the container holding the elements
  68391. */
  68392. addFromContainer(container: AbstractScene): void;
  68393. /**
  68394. * Removes all the elements in the container from the scene
  68395. * @param container contains the elements to remove
  68396. */
  68397. removeFromContainer(container: AbstractScene): void;
  68398. /**
  68399. * Serializes the component data to the specified json object
  68400. * @param serializationObject The object to serialize to
  68401. */
  68402. serialize(serializationObject: any): void;
  68403. }
  68404. /**
  68405. * Strong typing of a Mesh related stage step action
  68406. */
  68407. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  68408. /**
  68409. * Strong typing of a Evaluate Sub Mesh related stage step action
  68410. */
  68411. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  68412. /**
  68413. * Strong typing of a Active Mesh related stage step action
  68414. */
  68415. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  68416. /**
  68417. * Strong typing of a Camera related stage step action
  68418. */
  68419. export type CameraStageAction = (camera: Camera) => void;
  68420. /**
  68421. * Strong typing of a Render Target related stage step action
  68422. */
  68423. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  68424. /**
  68425. * Strong typing of a RenderingGroup related stage step action
  68426. */
  68427. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  68428. /**
  68429. * Strong typing of a Mesh Render related stage step action
  68430. */
  68431. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  68432. /**
  68433. * Strong typing of a simple stage step action
  68434. */
  68435. export type SimpleStageAction = () => void;
  68436. /**
  68437. * Strong typing of a render target action.
  68438. */
  68439. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  68440. /**
  68441. * Strong typing of a pointer move action.
  68442. */
  68443. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  68444. /**
  68445. * Strong typing of a pointer up/down action.
  68446. */
  68447. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  68448. /**
  68449. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  68450. * @hidden
  68451. */
  68452. export class Stage<T extends Function> extends Array<{
  68453. index: number;
  68454. component: ISceneComponent;
  68455. action: T;
  68456. }> {
  68457. /**
  68458. * Hide ctor from the rest of the world.
  68459. * @param items The items to add.
  68460. */
  68461. private constructor();
  68462. /**
  68463. * Creates a new Stage.
  68464. * @returns A new instance of a Stage
  68465. */
  68466. static Create<T extends Function>(): Stage<T>;
  68467. /**
  68468. * Registers a step in an ordered way in the targeted stage.
  68469. * @param index Defines the position to register the step in
  68470. * @param component Defines the component attached to the step
  68471. * @param action Defines the action to launch during the step
  68472. */
  68473. registerStep(index: number, component: ISceneComponent, action: T): void;
  68474. /**
  68475. * Clears all the steps from the stage.
  68476. */
  68477. clear(): void;
  68478. }
  68479. }
  68480. declare module BABYLON {
  68481. interface Scene {
  68482. /** @hidden */
  68483. _pointerOverSprite: Nullable<Sprite>;
  68484. /** @hidden */
  68485. _pickedDownSprite: Nullable<Sprite>;
  68486. /** @hidden */
  68487. _tempSpritePickingRay: Nullable<Ray>;
  68488. /**
  68489. * All of the sprite managers added to this scene
  68490. * @see http://doc.babylonjs.com/babylon101/sprites
  68491. */
  68492. spriteManagers: Array<ISpriteManager>;
  68493. /**
  68494. * An event triggered when sprites rendering is about to start
  68495. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68496. */
  68497. onBeforeSpritesRenderingObservable: Observable<Scene>;
  68498. /**
  68499. * An event triggered when sprites rendering is done
  68500. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  68501. */
  68502. onAfterSpritesRenderingObservable: Observable<Scene>;
  68503. /** @hidden */
  68504. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68505. /** Launch a ray to try to pick a sprite in the scene
  68506. * @param x position on screen
  68507. * @param y position on screen
  68508. * @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
  68509. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68510. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  68511. * @returns a PickingInfo
  68512. */
  68513. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68514. /** Use the given ray to pick a sprite in the scene
  68515. * @param ray The ray (in world space) to use to pick meshes
  68516. * @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
  68517. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  68518. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  68519. * @returns a PickingInfo
  68520. */
  68521. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  68522. /**
  68523. * Force the sprite under the pointer
  68524. * @param sprite defines the sprite to use
  68525. */
  68526. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  68527. /**
  68528. * Gets the sprite under the pointer
  68529. * @returns a Sprite or null if no sprite is under the pointer
  68530. */
  68531. getPointerOverSprite(): Nullable<Sprite>;
  68532. }
  68533. /**
  68534. * Defines the sprite scene component responsible to manage sprites
  68535. * in a given scene.
  68536. */
  68537. export class SpriteSceneComponent implements ISceneComponent {
  68538. /**
  68539. * The component name helpfull to identify the component in the list of scene components.
  68540. */
  68541. readonly name: string;
  68542. /**
  68543. * The scene the component belongs to.
  68544. */
  68545. scene: Scene;
  68546. /** @hidden */
  68547. private _spritePredicate;
  68548. /**
  68549. * Creates a new instance of the component for the given scene
  68550. * @param scene Defines the scene to register the component in
  68551. */
  68552. constructor(scene: Scene);
  68553. /**
  68554. * Registers the component in a given scene
  68555. */
  68556. register(): void;
  68557. /**
  68558. * Rebuilds the elements related to this component in case of
  68559. * context lost for instance.
  68560. */
  68561. rebuild(): void;
  68562. /**
  68563. * Disposes the component and the associated ressources.
  68564. */
  68565. dispose(): void;
  68566. private _pickSpriteButKeepRay;
  68567. private _pointerMove;
  68568. private _pointerDown;
  68569. private _pointerUp;
  68570. }
  68571. }
  68572. declare module BABYLON {
  68573. /** @hidden */
  68574. export var fogFragmentDeclaration: {
  68575. name: string;
  68576. shader: string;
  68577. };
  68578. }
  68579. declare module BABYLON {
  68580. /** @hidden */
  68581. export var fogFragment: {
  68582. name: string;
  68583. shader: string;
  68584. };
  68585. }
  68586. declare module BABYLON {
  68587. /** @hidden */
  68588. export var spritesPixelShader: {
  68589. name: string;
  68590. shader: string;
  68591. };
  68592. }
  68593. declare module BABYLON {
  68594. /** @hidden */
  68595. export var fogVertexDeclaration: {
  68596. name: string;
  68597. shader: string;
  68598. };
  68599. }
  68600. declare module BABYLON {
  68601. /** @hidden */
  68602. export var spritesVertexShader: {
  68603. name: string;
  68604. shader: string;
  68605. };
  68606. }
  68607. declare module BABYLON {
  68608. /**
  68609. * Defines the minimum interface to fullfil in order to be a sprite manager.
  68610. */
  68611. export interface ISpriteManager extends IDisposable {
  68612. /**
  68613. * Restricts the camera to viewing objects with the same layerMask.
  68614. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  68615. */
  68616. layerMask: number;
  68617. /**
  68618. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  68619. */
  68620. isPickable: boolean;
  68621. /**
  68622. * Specifies the rendering group id for this mesh (0 by default)
  68623. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  68624. */
  68625. renderingGroupId: number;
  68626. /**
  68627. * Defines the list of sprites managed by the manager.
  68628. */
  68629. sprites: Array<Sprite>;
  68630. /**
  68631. * Tests the intersection of a sprite with a specific ray.
  68632. * @param ray The ray we are sending to test the collision
  68633. * @param camera The camera space we are sending rays in
  68634. * @param predicate A predicate allowing excluding sprites from the list of object to test
  68635. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  68636. * @returns picking info or null.
  68637. */
  68638. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68639. /**
  68640. * Renders the list of sprites on screen.
  68641. */
  68642. render(): void;
  68643. }
  68644. /**
  68645. * Class used to manage multiple sprites on the same spritesheet
  68646. * @see http://doc.babylonjs.com/babylon101/sprites
  68647. */
  68648. export class SpriteManager implements ISpriteManager {
  68649. /** defines the manager's name */
  68650. name: string;
  68651. /** Gets the list of sprites */
  68652. sprites: Sprite[];
  68653. /** Gets or sets the rendering group id (0 by default) */
  68654. renderingGroupId: number;
  68655. /** Gets or sets camera layer mask */
  68656. layerMask: number;
  68657. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  68658. fogEnabled: boolean;
  68659. /** Gets or sets a boolean indicating if the sprites are pickable */
  68660. isPickable: boolean;
  68661. /** Defines the default width of a cell in the spritesheet */
  68662. cellWidth: number;
  68663. /** Defines the default height of a cell in the spritesheet */
  68664. cellHeight: number;
  68665. /**
  68666. * An event triggered when the manager is disposed.
  68667. */
  68668. onDisposeObservable: Observable<SpriteManager>;
  68669. private _onDisposeObserver;
  68670. /**
  68671. * Callback called when the manager is disposed
  68672. */
  68673. onDispose: () => void;
  68674. private _capacity;
  68675. private _spriteTexture;
  68676. private _epsilon;
  68677. private _scene;
  68678. private _vertexData;
  68679. private _buffer;
  68680. private _vertexBuffers;
  68681. private _indexBuffer;
  68682. private _effectBase;
  68683. private _effectFog;
  68684. /**
  68685. * Gets or sets the spritesheet texture
  68686. */
  68687. texture: Texture;
  68688. /**
  68689. * Creates a new sprite manager
  68690. * @param name defines the manager's name
  68691. * @param imgUrl defines the sprite sheet url
  68692. * @param capacity defines the maximum allowed number of sprites
  68693. * @param cellSize defines the size of a sprite cell
  68694. * @param scene defines the hosting scene
  68695. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  68696. * @param samplingMode defines the smapling mode to use with spritesheet
  68697. */
  68698. constructor(
  68699. /** defines the manager's name */
  68700. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  68701. private _appendSpriteVertex;
  68702. /**
  68703. * Intersects the sprites with a ray
  68704. * @param ray defines the ray to intersect with
  68705. * @param camera defines the current active camera
  68706. * @param predicate defines a predicate used to select candidate sprites
  68707. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  68708. * @returns null if no hit or a PickingInfo
  68709. */
  68710. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  68711. /**
  68712. * Render all child sprites
  68713. */
  68714. render(): void;
  68715. /**
  68716. * Release associated resources
  68717. */
  68718. dispose(): void;
  68719. }
  68720. }
  68721. declare module BABYLON {
  68722. /**
  68723. * Raw texture can help creating a texture directly from an array of data.
  68724. * This can be super useful if you either get the data from an uncompressed source or
  68725. * if you wish to create your texture pixel by pixel.
  68726. */
  68727. export class RawTexture extends Texture {
  68728. /**
  68729. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  68730. */
  68731. format: number;
  68732. private _engine;
  68733. /**
  68734. * Instantiates a new RawTexture.
  68735. * Raw texture can help creating a texture directly from an array of data.
  68736. * This can be super useful if you either get the data from an uncompressed source or
  68737. * if you wish to create your texture pixel by pixel.
  68738. * @param data define the array of data to use to create the texture
  68739. * @param width define the width of the texture
  68740. * @param height define the height of the texture
  68741. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  68742. * @param scene define the scene the texture belongs to
  68743. * @param generateMipMaps define whether mip maps should be generated or not
  68744. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  68745. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  68746. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  68747. */
  68748. constructor(data: ArrayBufferView, width: number, height: number,
  68749. /**
  68750. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  68751. */
  68752. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  68753. /**
  68754. * Updates the texture underlying data.
  68755. * @param data Define the new data of the texture
  68756. */
  68757. update(data: ArrayBufferView): void;
  68758. /**
  68759. * Creates a luminance texture from some data.
  68760. * @param data Define the texture data
  68761. * @param width Define the width of the texture
  68762. * @param height Define the height of the texture
  68763. * @param scene Define the scene the texture belongs to
  68764. * @param generateMipMaps Define whether or not to create mip maps for the texture
  68765. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  68766. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  68767. * @returns the luminance texture
  68768. */
  68769. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  68770. /**
  68771. * Creates a luminance alpha texture from some data.
  68772. * @param data Define the texture data
  68773. * @param width Define the width of the texture
  68774. * @param height Define the height of the texture
  68775. * @param scene Define the scene the texture belongs to
  68776. * @param generateMipMaps Define whether or not to create mip maps for the texture
  68777. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  68778. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  68779. * @returns the luminance alpha texture
  68780. */
  68781. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  68782. /**
  68783. * Creates an alpha texture from some data.
  68784. * @param data Define the texture data
  68785. * @param width Define the width of the texture
  68786. * @param height Define the height of the texture
  68787. * @param scene Define the scene the texture belongs to
  68788. * @param generateMipMaps Define whether or not to create mip maps for the texture
  68789. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  68790. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  68791. * @returns the alpha texture
  68792. */
  68793. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  68794. /**
  68795. * Creates a RGB texture from some data.
  68796. * @param data Define the texture data
  68797. * @param width Define the width of the texture
  68798. * @param height Define the height of the texture
  68799. * @param scene Define the scene the texture belongs to
  68800. * @param generateMipMaps Define whether or not to create mip maps for the texture
  68801. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  68802. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  68803. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  68804. * @returns the RGB alpha texture
  68805. */
  68806. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  68807. /**
  68808. * Creates a RGBA texture from some data.
  68809. * @param data Define the texture data
  68810. * @param width Define the width of the texture
  68811. * @param height Define the height of the texture
  68812. * @param scene Define the scene the texture belongs to
  68813. * @param generateMipMaps Define whether or not to create mip maps for the texture
  68814. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  68815. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  68816. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  68817. * @returns the RGBA texture
  68818. */
  68819. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  68820. /**
  68821. * Creates a R texture from some data.
  68822. * @param data Define the texture data
  68823. * @param width Define the width of the texture
  68824. * @param height Define the height of the texture
  68825. * @param scene Define the scene the texture belongs to
  68826. * @param generateMipMaps Define whether or not to create mip maps for the texture
  68827. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  68828. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  68829. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  68830. * @returns the R texture
  68831. */
  68832. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  68833. }
  68834. }
  68835. declare module BABYLON {
  68836. interface AbstractScene {
  68837. /**
  68838. * The list of layers (background and foreground) of the scene
  68839. */
  68840. layers: Array<Layer>;
  68841. }
  68842. /**
  68843. * Defines the layer scene component responsible to manage any layers
  68844. * in a given scene.
  68845. */
  68846. export class LayerSceneComponent implements ISceneComponent {
  68847. /**
  68848. * The component name helpfull to identify the component in the list of scene components.
  68849. */
  68850. readonly name: string;
  68851. /**
  68852. * The scene the component belongs to.
  68853. */
  68854. scene: Scene;
  68855. private _engine;
  68856. /**
  68857. * Creates a new instance of the component for the given scene
  68858. * @param scene Defines the scene to register the component in
  68859. */
  68860. constructor(scene: Scene);
  68861. /**
  68862. * Registers the component in a given scene
  68863. */
  68864. register(): void;
  68865. /**
  68866. * Rebuilds the elements related to this component in case of
  68867. * context lost for instance.
  68868. */
  68869. rebuild(): void;
  68870. /**
  68871. * Disposes the component and the associated ressources.
  68872. */
  68873. dispose(): void;
  68874. private _draw;
  68875. private _drawCameraPredicate;
  68876. private _drawCameraBackground;
  68877. private _drawCameraForeground;
  68878. private _drawRenderTargetPredicate;
  68879. private _drawRenderTargetBackground;
  68880. private _drawRenderTargetForeground;
  68881. }
  68882. }
  68883. declare module BABYLON {
  68884. /** @hidden */
  68885. export var layerPixelShader: {
  68886. name: string;
  68887. shader: string;
  68888. };
  68889. }
  68890. declare module BABYLON {
  68891. /** @hidden */
  68892. export var layerVertexShader: {
  68893. name: string;
  68894. shader: string;
  68895. };
  68896. }
  68897. declare module BABYLON {
  68898. /**
  68899. * This represents a full screen 2d layer.
  68900. * This can be useful to display a picture in the background of your scene for instance.
  68901. * @see https://www.babylonjs-playground.com/#08A2BS#1
  68902. */
  68903. export class Layer {
  68904. /**
  68905. * Define the name of the layer.
  68906. */
  68907. name: string;
  68908. /**
  68909. * Define the texture the layer should display.
  68910. */
  68911. texture: Nullable<Texture>;
  68912. /**
  68913. * Is the layer in background or foreground.
  68914. */
  68915. isBackground: boolean;
  68916. /**
  68917. * Define the color of the layer (instead of texture).
  68918. */
  68919. color: Color4;
  68920. /**
  68921. * Define the scale of the layer in order to zoom in out of the texture.
  68922. */
  68923. scale: Vector2;
  68924. /**
  68925. * Define an offset for the layer in order to shift the texture.
  68926. */
  68927. offset: Vector2;
  68928. /**
  68929. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  68930. */
  68931. alphaBlendingMode: number;
  68932. /**
  68933. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  68934. * Alpha test will not mix with the background color in case of transparency.
  68935. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  68936. */
  68937. alphaTest: boolean;
  68938. /**
  68939. * Define a mask to restrict the layer to only some of the scene cameras.
  68940. */
  68941. layerMask: number;
  68942. /**
  68943. * Define the list of render target the layer is visible into.
  68944. */
  68945. renderTargetTextures: RenderTargetTexture[];
  68946. /**
  68947. * Define if the layer is only used in renderTarget or if it also
  68948. * renders in the main frame buffer of the canvas.
  68949. */
  68950. renderOnlyInRenderTargetTextures: boolean;
  68951. private _scene;
  68952. private _vertexBuffers;
  68953. private _indexBuffer;
  68954. private _effect;
  68955. private _alphaTestEffect;
  68956. /**
  68957. * An event triggered when the layer is disposed.
  68958. */
  68959. onDisposeObservable: Observable<Layer>;
  68960. private _onDisposeObserver;
  68961. /**
  68962. * Back compatibility with callback before the onDisposeObservable existed.
  68963. * The set callback will be triggered when the layer has been disposed.
  68964. */
  68965. onDispose: () => void;
  68966. /**
  68967. * An event triggered before rendering the scene
  68968. */
  68969. onBeforeRenderObservable: Observable<Layer>;
  68970. private _onBeforeRenderObserver;
  68971. /**
  68972. * Back compatibility with callback before the onBeforeRenderObservable existed.
  68973. * The set callback will be triggered just before rendering the layer.
  68974. */
  68975. onBeforeRender: () => void;
  68976. /**
  68977. * An event triggered after rendering the scene
  68978. */
  68979. onAfterRenderObservable: Observable<Layer>;
  68980. private _onAfterRenderObserver;
  68981. /**
  68982. * Back compatibility with callback before the onAfterRenderObservable existed.
  68983. * The set callback will be triggered just after rendering the layer.
  68984. */
  68985. onAfterRender: () => void;
  68986. /**
  68987. * Instantiates a new layer.
  68988. * This represents a full screen 2d layer.
  68989. * This can be useful to display a picture in the background of your scene for instance.
  68990. * @see https://www.babylonjs-playground.com/#08A2BS#1
  68991. * @param name Define the name of the layer in the scene
  68992. * @param imgUrl Define the url of the texture to display in the layer
  68993. * @param scene Define the scene the layer belongs to
  68994. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  68995. * @param color Defines a color for the layer
  68996. */
  68997. constructor(
  68998. /**
  68999. * Define the name of the layer.
  69000. */
  69001. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  69002. private _createIndexBuffer;
  69003. /** @hidden */
  69004. _rebuild(): void;
  69005. /**
  69006. * Renders the layer in the scene.
  69007. */
  69008. render(): void;
  69009. /**
  69010. * Disposes and releases the associated ressources.
  69011. */
  69012. dispose(): void;
  69013. }
  69014. }
  69015. declare module BABYLON {
  69016. interface AbstractScene {
  69017. /**
  69018. * The list of procedural textures added to the scene
  69019. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69020. */
  69021. proceduralTextures: Array<ProceduralTexture>;
  69022. }
  69023. /**
  69024. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  69025. * in a given scene.
  69026. */
  69027. export class ProceduralTextureSceneComponent implements ISceneComponent {
  69028. /**
  69029. * The component name helpfull to identify the component in the list of scene components.
  69030. */
  69031. readonly name: string;
  69032. /**
  69033. * The scene the component belongs to.
  69034. */
  69035. scene: Scene;
  69036. /**
  69037. * Creates a new instance of the component for the given scene
  69038. * @param scene Defines the scene to register the component in
  69039. */
  69040. constructor(scene: Scene);
  69041. /**
  69042. * Registers the component in a given scene
  69043. */
  69044. register(): void;
  69045. /**
  69046. * Rebuilds the elements related to this component in case of
  69047. * context lost for instance.
  69048. */
  69049. rebuild(): void;
  69050. /**
  69051. * Disposes the component and the associated ressources.
  69052. */
  69053. dispose(): void;
  69054. private _beforeClear;
  69055. }
  69056. }
  69057. declare module BABYLON {
  69058. /** @hidden */
  69059. export var proceduralVertexShader: {
  69060. name: string;
  69061. shader: string;
  69062. };
  69063. }
  69064. declare module BABYLON {
  69065. /**
  69066. * 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.
  69067. * This is the base class of any Procedural texture and contains most of the shareable code.
  69068. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69069. */
  69070. export class ProceduralTexture extends Texture {
  69071. isCube: boolean;
  69072. /**
  69073. * Define if the texture is enabled or not (disabled texture will not render)
  69074. */
  69075. isEnabled: boolean;
  69076. /**
  69077. * Define if the texture must be cleared before rendering (default is true)
  69078. */
  69079. autoClear: boolean;
  69080. /**
  69081. * Callback called when the texture is generated
  69082. */
  69083. onGenerated: () => void;
  69084. /**
  69085. * Event raised when the texture is generated
  69086. */
  69087. onGeneratedObservable: Observable<ProceduralTexture>;
  69088. /** @hidden */
  69089. _generateMipMaps: boolean;
  69090. /** @hidden **/
  69091. _effect: Effect;
  69092. /** @hidden */
  69093. _textures: {
  69094. [key: string]: Texture;
  69095. };
  69096. private _size;
  69097. private _currentRefreshId;
  69098. private _refreshRate;
  69099. private _vertexBuffers;
  69100. private _indexBuffer;
  69101. private _uniforms;
  69102. private _samplers;
  69103. private _fragment;
  69104. private _floats;
  69105. private _ints;
  69106. private _floatsArrays;
  69107. private _colors3;
  69108. private _colors4;
  69109. private _vectors2;
  69110. private _vectors3;
  69111. private _matrices;
  69112. private _fallbackTexture;
  69113. private _fallbackTextureUsed;
  69114. private _engine;
  69115. private _cachedDefines;
  69116. private _contentUpdateId;
  69117. private _contentData;
  69118. /**
  69119. * Instantiates a new procedural texture.
  69120. * 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.
  69121. * This is the base class of any Procedural texture and contains most of the shareable code.
  69122. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  69123. * @param name Define the name of the texture
  69124. * @param size Define the size of the texture to create
  69125. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  69126. * @param scene Define the scene the texture belongs to
  69127. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  69128. * @param generateMipMaps Define if the texture should creates mip maps or not
  69129. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  69130. */
  69131. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  69132. /**
  69133. * The effect that is created when initializing the post process.
  69134. * @returns The created effect corrisponding the the postprocess.
  69135. */
  69136. getEffect(): Effect;
  69137. /**
  69138. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  69139. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  69140. */
  69141. getContent(): Nullable<ArrayBufferView>;
  69142. private _createIndexBuffer;
  69143. /** @hidden */
  69144. _rebuild(): void;
  69145. /**
  69146. * Resets the texture in order to recreate its associated resources.
  69147. * This can be called in case of context loss
  69148. */
  69149. reset(): void;
  69150. protected _getDefines(): string;
  69151. /**
  69152. * Is the texture ready to be used ? (rendered at least once)
  69153. * @returns true if ready, otherwise, false.
  69154. */
  69155. isReady(): boolean;
  69156. /**
  69157. * Resets the refresh counter of the texture and start bak from scratch.
  69158. * Could be useful to regenerate the texture if it is setup to render only once.
  69159. */
  69160. resetRefreshCounter(): void;
  69161. /**
  69162. * Set the fragment shader to use in order to render the texture.
  69163. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  69164. */
  69165. setFragment(fragment: any): void;
  69166. /**
  69167. * Define the refresh rate of the texture or the rendering frequency.
  69168. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  69169. */
  69170. refreshRate: number;
  69171. /** @hidden */
  69172. _shouldRender(): boolean;
  69173. /**
  69174. * Get the size the texture is rendering at.
  69175. * @returns the size (texture is always squared)
  69176. */
  69177. getRenderSize(): number;
  69178. /**
  69179. * Resize the texture to new value.
  69180. * @param size Define the new size the texture should have
  69181. * @param generateMipMaps Define whether the new texture should create mip maps
  69182. */
  69183. resize(size: number, generateMipMaps: boolean): void;
  69184. private _checkUniform;
  69185. /**
  69186. * Set a texture in the shader program used to render.
  69187. * @param name Define the name of the uniform samplers as defined in the shader
  69188. * @param texture Define the texture to bind to this sampler
  69189. * @return the texture itself allowing "fluent" like uniform updates
  69190. */
  69191. setTexture(name: string, texture: Texture): ProceduralTexture;
  69192. /**
  69193. * Set a float in the shader.
  69194. * @param name Define the name of the uniform as defined in the shader
  69195. * @param value Define the value to give to the uniform
  69196. * @return the texture itself allowing "fluent" like uniform updates
  69197. */
  69198. setFloat(name: string, value: number): ProceduralTexture;
  69199. /**
  69200. * Set a int in the shader.
  69201. * @param name Define the name of the uniform as defined in the shader
  69202. * @param value Define the value to give to the uniform
  69203. * @return the texture itself allowing "fluent" like uniform updates
  69204. */
  69205. setInt(name: string, value: number): ProceduralTexture;
  69206. /**
  69207. * Set an array of floats in the shader.
  69208. * @param name Define the name of the uniform as defined in the shader
  69209. * @param value Define the value to give to the uniform
  69210. * @return the texture itself allowing "fluent" like uniform updates
  69211. */
  69212. setFloats(name: string, value: number[]): ProceduralTexture;
  69213. /**
  69214. * Set a vec3 in the shader from a Color3.
  69215. * @param name Define the name of the uniform as defined in the shader
  69216. * @param value Define the value to give to the uniform
  69217. * @return the texture itself allowing "fluent" like uniform updates
  69218. */
  69219. setColor3(name: string, value: Color3): ProceduralTexture;
  69220. /**
  69221. * Set a vec4 in the shader from a Color4.
  69222. * @param name Define the name of the uniform as defined in the shader
  69223. * @param value Define the value to give to the uniform
  69224. * @return the texture itself allowing "fluent" like uniform updates
  69225. */
  69226. setColor4(name: string, value: Color4): ProceduralTexture;
  69227. /**
  69228. * Set a vec2 in the shader from a Vector2.
  69229. * @param name Define the name of the uniform as defined in the shader
  69230. * @param value Define the value to give to the uniform
  69231. * @return the texture itself allowing "fluent" like uniform updates
  69232. */
  69233. setVector2(name: string, value: Vector2): ProceduralTexture;
  69234. /**
  69235. * Set a vec3 in the shader from a Vector3.
  69236. * @param name Define the name of the uniform as defined in the shader
  69237. * @param value Define the value to give to the uniform
  69238. * @return the texture itself allowing "fluent" like uniform updates
  69239. */
  69240. setVector3(name: string, value: Vector3): ProceduralTexture;
  69241. /**
  69242. * Set a mat4 in the shader from a MAtrix.
  69243. * @param name Define the name of the uniform as defined in the shader
  69244. * @param value Define the value to give to the uniform
  69245. * @return the texture itself allowing "fluent" like uniform updates
  69246. */
  69247. setMatrix(name: string, value: Matrix): ProceduralTexture;
  69248. /**
  69249. * Render the texture to its associated render target.
  69250. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  69251. */
  69252. render(useCameraPostProcess?: boolean): void;
  69253. /**
  69254. * Clone the texture.
  69255. * @returns the cloned texture
  69256. */
  69257. clone(): ProceduralTexture;
  69258. /**
  69259. * Dispose the texture and release its asoociated resources.
  69260. */
  69261. dispose(): void;
  69262. }
  69263. }
  69264. declare module BABYLON {
  69265. /**
  69266. * This represents the base class for particle system in Babylon.
  69267. * 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.
  69268. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  69269. * @example https://doc.babylonjs.com/babylon101/particles
  69270. */
  69271. export class BaseParticleSystem {
  69272. /**
  69273. * Source color is added to the destination color without alpha affecting the result
  69274. */
  69275. static BLENDMODE_ONEONE: number;
  69276. /**
  69277. * Blend current color and particle color using particle’s alpha
  69278. */
  69279. static BLENDMODE_STANDARD: number;
  69280. /**
  69281. * Add current color and particle color multiplied by particle’s alpha
  69282. */
  69283. static BLENDMODE_ADD: number;
  69284. /**
  69285. * Multiply current color with particle color
  69286. */
  69287. static BLENDMODE_MULTIPLY: number;
  69288. /**
  69289. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  69290. */
  69291. static BLENDMODE_MULTIPLYADD: number;
  69292. /**
  69293. * List of animations used by the particle system.
  69294. */
  69295. animations: Animation[];
  69296. /**
  69297. * The id of the Particle system.
  69298. */
  69299. id: string;
  69300. /**
  69301. * The friendly name of the Particle system.
  69302. */
  69303. name: string;
  69304. /**
  69305. * The rendering group used by the Particle system to chose when to render.
  69306. */
  69307. renderingGroupId: number;
  69308. /**
  69309. * The emitter represents the Mesh or position we are attaching the particle system to.
  69310. */
  69311. emitter: Nullable<AbstractMesh | Vector3>;
  69312. /**
  69313. * The maximum number of particles to emit per frame
  69314. */
  69315. emitRate: number;
  69316. /**
  69317. * If you want to launch only a few particles at once, that can be done, as well.
  69318. */
  69319. manualEmitCount: number;
  69320. /**
  69321. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  69322. */
  69323. updateSpeed: number;
  69324. /**
  69325. * The amount of time the particle system is running (depends of the overall update speed).
  69326. */
  69327. targetStopDuration: number;
  69328. /**
  69329. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  69330. */
  69331. disposeOnStop: boolean;
  69332. /**
  69333. * Minimum power of emitting particles.
  69334. */
  69335. minEmitPower: number;
  69336. /**
  69337. * Maximum power of emitting particles.
  69338. */
  69339. maxEmitPower: number;
  69340. /**
  69341. * Minimum life time of emitting particles.
  69342. */
  69343. minLifeTime: number;
  69344. /**
  69345. * Maximum life time of emitting particles.
  69346. */
  69347. maxLifeTime: number;
  69348. /**
  69349. * Minimum Size of emitting particles.
  69350. */
  69351. minSize: number;
  69352. /**
  69353. * Maximum Size of emitting particles.
  69354. */
  69355. maxSize: number;
  69356. /**
  69357. * Minimum scale of emitting particles on X axis.
  69358. */
  69359. minScaleX: number;
  69360. /**
  69361. * Maximum scale of emitting particles on X axis.
  69362. */
  69363. maxScaleX: number;
  69364. /**
  69365. * Minimum scale of emitting particles on Y axis.
  69366. */
  69367. minScaleY: number;
  69368. /**
  69369. * Maximum scale of emitting particles on Y axis.
  69370. */
  69371. maxScaleY: number;
  69372. /**
  69373. * Gets or sets the minimal initial rotation in radians.
  69374. */
  69375. minInitialRotation: number;
  69376. /**
  69377. * Gets or sets the maximal initial rotation in radians.
  69378. */
  69379. maxInitialRotation: number;
  69380. /**
  69381. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  69382. */
  69383. minAngularSpeed: number;
  69384. /**
  69385. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  69386. */
  69387. maxAngularSpeed: number;
  69388. /**
  69389. * The texture used to render each particle. (this can be a spritesheet)
  69390. */
  69391. particleTexture: Nullable<Texture>;
  69392. /**
  69393. * The layer mask we are rendering the particles through.
  69394. */
  69395. layerMask: number;
  69396. /**
  69397. * This can help using your own shader to render the particle system.
  69398. * The according effect will be created
  69399. */
  69400. customShader: any;
  69401. /**
  69402. * By default particle system starts as soon as they are created. This prevents the
  69403. * automatic start to happen and let you decide when to start emitting particles.
  69404. */
  69405. preventAutoStart: boolean;
  69406. private _noiseTexture;
  69407. /**
  69408. * Gets or sets a texture used to add random noise to particle positions
  69409. */
  69410. noiseTexture: Nullable<ProceduralTexture>;
  69411. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  69412. noiseStrength: Vector3;
  69413. /**
  69414. * Callback triggered when the particle animation is ending.
  69415. */
  69416. onAnimationEnd: Nullable<() => void>;
  69417. /**
  69418. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  69419. */
  69420. blendMode: number;
  69421. /**
  69422. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  69423. * to override the particles.
  69424. */
  69425. forceDepthWrite: boolean;
  69426. /** 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 */
  69427. preWarmCycles: number;
  69428. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  69429. preWarmStepOffset: number;
  69430. /**
  69431. * 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)
  69432. */
  69433. spriteCellChangeSpeed: number;
  69434. /**
  69435. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  69436. */
  69437. startSpriteCellID: number;
  69438. /**
  69439. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  69440. */
  69441. endSpriteCellID: number;
  69442. /**
  69443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  69444. */
  69445. spriteCellWidth: number;
  69446. /**
  69447. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  69448. */
  69449. spriteCellHeight: number;
  69450. /**
  69451. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  69452. */
  69453. spriteRandomStartCell: boolean;
  69454. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  69455. translationPivot: Vector2;
  69456. /** @hidden */
  69457. protected _isAnimationSheetEnabled: boolean;
  69458. /**
  69459. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  69460. */
  69461. beginAnimationOnStart: boolean;
  69462. /**
  69463. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  69464. */
  69465. beginAnimationFrom: number;
  69466. /**
  69467. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  69468. */
  69469. beginAnimationTo: number;
  69470. /**
  69471. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  69472. */
  69473. beginAnimationLoop: boolean;
  69474. /**
  69475. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  69476. */
  69477. isAnimationSheetEnabled: boolean;
  69478. /**
  69479. * Get hosting scene
  69480. * @returns the scene
  69481. */
  69482. getScene(): Scene;
  69483. /**
  69484. * You can use gravity if you want to give an orientation to your particles.
  69485. */
  69486. gravity: Vector3;
  69487. protected _colorGradients: Nullable<Array<ColorGradient>>;
  69488. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  69489. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  69490. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  69491. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  69492. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  69493. protected _dragGradients: Nullable<Array<FactorGradient>>;
  69494. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  69495. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  69496. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  69497. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  69498. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  69499. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  69500. /**
  69501. * Defines the delay in milliseconds before starting the system (0 by default)
  69502. */
  69503. startDelay: number;
  69504. /**
  69505. * Gets the current list of drag gradients.
  69506. * You must use addDragGradient and removeDragGradient to udpate this list
  69507. * @returns the list of drag gradients
  69508. */
  69509. getDragGradients(): Nullable<Array<FactorGradient>>;
  69510. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  69511. limitVelocityDamping: number;
  69512. /**
  69513. * Gets the current list of limit velocity gradients.
  69514. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  69515. * @returns the list of limit velocity gradients
  69516. */
  69517. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  69518. /**
  69519. * Gets the current list of color gradients.
  69520. * You must use addColorGradient and removeColorGradient to udpate this list
  69521. * @returns the list of color gradients
  69522. */
  69523. getColorGradients(): Nullable<Array<ColorGradient>>;
  69524. /**
  69525. * Gets the current list of size gradients.
  69526. * You must use addSizeGradient and removeSizeGradient to udpate this list
  69527. * @returns the list of size gradients
  69528. */
  69529. getSizeGradients(): Nullable<Array<FactorGradient>>;
  69530. /**
  69531. * Gets the current list of color remap gradients.
  69532. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  69533. * @returns the list of color remap gradients
  69534. */
  69535. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  69536. /**
  69537. * Gets the current list of alpha remap gradients.
  69538. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  69539. * @returns the list of alpha remap gradients
  69540. */
  69541. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  69542. /**
  69543. * Gets the current list of life time gradients.
  69544. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  69545. * @returns the list of life time gradients
  69546. */
  69547. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  69548. /**
  69549. * Gets the current list of angular speed gradients.
  69550. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  69551. * @returns the list of angular speed gradients
  69552. */
  69553. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  69554. /**
  69555. * Gets the current list of velocity gradients.
  69556. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  69557. * @returns the list of velocity gradients
  69558. */
  69559. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  69560. /**
  69561. * Gets the current list of start size gradients.
  69562. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  69563. * @returns the list of start size gradients
  69564. */
  69565. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  69566. /**
  69567. * Gets the current list of emit rate gradients.
  69568. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  69569. * @returns the list of emit rate gradients
  69570. */
  69571. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  69572. /**
  69573. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  69574. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69575. */
  69576. direction1: Vector3;
  69577. /**
  69578. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  69579. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69580. */
  69581. direction2: Vector3;
  69582. /**
  69583. * 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.
  69584. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69585. */
  69586. minEmitBox: Vector3;
  69587. /**
  69588. * 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.
  69589. * This only works when particleEmitterTyps is a BoxParticleEmitter
  69590. */
  69591. maxEmitBox: Vector3;
  69592. /**
  69593. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  69594. */
  69595. color1: Color4;
  69596. /**
  69597. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  69598. */
  69599. color2: Color4;
  69600. /**
  69601. * Color the particle will have at the end of its lifetime
  69602. */
  69603. colorDead: Color4;
  69604. /**
  69605. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  69606. */
  69607. textureMask: Color4;
  69608. /**
  69609. * The particle emitter type defines the emitter used by the particle system.
  69610. * It can be for example box, sphere, or cone...
  69611. */
  69612. particleEmitterType: IParticleEmitterType;
  69613. /** @hidden */
  69614. _isSubEmitter: boolean;
  69615. /**
  69616. * Gets or sets the billboard mode to use when isBillboardBased = true.
  69617. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  69618. */
  69619. billboardMode: number;
  69620. protected _isBillboardBased: boolean;
  69621. /**
  69622. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  69623. */
  69624. isBillboardBased: boolean;
  69625. /**
  69626. * The scene the particle system belongs to.
  69627. */
  69628. protected _scene: Scene;
  69629. /**
  69630. * Local cache of defines for image processing.
  69631. */
  69632. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  69633. /**
  69634. * Default configuration related to image processing available in the standard Material.
  69635. */
  69636. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  69637. /**
  69638. * Gets the image processing configuration used either in this material.
  69639. */
  69640. /**
  69641. * Sets the Default image processing configuration used either in the this material.
  69642. *
  69643. * If sets to null, the scene one is in use.
  69644. */
  69645. imageProcessingConfiguration: ImageProcessingConfiguration;
  69646. /**
  69647. * Attaches a new image processing configuration to the Standard Material.
  69648. * @param configuration
  69649. */
  69650. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  69651. /** @hidden */
  69652. protected _reset(): void;
  69653. /** @hidden */
  69654. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  69655. /**
  69656. * Instantiates a particle system.
  69657. * 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.
  69658. * @param name The name of the particle system
  69659. */
  69660. constructor(name: string);
  69661. /**
  69662. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  69663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  69664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  69665. * @returns the emitter
  69666. */
  69667. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  69668. /**
  69669. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  69670. * @param radius The radius of the hemisphere to emit from
  69671. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  69672. * @returns the emitter
  69673. */
  69674. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  69675. /**
  69676. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  69677. * @param radius The radius of the sphere to emit from
  69678. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  69679. * @returns the emitter
  69680. */
  69681. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  69682. /**
  69683. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  69684. * @param radius The radius of the sphere to emit from
  69685. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  69686. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  69687. * @returns the emitter
  69688. */
  69689. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  69690. /**
  69691. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  69692. * @param radius The radius of the emission cylinder
  69693. * @param height The height of the emission cylinder
  69694. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  69695. * @param directionRandomizer How much to randomize the particle direction [0-1]
  69696. * @returns the emitter
  69697. */
  69698. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  69699. /**
  69700. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  69701. * @param radius The radius of the cylinder to emit from
  69702. * @param height The height of the emission cylinder
  69703. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  69704. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  69705. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  69706. * @returns the emitter
  69707. */
  69708. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  69709. /**
  69710. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  69711. * @param radius The radius of the cone to emit from
  69712. * @param angle The base angle of the cone
  69713. * @returns the emitter
  69714. */
  69715. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  69716. /**
  69717. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  69718. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  69719. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  69720. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  69721. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  69722. * @returns the emitter
  69723. */
  69724. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  69725. }
  69726. }
  69727. declare module BABYLON {
  69728. /**
  69729. * Type of sub emitter
  69730. */
  69731. export enum SubEmitterType {
  69732. /**
  69733. * Attached to the particle over it's lifetime
  69734. */
  69735. ATTACHED = 0,
  69736. /**
  69737. * Created when the particle dies
  69738. */
  69739. END = 1
  69740. }
  69741. /**
  69742. * Sub emitter class used to emit particles from an existing particle
  69743. */
  69744. export class SubEmitter {
  69745. /**
  69746. * the particle system to be used by the sub emitter
  69747. */
  69748. particleSystem: ParticleSystem;
  69749. /**
  69750. * Type of the submitter (Default: END)
  69751. */
  69752. type: SubEmitterType;
  69753. /**
  69754. * 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)
  69755. * Note: This only is supported when using an emitter of type Mesh
  69756. */
  69757. inheritDirection: boolean;
  69758. /**
  69759. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  69760. */
  69761. inheritedVelocityAmount: number;
  69762. /**
  69763. * Creates a sub emitter
  69764. * @param particleSystem the particle system to be used by the sub emitter
  69765. */
  69766. constructor(
  69767. /**
  69768. * the particle system to be used by the sub emitter
  69769. */
  69770. particleSystem: ParticleSystem);
  69771. /**
  69772. * Clones the sub emitter
  69773. * @returns the cloned sub emitter
  69774. */
  69775. clone(): SubEmitter;
  69776. /**
  69777. * Serialize current object to a JSON object
  69778. * @returns the serialized object
  69779. */
  69780. serialize(): any;
  69781. /** @hidden */
  69782. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  69783. /**
  69784. * Creates a new SubEmitter from a serialized JSON version
  69785. * @param serializationObject defines the JSON object to read from
  69786. * @param scene defines the hosting scene
  69787. * @param rootUrl defines the rootUrl for data loading
  69788. * @returns a new SubEmitter
  69789. */
  69790. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  69791. /** Release associated resources */
  69792. dispose(): void;
  69793. }
  69794. }
  69795. declare module BABYLON {
  69796. /** @hidden */
  69797. export var clipPlaneFragmentDeclaration: {
  69798. name: string;
  69799. shader: string;
  69800. };
  69801. }
  69802. declare module BABYLON {
  69803. /** @hidden */
  69804. export var imageProcessingDeclaration: {
  69805. name: string;
  69806. shader: string;
  69807. };
  69808. }
  69809. declare module BABYLON {
  69810. /** @hidden */
  69811. export var imageProcessingFunctions: {
  69812. name: string;
  69813. shader: string;
  69814. };
  69815. }
  69816. declare module BABYLON {
  69817. /** @hidden */
  69818. export var clipPlaneFragment: {
  69819. name: string;
  69820. shader: string;
  69821. };
  69822. }
  69823. declare module BABYLON {
  69824. /** @hidden */
  69825. export var particlesPixelShader: {
  69826. name: string;
  69827. shader: string;
  69828. };
  69829. }
  69830. declare module BABYLON {
  69831. /** @hidden */
  69832. export var clipPlaneVertexDeclaration: {
  69833. name: string;
  69834. shader: string;
  69835. };
  69836. }
  69837. declare module BABYLON {
  69838. /** @hidden */
  69839. export var clipPlaneVertex: {
  69840. name: string;
  69841. shader: string;
  69842. };
  69843. }
  69844. declare module BABYLON {
  69845. /** @hidden */
  69846. export var particlesVertexShader: {
  69847. name: string;
  69848. shader: string;
  69849. };
  69850. }
  69851. declare module BABYLON {
  69852. /**
  69853. * This represents a particle system in Babylon.
  69854. * 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.
  69855. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  69856. * @example https://doc.babylonjs.com/babylon101/particles
  69857. */
  69858. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  69859. /**
  69860. * Billboard mode will only apply to Y axis
  69861. */
  69862. static readonly BILLBOARDMODE_Y: number;
  69863. /**
  69864. * Billboard mode will apply to all axes
  69865. */
  69866. static readonly BILLBOARDMODE_ALL: number;
  69867. /**
  69868. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  69869. */
  69870. static readonly BILLBOARDMODE_STRETCHED: number;
  69871. /**
  69872. * This function can be defined to provide custom update for active particles.
  69873. * This function will be called instead of regular update (age, position, color, etc.).
  69874. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  69875. */
  69876. updateFunction: (particles: Particle[]) => void;
  69877. private _emitterWorldMatrix;
  69878. /**
  69879. * This function can be defined to specify initial direction for every new particle.
  69880. * It by default use the emitterType defined function
  69881. */
  69882. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  69883. /**
  69884. * This function can be defined to specify initial position for every new particle.
  69885. * It by default use the emitterType defined function
  69886. */
  69887. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  69888. /**
  69889. * @hidden
  69890. */
  69891. _inheritedVelocityOffset: Vector3;
  69892. /**
  69893. * An event triggered when the system is disposed
  69894. */
  69895. onDisposeObservable: Observable<ParticleSystem>;
  69896. private _onDisposeObserver;
  69897. /**
  69898. * Sets a callback that will be triggered when the system is disposed
  69899. */
  69900. onDispose: () => void;
  69901. private _particles;
  69902. private _epsilon;
  69903. private _capacity;
  69904. private _stockParticles;
  69905. private _newPartsExcess;
  69906. private _vertexData;
  69907. private _vertexBuffer;
  69908. private _vertexBuffers;
  69909. private _spriteBuffer;
  69910. private _indexBuffer;
  69911. private _effect;
  69912. private _customEffect;
  69913. private _cachedDefines;
  69914. private _scaledColorStep;
  69915. private _colorDiff;
  69916. private _scaledDirection;
  69917. private _scaledGravity;
  69918. private _currentRenderId;
  69919. private _alive;
  69920. private _useInstancing;
  69921. private _started;
  69922. private _stopped;
  69923. private _actualFrame;
  69924. private _scaledUpdateSpeed;
  69925. private _vertexBufferSize;
  69926. /** @hidden */
  69927. _currentEmitRateGradient: Nullable<FactorGradient>;
  69928. /** @hidden */
  69929. _currentEmitRate1: number;
  69930. /** @hidden */
  69931. _currentEmitRate2: number;
  69932. /** @hidden */
  69933. _currentStartSizeGradient: Nullable<FactorGradient>;
  69934. /** @hidden */
  69935. _currentStartSize1: number;
  69936. /** @hidden */
  69937. _currentStartSize2: number;
  69938. private readonly _rawTextureWidth;
  69939. private _rampGradientsTexture;
  69940. private _useRampGradients;
  69941. /** Gets or sets a boolean indicating that ramp gradients must be used
  69942. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  69943. */
  69944. useRampGradients: boolean;
  69945. /**
  69946. * 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.
  69947. * 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: [])
  69948. */
  69949. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  69950. private _subEmitters;
  69951. /**
  69952. * @hidden
  69953. * If the particle systems emitter should be disposed when the particle system is disposed
  69954. */
  69955. _disposeEmitterOnDispose: boolean;
  69956. /**
  69957. * The current active Sub-systems, this property is used by the root particle system only.
  69958. */
  69959. activeSubSystems: Array<ParticleSystem>;
  69960. private _rootParticleSystem;
  69961. /**
  69962. * Gets the current list of active particles
  69963. */
  69964. readonly particles: Particle[];
  69965. /**
  69966. * Returns the string "ParticleSystem"
  69967. * @returns a string containing the class name
  69968. */
  69969. getClassName(): string;
  69970. /**
  69971. * Instantiates a particle system.
  69972. * 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.
  69973. * @param name The name of the particle system
  69974. * @param capacity The max number of particles alive at the same time
  69975. * @param scene The scene the particle system belongs to
  69976. * @param customEffect a custom effect used to change the way particles are rendered by default
  69977. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  69978. * @param epsilon Offset used to render the particles
  69979. */
  69980. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  69981. private _addFactorGradient;
  69982. private _removeFactorGradient;
  69983. /**
  69984. * Adds a new life time gradient
  69985. * @param gradient defines the gradient to use (between 0 and 1)
  69986. * @param factor defines the life time factor to affect to the specified gradient
  69987. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  69988. * @returns the current particle system
  69989. */
  69990. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  69991. /**
  69992. * Remove a specific life time gradient
  69993. * @param gradient defines the gradient to remove
  69994. * @returns the current particle system
  69995. */
  69996. removeLifeTimeGradient(gradient: number): IParticleSystem;
  69997. /**
  69998. * Adds a new size gradient
  69999. * @param gradient defines the gradient to use (between 0 and 1)
  70000. * @param factor defines the size factor to affect to the specified gradient
  70001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70002. * @returns the current particle system
  70003. */
  70004. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70005. /**
  70006. * Remove a specific size gradient
  70007. * @param gradient defines the gradient to remove
  70008. * @returns the current particle system
  70009. */
  70010. removeSizeGradient(gradient: number): IParticleSystem;
  70011. /**
  70012. * Adds a new color remap gradient
  70013. * @param gradient defines the gradient to use (between 0 and 1)
  70014. * @param min defines the color remap minimal range
  70015. * @param max defines the color remap maximal range
  70016. * @returns the current particle system
  70017. */
  70018. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70019. /**
  70020. * Remove a specific color remap gradient
  70021. * @param gradient defines the gradient to remove
  70022. * @returns the current particle system
  70023. */
  70024. removeColorRemapGradient(gradient: number): IParticleSystem;
  70025. /**
  70026. * Adds a new alpha remap gradient
  70027. * @param gradient defines the gradient to use (between 0 and 1)
  70028. * @param min defines the alpha remap minimal range
  70029. * @param max defines the alpha remap maximal range
  70030. * @returns the current particle system
  70031. */
  70032. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70033. /**
  70034. * Remove a specific alpha remap gradient
  70035. * @param gradient defines the gradient to remove
  70036. * @returns the current particle system
  70037. */
  70038. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  70039. /**
  70040. * Adds a new angular speed gradient
  70041. * @param gradient defines the gradient to use (between 0 and 1)
  70042. * @param factor defines the angular speed to affect to the specified gradient
  70043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70044. * @returns the current particle system
  70045. */
  70046. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70047. /**
  70048. * Remove a specific angular speed gradient
  70049. * @param gradient defines the gradient to remove
  70050. * @returns the current particle system
  70051. */
  70052. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  70053. /**
  70054. * Adds a new velocity gradient
  70055. * @param gradient defines the gradient to use (between 0 and 1)
  70056. * @param factor defines the velocity to affect to the specified gradient
  70057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70058. * @returns the current particle system
  70059. */
  70060. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70061. /**
  70062. * Remove a specific velocity gradient
  70063. * @param gradient defines the gradient to remove
  70064. * @returns the current particle system
  70065. */
  70066. removeVelocityGradient(gradient: number): IParticleSystem;
  70067. /**
  70068. * Adds a new limit velocity gradient
  70069. * @param gradient defines the gradient to use (between 0 and 1)
  70070. * @param factor defines the limit velocity value to affect to the specified gradient
  70071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70072. * @returns the current particle system
  70073. */
  70074. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70075. /**
  70076. * Remove a specific limit velocity gradient
  70077. * @param gradient defines the gradient to remove
  70078. * @returns the current particle system
  70079. */
  70080. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  70081. /**
  70082. * Adds a new drag gradient
  70083. * @param gradient defines the gradient to use (between 0 and 1)
  70084. * @param factor defines the drag value to affect to the specified gradient
  70085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70086. * @returns the current particle system
  70087. */
  70088. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70089. /**
  70090. * Remove a specific drag gradient
  70091. * @param gradient defines the gradient to remove
  70092. * @returns the current particle system
  70093. */
  70094. removeDragGradient(gradient: number): IParticleSystem;
  70095. /**
  70096. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  70097. * @param gradient defines the gradient to use (between 0 and 1)
  70098. * @param factor defines the emit rate value to affect to the specified gradient
  70099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70100. * @returns the current particle system
  70101. */
  70102. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70103. /**
  70104. * Remove a specific emit rate gradient
  70105. * @param gradient defines the gradient to remove
  70106. * @returns the current particle system
  70107. */
  70108. removeEmitRateGradient(gradient: number): IParticleSystem;
  70109. /**
  70110. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  70111. * @param gradient defines the gradient to use (between 0 and 1)
  70112. * @param factor defines the start size value to affect to the specified gradient
  70113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70114. * @returns the current particle system
  70115. */
  70116. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70117. /**
  70118. * Remove a specific start size gradient
  70119. * @param gradient defines the gradient to remove
  70120. * @returns the current particle system
  70121. */
  70122. removeStartSizeGradient(gradient: number): IParticleSystem;
  70123. private _createRampGradientTexture;
  70124. /**
  70125. * Gets the current list of ramp gradients.
  70126. * You must use addRampGradient and removeRampGradient to udpate this list
  70127. * @returns the list of ramp gradients
  70128. */
  70129. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70130. /**
  70131. * Adds a new ramp gradient used to remap particle colors
  70132. * @param gradient defines the gradient to use (between 0 and 1)
  70133. * @param color defines the color to affect to the specified gradient
  70134. * @returns the current particle system
  70135. */
  70136. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  70137. /**
  70138. * Remove a specific ramp gradient
  70139. * @param gradient defines the gradient to remove
  70140. * @returns the current particle system
  70141. */
  70142. removeRampGradient(gradient: number): ParticleSystem;
  70143. /**
  70144. * Adds a new color gradient
  70145. * @param gradient defines the gradient to use (between 0 and 1)
  70146. * @param color1 defines the color to affect to the specified gradient
  70147. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70148. * @returns this particle system
  70149. */
  70150. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  70151. /**
  70152. * Remove a specific color gradient
  70153. * @param gradient defines the gradient to remove
  70154. * @returns this particle system
  70155. */
  70156. removeColorGradient(gradient: number): IParticleSystem;
  70157. private _fetchR;
  70158. protected _reset(): void;
  70159. private _resetEffect;
  70160. private _createVertexBuffers;
  70161. private _createIndexBuffer;
  70162. /**
  70163. * Gets the maximum number of particles active at the same time.
  70164. * @returns The max number of active particles.
  70165. */
  70166. getCapacity(): number;
  70167. /**
  70168. * Gets whether there are still active particles in the system.
  70169. * @returns True if it is alive, otherwise false.
  70170. */
  70171. isAlive(): boolean;
  70172. /**
  70173. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70174. * @returns True if it has been started, otherwise false.
  70175. */
  70176. isStarted(): boolean;
  70177. private _prepareSubEmitterInternalArray;
  70178. /**
  70179. * Starts the particle system and begins to emit
  70180. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70181. */
  70182. start(delay?: number): void;
  70183. /**
  70184. * Stops the particle system.
  70185. * @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.
  70186. */
  70187. stop(stopSubEmitters?: boolean): void;
  70188. /**
  70189. * Remove all active particles
  70190. */
  70191. reset(): void;
  70192. /**
  70193. * @hidden (for internal use only)
  70194. */
  70195. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  70196. /**
  70197. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  70198. * Its lifetime will start back at 0.
  70199. */
  70200. recycleParticle: (particle: Particle) => void;
  70201. private _stopSubEmitters;
  70202. private _createParticle;
  70203. private _removeFromRoot;
  70204. private _emitFromParticle;
  70205. private _update;
  70206. /** @hidden */
  70207. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  70208. /** @hidden */
  70209. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  70210. /** @hidden */
  70211. private _getEffect;
  70212. /**
  70213. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70214. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  70215. */
  70216. animate(preWarmOnly?: boolean): void;
  70217. private _appendParticleVertices;
  70218. /**
  70219. * Rebuilds the particle system.
  70220. */
  70221. rebuild(): void;
  70222. /**
  70223. * Is this system ready to be used/rendered
  70224. * @return true if the system is ready
  70225. */
  70226. isReady(): boolean;
  70227. private _render;
  70228. /**
  70229. * Renders the particle system in its current state.
  70230. * @returns the current number of particles
  70231. */
  70232. render(): number;
  70233. /**
  70234. * Disposes the particle system and free the associated resources
  70235. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70236. */
  70237. dispose(disposeTexture?: boolean): void;
  70238. /**
  70239. * Clones the particle system.
  70240. * @param name The name of the cloned object
  70241. * @param newEmitter The new emitter to use
  70242. * @returns the cloned particle system
  70243. */
  70244. clone(name: string, newEmitter: any): ParticleSystem;
  70245. /**
  70246. * Serializes the particle system to a JSON object.
  70247. * @returns the JSON object
  70248. */
  70249. serialize(): any;
  70250. /** @hidden */
  70251. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  70252. /** @hidden */
  70253. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  70254. /**
  70255. * Parses a JSON object to create a particle system.
  70256. * @param parsedParticleSystem The JSON object to parse
  70257. * @param scene The scene to create the particle system in
  70258. * @param rootUrl The root url to use to load external dependencies like texture
  70259. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70260. * @returns the Parsed particle system
  70261. */
  70262. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  70263. }
  70264. }
  70265. declare module BABYLON {
  70266. /**
  70267. * A particle represents one of the element emitted by a particle system.
  70268. * This is mainly define by its coordinates, direction, velocity and age.
  70269. */
  70270. export class Particle {
  70271. /**
  70272. * The particle system the particle belongs to.
  70273. */
  70274. particleSystem: ParticleSystem;
  70275. private static _Count;
  70276. /**
  70277. * Unique ID of the particle
  70278. */
  70279. id: number;
  70280. /**
  70281. * The world position of the particle in the scene.
  70282. */
  70283. position: Vector3;
  70284. /**
  70285. * The world direction of the particle in the scene.
  70286. */
  70287. direction: Vector3;
  70288. /**
  70289. * The color of the particle.
  70290. */
  70291. color: Color4;
  70292. /**
  70293. * The color change of the particle per step.
  70294. */
  70295. colorStep: Color4;
  70296. /**
  70297. * Defines how long will the life of the particle be.
  70298. */
  70299. lifeTime: number;
  70300. /**
  70301. * The current age of the particle.
  70302. */
  70303. age: number;
  70304. /**
  70305. * The current size of the particle.
  70306. */
  70307. size: number;
  70308. /**
  70309. * The current scale of the particle.
  70310. */
  70311. scale: Vector2;
  70312. /**
  70313. * The current angle of the particle.
  70314. */
  70315. angle: number;
  70316. /**
  70317. * Defines how fast is the angle changing.
  70318. */
  70319. angularSpeed: number;
  70320. /**
  70321. * Defines the cell index used by the particle to be rendered from a sprite.
  70322. */
  70323. cellIndex: number;
  70324. /**
  70325. * The information required to support color remapping
  70326. */
  70327. remapData: Vector4;
  70328. /** @hidden */
  70329. _randomCellOffset?: number;
  70330. /** @hidden */
  70331. _initialDirection: Nullable<Vector3>;
  70332. /** @hidden */
  70333. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  70334. /** @hidden */
  70335. _initialStartSpriteCellID: number;
  70336. /** @hidden */
  70337. _initialEndSpriteCellID: number;
  70338. /** @hidden */
  70339. _currentColorGradient: Nullable<ColorGradient>;
  70340. /** @hidden */
  70341. _currentColor1: Color4;
  70342. /** @hidden */
  70343. _currentColor2: Color4;
  70344. /** @hidden */
  70345. _currentSizeGradient: Nullable<FactorGradient>;
  70346. /** @hidden */
  70347. _currentSize1: number;
  70348. /** @hidden */
  70349. _currentSize2: number;
  70350. /** @hidden */
  70351. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  70352. /** @hidden */
  70353. _currentAngularSpeed1: number;
  70354. /** @hidden */
  70355. _currentAngularSpeed2: number;
  70356. /** @hidden */
  70357. _currentVelocityGradient: Nullable<FactorGradient>;
  70358. /** @hidden */
  70359. _currentVelocity1: number;
  70360. /** @hidden */
  70361. _currentVelocity2: number;
  70362. /** @hidden */
  70363. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  70364. /** @hidden */
  70365. _currentLimitVelocity1: number;
  70366. /** @hidden */
  70367. _currentLimitVelocity2: number;
  70368. /** @hidden */
  70369. _currentDragGradient: Nullable<FactorGradient>;
  70370. /** @hidden */
  70371. _currentDrag1: number;
  70372. /** @hidden */
  70373. _currentDrag2: number;
  70374. /** @hidden */
  70375. _randomNoiseCoordinates1: Vector3;
  70376. /** @hidden */
  70377. _randomNoiseCoordinates2: Vector3;
  70378. /**
  70379. * Creates a new instance Particle
  70380. * @param particleSystem the particle system the particle belongs to
  70381. */
  70382. constructor(
  70383. /**
  70384. * The particle system the particle belongs to.
  70385. */
  70386. particleSystem: ParticleSystem);
  70387. private updateCellInfoFromSystem;
  70388. /**
  70389. * Defines how the sprite cell index is updated for the particle
  70390. */
  70391. updateCellIndex(): void;
  70392. /** @hidden */
  70393. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  70394. /** @hidden */
  70395. _inheritParticleInfoToSubEmitters(): void;
  70396. /** @hidden */
  70397. _reset(): void;
  70398. /**
  70399. * Copy the properties of particle to another one.
  70400. * @param other the particle to copy the information to.
  70401. */
  70402. copyTo(other: Particle): void;
  70403. }
  70404. }
  70405. declare module BABYLON {
  70406. /**
  70407. * Particle emitter represents a volume emitting particles.
  70408. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  70409. */
  70410. export interface IParticleEmitterType {
  70411. /**
  70412. * Called by the particle System when the direction is computed for the created particle.
  70413. * @param worldMatrix is the world matrix of the particle system
  70414. * @param directionToUpdate is the direction vector to update with the result
  70415. * @param particle is the particle we are computed the direction for
  70416. */
  70417. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70418. /**
  70419. * Called by the particle System when the position is computed for the created particle.
  70420. * @param worldMatrix is the world matrix of the particle system
  70421. * @param positionToUpdate is the position vector to update with the result
  70422. * @param particle is the particle we are computed the position for
  70423. */
  70424. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70425. /**
  70426. * Clones the current emitter and returns a copy of it
  70427. * @returns the new emitter
  70428. */
  70429. clone(): IParticleEmitterType;
  70430. /**
  70431. * Called by the GPUParticleSystem to setup the update shader
  70432. * @param effect defines the update shader
  70433. */
  70434. applyToShader(effect: Effect): void;
  70435. /**
  70436. * Returns a string to use to update the GPU particles update shader
  70437. * @returns the effect defines string
  70438. */
  70439. getEffectDefines(): string;
  70440. /**
  70441. * Returns a string representing the class name
  70442. * @returns a string containing the class name
  70443. */
  70444. getClassName(): string;
  70445. /**
  70446. * Serializes the particle system to a JSON object.
  70447. * @returns the JSON object
  70448. */
  70449. serialize(): any;
  70450. /**
  70451. * Parse properties from a JSON object
  70452. * @param serializationObject defines the JSON object
  70453. */
  70454. parse(serializationObject: any): void;
  70455. }
  70456. }
  70457. declare module BABYLON {
  70458. /**
  70459. * Particle emitter emitting particles from the inside of a box.
  70460. * It emits the particles randomly between 2 given directions.
  70461. */
  70462. export class BoxParticleEmitter implements IParticleEmitterType {
  70463. /**
  70464. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70465. */
  70466. direction1: Vector3;
  70467. /**
  70468. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70469. */
  70470. direction2: Vector3;
  70471. /**
  70472. * 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.
  70473. */
  70474. minEmitBox: Vector3;
  70475. /**
  70476. * 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.
  70477. */
  70478. maxEmitBox: Vector3;
  70479. /**
  70480. * Creates a new instance BoxParticleEmitter
  70481. */
  70482. constructor();
  70483. /**
  70484. * Called by the particle System when the direction is computed for the created particle.
  70485. * @param worldMatrix is the world matrix of the particle system
  70486. * @param directionToUpdate is the direction vector to update with the result
  70487. * @param particle is the particle we are computed the direction for
  70488. */
  70489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70490. /**
  70491. * Called by the particle System when the position is computed for the created particle.
  70492. * @param worldMatrix is the world matrix of the particle system
  70493. * @param positionToUpdate is the position vector to update with the result
  70494. * @param particle is the particle we are computed the position for
  70495. */
  70496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70497. /**
  70498. * Clones the current emitter and returns a copy of it
  70499. * @returns the new emitter
  70500. */
  70501. clone(): BoxParticleEmitter;
  70502. /**
  70503. * Called by the GPUParticleSystem to setup the update shader
  70504. * @param effect defines the update shader
  70505. */
  70506. applyToShader(effect: Effect): void;
  70507. /**
  70508. * Returns a string to use to update the GPU particles update shader
  70509. * @returns a string containng the defines string
  70510. */
  70511. getEffectDefines(): string;
  70512. /**
  70513. * Returns the string "BoxParticleEmitter"
  70514. * @returns a string containing the class name
  70515. */
  70516. getClassName(): string;
  70517. /**
  70518. * Serializes the particle system to a JSON object.
  70519. * @returns the JSON object
  70520. */
  70521. serialize(): any;
  70522. /**
  70523. * Parse properties from a JSON object
  70524. * @param serializationObject defines the JSON object
  70525. */
  70526. parse(serializationObject: any): void;
  70527. }
  70528. }
  70529. declare module BABYLON {
  70530. /**
  70531. * Particle emitter emitting particles from the inside of a cone.
  70532. * It emits the particles alongside the cone volume from the base to the particle.
  70533. * The emission direction might be randomized.
  70534. */
  70535. export class ConeParticleEmitter implements IParticleEmitterType {
  70536. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  70537. directionRandomizer: number;
  70538. private _radius;
  70539. private _angle;
  70540. private _height;
  70541. /**
  70542. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  70543. */
  70544. radiusRange: number;
  70545. /**
  70546. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  70547. */
  70548. heightRange: number;
  70549. /**
  70550. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  70551. */
  70552. emitFromSpawnPointOnly: boolean;
  70553. /**
  70554. * Gets or sets the radius of the emission cone
  70555. */
  70556. radius: number;
  70557. /**
  70558. * Gets or sets the angle of the emission cone
  70559. */
  70560. angle: number;
  70561. private _buildHeight;
  70562. /**
  70563. * Creates a new instance ConeParticleEmitter
  70564. * @param radius the radius of the emission cone (1 by default)
  70565. * @param angle the cone base angle (PI by default)
  70566. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  70567. */
  70568. constructor(radius?: number, angle?: number,
  70569. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  70570. directionRandomizer?: number);
  70571. /**
  70572. * Called by the particle System when the direction is computed for the created particle.
  70573. * @param worldMatrix is the world matrix of the particle system
  70574. * @param directionToUpdate is the direction vector to update with the result
  70575. * @param particle is the particle we are computed the direction for
  70576. */
  70577. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70578. /**
  70579. * Called by the particle System when the position is computed for the created particle.
  70580. * @param worldMatrix is the world matrix of the particle system
  70581. * @param positionToUpdate is the position vector to update with the result
  70582. * @param particle is the particle we are computed the position for
  70583. */
  70584. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70585. /**
  70586. * Clones the current emitter and returns a copy of it
  70587. * @returns the new emitter
  70588. */
  70589. clone(): ConeParticleEmitter;
  70590. /**
  70591. * Called by the GPUParticleSystem to setup the update shader
  70592. * @param effect defines the update shader
  70593. */
  70594. applyToShader(effect: Effect): void;
  70595. /**
  70596. * Returns a string to use to update the GPU particles update shader
  70597. * @returns a string containng the defines string
  70598. */
  70599. getEffectDefines(): string;
  70600. /**
  70601. * Returns the string "ConeParticleEmitter"
  70602. * @returns a string containing the class name
  70603. */
  70604. getClassName(): string;
  70605. /**
  70606. * Serializes the particle system to a JSON object.
  70607. * @returns the JSON object
  70608. */
  70609. serialize(): any;
  70610. /**
  70611. * Parse properties from a JSON object
  70612. * @param serializationObject defines the JSON object
  70613. */
  70614. parse(serializationObject: any): void;
  70615. }
  70616. }
  70617. declare module BABYLON {
  70618. /**
  70619. * Particle emitter emitting particles from the inside of a cylinder.
  70620. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  70621. */
  70622. export class CylinderParticleEmitter implements IParticleEmitterType {
  70623. /**
  70624. * The radius of the emission cylinder.
  70625. */
  70626. radius: number;
  70627. /**
  70628. * The height of the emission cylinder.
  70629. */
  70630. height: number;
  70631. /**
  70632. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70633. */
  70634. radiusRange: number;
  70635. /**
  70636. * How much to randomize the particle direction [0-1].
  70637. */
  70638. directionRandomizer: number;
  70639. /**
  70640. * Creates a new instance CylinderParticleEmitter
  70641. * @param radius the radius of the emission cylinder (1 by default)
  70642. * @param height the height of the emission cylinder (1 by default)
  70643. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70644. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  70645. */
  70646. constructor(
  70647. /**
  70648. * The radius of the emission cylinder.
  70649. */
  70650. radius?: number,
  70651. /**
  70652. * The height of the emission cylinder.
  70653. */
  70654. height?: number,
  70655. /**
  70656. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70657. */
  70658. radiusRange?: number,
  70659. /**
  70660. * How much to randomize the particle direction [0-1].
  70661. */
  70662. directionRandomizer?: number);
  70663. /**
  70664. * Called by the particle System when the direction is computed for the created particle.
  70665. * @param worldMatrix is the world matrix of the particle system
  70666. * @param directionToUpdate is the direction vector to update with the result
  70667. * @param particle is the particle we are computed the direction for
  70668. */
  70669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70670. /**
  70671. * Called by the particle System when the position is computed for the created particle.
  70672. * @param worldMatrix is the world matrix of the particle system
  70673. * @param positionToUpdate is the position vector to update with the result
  70674. * @param particle is the particle we are computed the position for
  70675. */
  70676. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70677. /**
  70678. * Clones the current emitter and returns a copy of it
  70679. * @returns the new emitter
  70680. */
  70681. clone(): CylinderParticleEmitter;
  70682. /**
  70683. * Called by the GPUParticleSystem to setup the update shader
  70684. * @param effect defines the update shader
  70685. */
  70686. applyToShader(effect: Effect): void;
  70687. /**
  70688. * Returns a string to use to update the GPU particles update shader
  70689. * @returns a string containng the defines string
  70690. */
  70691. getEffectDefines(): string;
  70692. /**
  70693. * Returns the string "CylinderParticleEmitter"
  70694. * @returns a string containing the class name
  70695. */
  70696. getClassName(): string;
  70697. /**
  70698. * Serializes the particle system to a JSON object.
  70699. * @returns the JSON object
  70700. */
  70701. serialize(): any;
  70702. /**
  70703. * Parse properties from a JSON object
  70704. * @param serializationObject defines the JSON object
  70705. */
  70706. parse(serializationObject: any): void;
  70707. }
  70708. /**
  70709. * Particle emitter emitting particles from the inside of a cylinder.
  70710. * It emits the particles randomly between two vectors.
  70711. */
  70712. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  70713. /**
  70714. * The min limit of the emission direction.
  70715. */
  70716. direction1: Vector3;
  70717. /**
  70718. * The max limit of the emission direction.
  70719. */
  70720. direction2: Vector3;
  70721. /**
  70722. * Creates a new instance CylinderDirectedParticleEmitter
  70723. * @param radius the radius of the emission cylinder (1 by default)
  70724. * @param height the height of the emission cylinder (1 by default)
  70725. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70726. * @param direction1 the min limit of the emission direction (up vector by default)
  70727. * @param direction2 the max limit of the emission direction (up vector by default)
  70728. */
  70729. constructor(radius?: number, height?: number, radiusRange?: number,
  70730. /**
  70731. * The min limit of the emission direction.
  70732. */
  70733. direction1?: Vector3,
  70734. /**
  70735. * The max limit of the emission direction.
  70736. */
  70737. direction2?: Vector3);
  70738. /**
  70739. * Called by the particle System when the direction is computed for the created particle.
  70740. * @param worldMatrix is the world matrix of the particle system
  70741. * @param directionToUpdate is the direction vector to update with the result
  70742. * @param particle is the particle we are computed the direction for
  70743. */
  70744. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70745. /**
  70746. * Clones the current emitter and returns a copy of it
  70747. * @returns the new emitter
  70748. */
  70749. clone(): CylinderDirectedParticleEmitter;
  70750. /**
  70751. * Called by the GPUParticleSystem to setup the update shader
  70752. * @param effect defines the update shader
  70753. */
  70754. applyToShader(effect: Effect): void;
  70755. /**
  70756. * Returns a string to use to update the GPU particles update shader
  70757. * @returns a string containng the defines string
  70758. */
  70759. getEffectDefines(): string;
  70760. /**
  70761. * Returns the string "CylinderDirectedParticleEmitter"
  70762. * @returns a string containing the class name
  70763. */
  70764. getClassName(): string;
  70765. /**
  70766. * Serializes the particle system to a JSON object.
  70767. * @returns the JSON object
  70768. */
  70769. serialize(): any;
  70770. /**
  70771. * Parse properties from a JSON object
  70772. * @param serializationObject defines the JSON object
  70773. */
  70774. parse(serializationObject: any): void;
  70775. }
  70776. }
  70777. declare module BABYLON {
  70778. /**
  70779. * Particle emitter emitting particles from the inside of a hemisphere.
  70780. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  70781. */
  70782. export class HemisphericParticleEmitter implements IParticleEmitterType {
  70783. /**
  70784. * The radius of the emission hemisphere.
  70785. */
  70786. radius: number;
  70787. /**
  70788. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70789. */
  70790. radiusRange: number;
  70791. /**
  70792. * How much to randomize the particle direction [0-1].
  70793. */
  70794. directionRandomizer: number;
  70795. /**
  70796. * Creates a new instance HemisphericParticleEmitter
  70797. * @param radius the radius of the emission hemisphere (1 by default)
  70798. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70799. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  70800. */
  70801. constructor(
  70802. /**
  70803. * The radius of the emission hemisphere.
  70804. */
  70805. radius?: number,
  70806. /**
  70807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70808. */
  70809. radiusRange?: number,
  70810. /**
  70811. * How much to randomize the particle direction [0-1].
  70812. */
  70813. directionRandomizer?: number);
  70814. /**
  70815. * Called by the particle System when the direction is computed for the created particle.
  70816. * @param worldMatrix is the world matrix of the particle system
  70817. * @param directionToUpdate is the direction vector to update with the result
  70818. * @param particle is the particle we are computed the direction for
  70819. */
  70820. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70821. /**
  70822. * Called by the particle System when the position is computed for the created particle.
  70823. * @param worldMatrix is the world matrix of the particle system
  70824. * @param positionToUpdate is the position vector to update with the result
  70825. * @param particle is the particle we are computed the position for
  70826. */
  70827. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70828. /**
  70829. * Clones the current emitter and returns a copy of it
  70830. * @returns the new emitter
  70831. */
  70832. clone(): HemisphericParticleEmitter;
  70833. /**
  70834. * Called by the GPUParticleSystem to setup the update shader
  70835. * @param effect defines the update shader
  70836. */
  70837. applyToShader(effect: Effect): void;
  70838. /**
  70839. * Returns a string to use to update the GPU particles update shader
  70840. * @returns a string containng the defines string
  70841. */
  70842. getEffectDefines(): string;
  70843. /**
  70844. * Returns the string "HemisphericParticleEmitter"
  70845. * @returns a string containing the class name
  70846. */
  70847. getClassName(): string;
  70848. /**
  70849. * Serializes the particle system to a JSON object.
  70850. * @returns the JSON object
  70851. */
  70852. serialize(): any;
  70853. /**
  70854. * Parse properties from a JSON object
  70855. * @param serializationObject defines the JSON object
  70856. */
  70857. parse(serializationObject: any): void;
  70858. }
  70859. }
  70860. declare module BABYLON {
  70861. /**
  70862. * Particle emitter emitting particles from a point.
  70863. * It emits the particles randomly between 2 given directions.
  70864. */
  70865. export class PointParticleEmitter implements IParticleEmitterType {
  70866. /**
  70867. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70868. */
  70869. direction1: Vector3;
  70870. /**
  70871. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  70872. */
  70873. direction2: Vector3;
  70874. /**
  70875. * Creates a new instance PointParticleEmitter
  70876. */
  70877. constructor();
  70878. /**
  70879. * Called by the particle System when the direction is computed for the created particle.
  70880. * @param worldMatrix is the world matrix of the particle system
  70881. * @param directionToUpdate is the direction vector to update with the result
  70882. * @param particle is the particle we are computed the direction for
  70883. */
  70884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70885. /**
  70886. * Called by the particle System when the position is computed for the created particle.
  70887. * @param worldMatrix is the world matrix of the particle system
  70888. * @param positionToUpdate is the position vector to update with the result
  70889. * @param particle is the particle we are computed the position for
  70890. */
  70891. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70892. /**
  70893. * Clones the current emitter and returns a copy of it
  70894. * @returns the new emitter
  70895. */
  70896. clone(): PointParticleEmitter;
  70897. /**
  70898. * Called by the GPUParticleSystem to setup the update shader
  70899. * @param effect defines the update shader
  70900. */
  70901. applyToShader(effect: Effect): void;
  70902. /**
  70903. * Returns a string to use to update the GPU particles update shader
  70904. * @returns a string containng the defines string
  70905. */
  70906. getEffectDefines(): string;
  70907. /**
  70908. * Returns the string "PointParticleEmitter"
  70909. * @returns a string containing the class name
  70910. */
  70911. getClassName(): string;
  70912. /**
  70913. * Serializes the particle system to a JSON object.
  70914. * @returns the JSON object
  70915. */
  70916. serialize(): any;
  70917. /**
  70918. * Parse properties from a JSON object
  70919. * @param serializationObject defines the JSON object
  70920. */
  70921. parse(serializationObject: any): void;
  70922. }
  70923. }
  70924. declare module BABYLON {
  70925. /**
  70926. * Particle emitter emitting particles from the inside of a sphere.
  70927. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  70928. */
  70929. export class SphereParticleEmitter implements IParticleEmitterType {
  70930. /**
  70931. * The radius of the emission sphere.
  70932. */
  70933. radius: number;
  70934. /**
  70935. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70936. */
  70937. radiusRange: number;
  70938. /**
  70939. * How much to randomize the particle direction [0-1].
  70940. */
  70941. directionRandomizer: number;
  70942. /**
  70943. * Creates a new instance SphereParticleEmitter
  70944. * @param radius the radius of the emission sphere (1 by default)
  70945. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  70946. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  70947. */
  70948. constructor(
  70949. /**
  70950. * The radius of the emission sphere.
  70951. */
  70952. radius?: number,
  70953. /**
  70954. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  70955. */
  70956. radiusRange?: number,
  70957. /**
  70958. * How much to randomize the particle direction [0-1].
  70959. */
  70960. directionRandomizer?: number);
  70961. /**
  70962. * Called by the particle System when the direction is computed for the created particle.
  70963. * @param worldMatrix is the world matrix of the particle system
  70964. * @param directionToUpdate is the direction vector to update with the result
  70965. * @param particle is the particle we are computed the direction for
  70966. */
  70967. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  70968. /**
  70969. * Called by the particle System when the position is computed for the created particle.
  70970. * @param worldMatrix is the world matrix of the particle system
  70971. * @param positionToUpdate is the position vector to update with the result
  70972. * @param particle is the particle we are computed the position for
  70973. */
  70974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  70975. /**
  70976. * Clones the current emitter and returns a copy of it
  70977. * @returns the new emitter
  70978. */
  70979. clone(): SphereParticleEmitter;
  70980. /**
  70981. * Called by the GPUParticleSystem to setup the update shader
  70982. * @param effect defines the update shader
  70983. */
  70984. applyToShader(effect: Effect): void;
  70985. /**
  70986. * Returns a string to use to update the GPU particles update shader
  70987. * @returns a string containng the defines string
  70988. */
  70989. getEffectDefines(): string;
  70990. /**
  70991. * Returns the string "SphereParticleEmitter"
  70992. * @returns a string containing the class name
  70993. */
  70994. getClassName(): string;
  70995. /**
  70996. * Serializes the particle system to a JSON object.
  70997. * @returns the JSON object
  70998. */
  70999. serialize(): any;
  71000. /**
  71001. * Parse properties from a JSON object
  71002. * @param serializationObject defines the JSON object
  71003. */
  71004. parse(serializationObject: any): void;
  71005. }
  71006. /**
  71007. * Particle emitter emitting particles from the inside of a sphere.
  71008. * It emits the particles randomly between two vectors.
  71009. */
  71010. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  71011. /**
  71012. * The min limit of the emission direction.
  71013. */
  71014. direction1: Vector3;
  71015. /**
  71016. * The max limit of the emission direction.
  71017. */
  71018. direction2: Vector3;
  71019. /**
  71020. * Creates a new instance SphereDirectedParticleEmitter
  71021. * @param radius the radius of the emission sphere (1 by default)
  71022. * @param direction1 the min limit of the emission direction (up vector by default)
  71023. * @param direction2 the max limit of the emission direction (up vector by default)
  71024. */
  71025. constructor(radius?: number,
  71026. /**
  71027. * The min limit of the emission direction.
  71028. */
  71029. direction1?: Vector3,
  71030. /**
  71031. * The max limit of the emission direction.
  71032. */
  71033. direction2?: Vector3);
  71034. /**
  71035. * Called by the particle System when the direction is computed for the created particle.
  71036. * @param worldMatrix is the world matrix of the particle system
  71037. * @param directionToUpdate is the direction vector to update with the result
  71038. * @param particle is the particle we are computed the direction for
  71039. */
  71040. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  71041. /**
  71042. * Clones the current emitter and returns a copy of it
  71043. * @returns the new emitter
  71044. */
  71045. clone(): SphereDirectedParticleEmitter;
  71046. /**
  71047. * Called by the GPUParticleSystem to setup the update shader
  71048. * @param effect defines the update shader
  71049. */
  71050. applyToShader(effect: Effect): void;
  71051. /**
  71052. * Returns a string to use to update the GPU particles update shader
  71053. * @returns a string containng the defines string
  71054. */
  71055. getEffectDefines(): string;
  71056. /**
  71057. * Returns the string "SphereDirectedParticleEmitter"
  71058. * @returns a string containing the class name
  71059. */
  71060. getClassName(): string;
  71061. /**
  71062. * Serializes the particle system to a JSON object.
  71063. * @returns the JSON object
  71064. */
  71065. serialize(): any;
  71066. /**
  71067. * Parse properties from a JSON object
  71068. * @param serializationObject defines the JSON object
  71069. */
  71070. parse(serializationObject: any): void;
  71071. }
  71072. }
  71073. declare module BABYLON {
  71074. /**
  71075. * Interface representing a particle system in Babylon.js.
  71076. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  71077. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  71078. */
  71079. export interface IParticleSystem {
  71080. /**
  71081. * List of animations used by the particle system.
  71082. */
  71083. animations: Animation[];
  71084. /**
  71085. * The id of the Particle system.
  71086. */
  71087. id: string;
  71088. /**
  71089. * The name of the Particle system.
  71090. */
  71091. name: string;
  71092. /**
  71093. * The emitter represents the Mesh or position we are attaching the particle system to.
  71094. */
  71095. emitter: Nullable<AbstractMesh | Vector3>;
  71096. /**
  71097. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  71098. */
  71099. isBillboardBased: boolean;
  71100. /**
  71101. * The rendering group used by the Particle system to chose when to render.
  71102. */
  71103. renderingGroupId: number;
  71104. /**
  71105. * The layer mask we are rendering the particles through.
  71106. */
  71107. layerMask: number;
  71108. /**
  71109. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  71110. */
  71111. updateSpeed: number;
  71112. /**
  71113. * The amount of time the particle system is running (depends of the overall update speed).
  71114. */
  71115. targetStopDuration: number;
  71116. /**
  71117. * The texture used to render each particle. (this can be a spritesheet)
  71118. */
  71119. particleTexture: Nullable<Texture>;
  71120. /**
  71121. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  71122. */
  71123. blendMode: number;
  71124. /**
  71125. * Minimum life time of emitting particles.
  71126. */
  71127. minLifeTime: number;
  71128. /**
  71129. * Maximum life time of emitting particles.
  71130. */
  71131. maxLifeTime: number;
  71132. /**
  71133. * Minimum Size of emitting particles.
  71134. */
  71135. minSize: number;
  71136. /**
  71137. * Maximum Size of emitting particles.
  71138. */
  71139. maxSize: number;
  71140. /**
  71141. * Minimum scale of emitting particles on X axis.
  71142. */
  71143. minScaleX: number;
  71144. /**
  71145. * Maximum scale of emitting particles on X axis.
  71146. */
  71147. maxScaleX: number;
  71148. /**
  71149. * Minimum scale of emitting particles on Y axis.
  71150. */
  71151. minScaleY: number;
  71152. /**
  71153. * Maximum scale of emitting particles on Y axis.
  71154. */
  71155. maxScaleY: number;
  71156. /**
  71157. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  71158. */
  71159. color1: Color4;
  71160. /**
  71161. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  71162. */
  71163. color2: Color4;
  71164. /**
  71165. * Color the particle will have at the end of its lifetime.
  71166. */
  71167. colorDead: Color4;
  71168. /**
  71169. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  71170. */
  71171. emitRate: number;
  71172. /**
  71173. * You can use gravity if you want to give an orientation to your particles.
  71174. */
  71175. gravity: Vector3;
  71176. /**
  71177. * Minimum power of emitting particles.
  71178. */
  71179. minEmitPower: number;
  71180. /**
  71181. * Maximum power of emitting particles.
  71182. */
  71183. maxEmitPower: number;
  71184. /**
  71185. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  71186. */
  71187. minAngularSpeed: number;
  71188. /**
  71189. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  71190. */
  71191. maxAngularSpeed: number;
  71192. /**
  71193. * Gets or sets the minimal initial rotation in radians.
  71194. */
  71195. minInitialRotation: number;
  71196. /**
  71197. * Gets or sets the maximal initial rotation in radians.
  71198. */
  71199. maxInitialRotation: number;
  71200. /**
  71201. * The particle emitter type defines the emitter used by the particle system.
  71202. * It can be for example box, sphere, or cone...
  71203. */
  71204. particleEmitterType: Nullable<IParticleEmitterType>;
  71205. /**
  71206. * Defines the delay in milliseconds before starting the system (0 by default)
  71207. */
  71208. startDelay: number;
  71209. /**
  71210. * 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
  71211. */
  71212. preWarmCycles: number;
  71213. /**
  71214. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  71215. */
  71216. preWarmStepOffset: number;
  71217. /**
  71218. * 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)
  71219. */
  71220. spriteCellChangeSpeed: number;
  71221. /**
  71222. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  71223. */
  71224. startSpriteCellID: number;
  71225. /**
  71226. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  71227. */
  71228. endSpriteCellID: number;
  71229. /**
  71230. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  71231. */
  71232. spriteCellWidth: number;
  71233. /**
  71234. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  71235. */
  71236. spriteCellHeight: number;
  71237. /**
  71238. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  71239. */
  71240. spriteRandomStartCell: boolean;
  71241. /**
  71242. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  71243. */
  71244. isAnimationSheetEnabled: boolean;
  71245. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  71246. translationPivot: Vector2;
  71247. /**
  71248. * Gets or sets a texture used to add random noise to particle positions
  71249. */
  71250. noiseTexture: Nullable<BaseTexture>;
  71251. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  71252. noiseStrength: Vector3;
  71253. /**
  71254. * Gets or sets the billboard mode to use when isBillboardBased = true.
  71255. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  71256. */
  71257. billboardMode: number;
  71258. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  71259. limitVelocityDamping: number;
  71260. /**
  71261. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  71262. */
  71263. beginAnimationOnStart: boolean;
  71264. /**
  71265. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  71266. */
  71267. beginAnimationFrom: number;
  71268. /**
  71269. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  71270. */
  71271. beginAnimationTo: number;
  71272. /**
  71273. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  71274. */
  71275. beginAnimationLoop: boolean;
  71276. /**
  71277. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  71278. */
  71279. disposeOnStop: boolean;
  71280. /**
  71281. * Gets the maximum number of particles active at the same time.
  71282. * @returns The max number of active particles.
  71283. */
  71284. getCapacity(): number;
  71285. /**
  71286. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71287. * @returns True if it has been started, otherwise false.
  71288. */
  71289. isStarted(): boolean;
  71290. /**
  71291. * Animates the particle system for this frame.
  71292. */
  71293. animate(): void;
  71294. /**
  71295. * Renders the particle system in its current state.
  71296. * @returns the current number of particles
  71297. */
  71298. render(): number;
  71299. /**
  71300. * Dispose the particle system and frees its associated resources.
  71301. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71302. */
  71303. dispose(disposeTexture?: boolean): void;
  71304. /**
  71305. * Clones the particle system.
  71306. * @param name The name of the cloned object
  71307. * @param newEmitter The new emitter to use
  71308. * @returns the cloned particle system
  71309. */
  71310. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  71311. /**
  71312. * Serializes the particle system to a JSON object.
  71313. * @returns the JSON object
  71314. */
  71315. serialize(): any;
  71316. /**
  71317. * Rebuild the particle system
  71318. */
  71319. rebuild(): void;
  71320. /**
  71321. * Starts the particle system and begins to emit
  71322. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  71323. */
  71324. start(delay?: number): void;
  71325. /**
  71326. * Stops the particle system.
  71327. */
  71328. stop(): void;
  71329. /**
  71330. * Remove all active particles
  71331. */
  71332. reset(): void;
  71333. /**
  71334. * Is this system ready to be used/rendered
  71335. * @return true if the system is ready
  71336. */
  71337. isReady(): boolean;
  71338. /**
  71339. * Adds a new color gradient
  71340. * @param gradient defines the gradient to use (between 0 and 1)
  71341. * @param color1 defines the color to affect to the specified gradient
  71342. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71343. * @returns the current particle system
  71344. */
  71345. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  71346. /**
  71347. * Remove a specific color gradient
  71348. * @param gradient defines the gradient to remove
  71349. * @returns the current particle system
  71350. */
  71351. removeColorGradient(gradient: number): IParticleSystem;
  71352. /**
  71353. * Adds a new size gradient
  71354. * @param gradient defines the gradient to use (between 0 and 1)
  71355. * @param factor defines the size factor to affect to the specified gradient
  71356. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71357. * @returns the current particle system
  71358. */
  71359. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71360. /**
  71361. * Remove a specific size gradient
  71362. * @param gradient defines the gradient to remove
  71363. * @returns the current particle system
  71364. */
  71365. removeSizeGradient(gradient: number): IParticleSystem;
  71366. /**
  71367. * Gets the current list of color gradients.
  71368. * You must use addColorGradient and removeColorGradient to udpate this list
  71369. * @returns the list of color gradients
  71370. */
  71371. getColorGradients(): Nullable<Array<ColorGradient>>;
  71372. /**
  71373. * Gets the current list of size gradients.
  71374. * You must use addSizeGradient and removeSizeGradient to udpate this list
  71375. * @returns the list of size gradients
  71376. */
  71377. getSizeGradients(): Nullable<Array<FactorGradient>>;
  71378. /**
  71379. * Gets the current list of angular speed gradients.
  71380. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  71381. * @returns the list of angular speed gradients
  71382. */
  71383. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  71384. /**
  71385. * Adds a new angular speed gradient
  71386. * @param gradient defines the gradient to use (between 0 and 1)
  71387. * @param factor defines the angular speed to affect to the specified gradient
  71388. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71389. * @returns the current particle system
  71390. */
  71391. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71392. /**
  71393. * Remove a specific angular speed gradient
  71394. * @param gradient defines the gradient to remove
  71395. * @returns the current particle system
  71396. */
  71397. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  71398. /**
  71399. * Gets the current list of velocity gradients.
  71400. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  71401. * @returns the list of velocity gradients
  71402. */
  71403. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  71404. /**
  71405. * Adds a new velocity gradient
  71406. * @param gradient defines the gradient to use (between 0 and 1)
  71407. * @param factor defines the velocity to affect to the specified gradient
  71408. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71409. * @returns the current particle system
  71410. */
  71411. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71412. /**
  71413. * Remove a specific velocity gradient
  71414. * @param gradient defines the gradient to remove
  71415. * @returns the current particle system
  71416. */
  71417. removeVelocityGradient(gradient: number): IParticleSystem;
  71418. /**
  71419. * Gets the current list of limit velocity gradients.
  71420. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  71421. * @returns the list of limit velocity gradients
  71422. */
  71423. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  71424. /**
  71425. * Adds a new limit velocity gradient
  71426. * @param gradient defines the gradient to use (between 0 and 1)
  71427. * @param factor defines the limit velocity to affect to the specified gradient
  71428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71429. * @returns the current particle system
  71430. */
  71431. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71432. /**
  71433. * Remove a specific limit velocity gradient
  71434. * @param gradient defines the gradient to remove
  71435. * @returns the current particle system
  71436. */
  71437. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  71438. /**
  71439. * Adds a new drag gradient
  71440. * @param gradient defines the gradient to use (between 0 and 1)
  71441. * @param factor defines the drag to affect to the specified gradient
  71442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71443. * @returns the current particle system
  71444. */
  71445. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71446. /**
  71447. * Remove a specific drag gradient
  71448. * @param gradient defines the gradient to remove
  71449. * @returns the current particle system
  71450. */
  71451. removeDragGradient(gradient: number): IParticleSystem;
  71452. /**
  71453. * Gets the current list of drag gradients.
  71454. * You must use addDragGradient and removeDragGradient to udpate this list
  71455. * @returns the list of drag gradients
  71456. */
  71457. getDragGradients(): Nullable<Array<FactorGradient>>;
  71458. /**
  71459. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  71460. * @param gradient defines the gradient to use (between 0 and 1)
  71461. * @param factor defines the emit rate to affect to the specified gradient
  71462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71463. * @returns the current particle system
  71464. */
  71465. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71466. /**
  71467. * Remove a specific emit rate gradient
  71468. * @param gradient defines the gradient to remove
  71469. * @returns the current particle system
  71470. */
  71471. removeEmitRateGradient(gradient: number): IParticleSystem;
  71472. /**
  71473. * Gets the current list of emit rate gradients.
  71474. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  71475. * @returns the list of emit rate gradients
  71476. */
  71477. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  71478. /**
  71479. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  71480. * @param gradient defines the gradient to use (between 0 and 1)
  71481. * @param factor defines the start size to affect to the specified gradient
  71482. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71483. * @returns the current particle system
  71484. */
  71485. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71486. /**
  71487. * Remove a specific start size gradient
  71488. * @param gradient defines the gradient to remove
  71489. * @returns the current particle system
  71490. */
  71491. removeStartSizeGradient(gradient: number): IParticleSystem;
  71492. /**
  71493. * Gets the current list of start size gradients.
  71494. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  71495. * @returns the list of start size gradients
  71496. */
  71497. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  71498. /**
  71499. * Adds a new life time gradient
  71500. * @param gradient defines the gradient to use (between 0 and 1)
  71501. * @param factor defines the life time factor to affect to the specified gradient
  71502. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71503. * @returns the current particle system
  71504. */
  71505. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71506. /**
  71507. * Remove a specific life time gradient
  71508. * @param gradient defines the gradient to remove
  71509. * @returns the current particle system
  71510. */
  71511. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71512. /**
  71513. * Gets the current list of life time gradients.
  71514. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  71515. * @returns the list of life time gradients
  71516. */
  71517. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  71518. /**
  71519. * Gets the current list of color gradients.
  71520. * You must use addColorGradient and removeColorGradient to udpate this list
  71521. * @returns the list of color gradients
  71522. */
  71523. getColorGradients(): Nullable<Array<ColorGradient>>;
  71524. /**
  71525. * Adds a new ramp gradient used to remap particle colors
  71526. * @param gradient defines the gradient to use (between 0 and 1)
  71527. * @param color defines the color to affect to the specified gradient
  71528. * @returns the current particle system
  71529. */
  71530. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71531. /**
  71532. * Gets the current list of ramp gradients.
  71533. * You must use addRampGradient and removeRampGradient to udpate this list
  71534. * @returns the list of ramp gradients
  71535. */
  71536. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71537. /** Gets or sets a boolean indicating that ramp gradients must be used
  71538. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71539. */
  71540. useRampGradients: boolean;
  71541. /**
  71542. * Adds a new color remap gradient
  71543. * @param gradient defines the gradient to use (between 0 and 1)
  71544. * @param min defines the color remap minimal range
  71545. * @param max defines the color remap maximal range
  71546. * @returns the current particle system
  71547. */
  71548. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71549. /**
  71550. * Gets the current list of color remap gradients.
  71551. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  71552. * @returns the list of color remap gradients
  71553. */
  71554. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  71555. /**
  71556. * Adds a new alpha remap gradient
  71557. * @param gradient defines the gradient to use (between 0 and 1)
  71558. * @param min defines the alpha remap minimal range
  71559. * @param max defines the alpha remap maximal range
  71560. * @returns the current particle system
  71561. */
  71562. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71563. /**
  71564. * Gets the current list of alpha remap gradients.
  71565. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  71566. * @returns the list of alpha remap gradients
  71567. */
  71568. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  71569. /**
  71570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  71571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71573. * @returns the emitter
  71574. */
  71575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  71576. /**
  71577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  71578. * @param radius The radius of the hemisphere to emit from
  71579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71580. * @returns the emitter
  71581. */
  71582. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  71583. /**
  71584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  71585. * @param radius The radius of the sphere to emit from
  71586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  71587. * @returns the emitter
  71588. */
  71589. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  71590. /**
  71591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  71592. * @param radius The radius of the sphere to emit from
  71593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  71594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  71595. * @returns the emitter
  71596. */
  71597. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  71598. /**
  71599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  71600. * @param radius The radius of the emission cylinder
  71601. * @param height The height of the emission cylinder
  71602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  71603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  71604. * @returns the emitter
  71605. */
  71606. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  71607. /**
  71608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  71609. * @param radius The radius of the cylinder to emit from
  71610. * @param height The height of the emission cylinder
  71611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  71612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  71613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  71614. * @returns the emitter
  71615. */
  71616. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  71617. /**
  71618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  71619. * @param radius The radius of the cone to emit from
  71620. * @param angle The base angle of the cone
  71621. * @returns the emitter
  71622. */
  71623. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  71624. /**
  71625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  71626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  71627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  71628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  71630. * @returns the emitter
  71631. */
  71632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  71633. /**
  71634. * Get hosting scene
  71635. * @returns the scene
  71636. */
  71637. getScene(): Scene;
  71638. }
  71639. }
  71640. declare module BABYLON {
  71641. /**
  71642. * Creates an instance based on a source mesh.
  71643. */
  71644. export class InstancedMesh extends AbstractMesh {
  71645. private _sourceMesh;
  71646. private _currentLOD;
  71647. /** @hidden */
  71648. _indexInSourceMeshInstanceArray: number;
  71649. constructor(name: string, source: Mesh);
  71650. /**
  71651. * Returns the string "InstancedMesh".
  71652. */
  71653. getClassName(): string;
  71654. /**
  71655. * If the source mesh receives shadows
  71656. */
  71657. readonly receiveShadows: boolean;
  71658. /**
  71659. * The material of the source mesh
  71660. */
  71661. readonly material: Nullable<Material>;
  71662. /**
  71663. * Visibility of the source mesh
  71664. */
  71665. readonly visibility: number;
  71666. /**
  71667. * Skeleton of the source mesh
  71668. */
  71669. readonly skeleton: Nullable<Skeleton>;
  71670. /**
  71671. * Rendering ground id of the source mesh
  71672. */
  71673. renderingGroupId: number;
  71674. /**
  71675. * Returns the total number of vertices (integer).
  71676. */
  71677. getTotalVertices(): number;
  71678. /**
  71679. * Returns a positive integer : the total number of indices in this mesh geometry.
  71680. * @returns the numner of indices or zero if the mesh has no geometry.
  71681. */
  71682. getTotalIndices(): number;
  71683. /**
  71684. * The source mesh of the instance
  71685. */
  71686. readonly sourceMesh: Mesh;
  71687. /**
  71688. * Is this node ready to be used/rendered
  71689. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  71690. * @return {boolean} is it ready
  71691. */
  71692. isReady(completeCheck?: boolean): boolean;
  71693. /**
  71694. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  71695. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  71696. * @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.
  71697. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  71698. */
  71699. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  71700. /**
  71701. * Sets the vertex data of the mesh geometry for the requested `kind`.
  71702. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  71703. * The `data` are either a numeric array either a Float32Array.
  71704. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  71705. * 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).
  71706. * Note that a new underlying VertexBuffer object is created each call.
  71707. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  71708. *
  71709. * Possible `kind` values :
  71710. * - VertexBuffer.PositionKind
  71711. * - VertexBuffer.UVKind
  71712. * - VertexBuffer.UV2Kind
  71713. * - VertexBuffer.UV3Kind
  71714. * - VertexBuffer.UV4Kind
  71715. * - VertexBuffer.UV5Kind
  71716. * - VertexBuffer.UV6Kind
  71717. * - VertexBuffer.ColorKind
  71718. * - VertexBuffer.MatricesIndicesKind
  71719. * - VertexBuffer.MatricesIndicesExtraKind
  71720. * - VertexBuffer.MatricesWeightsKind
  71721. * - VertexBuffer.MatricesWeightsExtraKind
  71722. *
  71723. * Returns the Mesh.
  71724. */
  71725. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  71726. /**
  71727. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  71728. * If the mesh has no geometry, it is simply returned as it is.
  71729. * The `data` are either a numeric array either a Float32Array.
  71730. * No new underlying VertexBuffer object is created.
  71731. * 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.
  71732. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  71733. *
  71734. * Possible `kind` values :
  71735. * - VertexBuffer.PositionKind
  71736. * - VertexBuffer.UVKind
  71737. * - VertexBuffer.UV2Kind
  71738. * - VertexBuffer.UV3Kind
  71739. * - VertexBuffer.UV4Kind
  71740. * - VertexBuffer.UV5Kind
  71741. * - VertexBuffer.UV6Kind
  71742. * - VertexBuffer.ColorKind
  71743. * - VertexBuffer.MatricesIndicesKind
  71744. * - VertexBuffer.MatricesIndicesExtraKind
  71745. * - VertexBuffer.MatricesWeightsKind
  71746. * - VertexBuffer.MatricesWeightsExtraKind
  71747. *
  71748. * Returns the Mesh.
  71749. */
  71750. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  71751. /**
  71752. * Sets the mesh indices.
  71753. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  71754. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  71755. * This method creates a new index buffer each call.
  71756. * Returns the Mesh.
  71757. */
  71758. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  71759. /**
  71760. * Boolean : True if the mesh owns the requested kind of data.
  71761. */
  71762. isVerticesDataPresent(kind: string): boolean;
  71763. /**
  71764. * Returns an array of indices (IndicesArray).
  71765. */
  71766. getIndices(): Nullable<IndicesArray>;
  71767. readonly _positions: Nullable<Vector3[]>;
  71768. /**
  71769. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  71770. * This means the mesh underlying bounding box and sphere are recomputed.
  71771. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  71772. * @returns the current mesh
  71773. */
  71774. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  71775. /** @hidden */
  71776. _preActivate(): InstancedMesh;
  71777. /** @hidden */
  71778. _activate(renderId: number): InstancedMesh;
  71779. /**
  71780. * Returns the current associated LOD AbstractMesh.
  71781. */
  71782. getLOD(camera: Camera): AbstractMesh;
  71783. /** @hidden */
  71784. _syncSubMeshes(): InstancedMesh;
  71785. /** @hidden */
  71786. _generatePointsArray(): boolean;
  71787. /**
  71788. * Creates a new InstancedMesh from the current mesh.
  71789. * - name (string) : the cloned mesh name
  71790. * - newParent (optional Node) : the optional Node to parent the clone to.
  71791. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  71792. *
  71793. * Returns the clone.
  71794. */
  71795. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  71796. /**
  71797. * Disposes the InstancedMesh.
  71798. * Returns nothing.
  71799. */
  71800. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71801. }
  71802. }
  71803. declare module BABYLON {
  71804. /**
  71805. * Defines the options associated with the creation of a shader material.
  71806. */
  71807. export interface IShaderMaterialOptions {
  71808. /**
  71809. * Does the material work in alpha blend mode
  71810. */
  71811. needAlphaBlending: boolean;
  71812. /**
  71813. * Does the material work in alpha test mode
  71814. */
  71815. needAlphaTesting: boolean;
  71816. /**
  71817. * The list of attribute names used in the shader
  71818. */
  71819. attributes: string[];
  71820. /**
  71821. * The list of unifrom names used in the shader
  71822. */
  71823. uniforms: string[];
  71824. /**
  71825. * The list of UBO names used in the shader
  71826. */
  71827. uniformBuffers: string[];
  71828. /**
  71829. * The list of sampler names used in the shader
  71830. */
  71831. samplers: string[];
  71832. /**
  71833. * The list of defines used in the shader
  71834. */
  71835. defines: string[];
  71836. }
  71837. /**
  71838. * 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.
  71839. *
  71840. * This returned material effects how the mesh will look based on the code in the shaders.
  71841. *
  71842. * @see http://doc.babylonjs.com/how_to/shader_material
  71843. */
  71844. export class ShaderMaterial extends Material {
  71845. private _shaderPath;
  71846. private _options;
  71847. private _textures;
  71848. private _textureArrays;
  71849. private _floats;
  71850. private _ints;
  71851. private _floatsArrays;
  71852. private _colors3;
  71853. private _colors3Arrays;
  71854. private _colors4;
  71855. private _vectors2;
  71856. private _vectors3;
  71857. private _vectors4;
  71858. private _matrices;
  71859. private _matrices3x3;
  71860. private _matrices2x2;
  71861. private _vectors2Arrays;
  71862. private _vectors3Arrays;
  71863. private _cachedWorldViewMatrix;
  71864. private _renderId;
  71865. /**
  71866. * Instantiate a new shader material.
  71867. * 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.
  71868. * This returned material effects how the mesh will look based on the code in the shaders.
  71869. * @see http://doc.babylonjs.com/how_to/shader_material
  71870. * @param name Define the name of the material in the scene
  71871. * @param scene Define the scene the material belongs to
  71872. * @param shaderPath Defines the route to the shader code in one of three ways:
  71873. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  71874. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  71875. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  71876. * @param options Define the options used to create the shader
  71877. */
  71878. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  71879. /**
  71880. * Gets the current class name of the material e.g. "ShaderMaterial"
  71881. * Mainly use in serialization.
  71882. * @returns the class name
  71883. */
  71884. getClassName(): string;
  71885. /**
  71886. * Specifies if the material will require alpha blending
  71887. * @returns a boolean specifying if alpha blending is needed
  71888. */
  71889. needAlphaBlending(): boolean;
  71890. /**
  71891. * Specifies if this material should be rendered in alpha test mode
  71892. * @returns a boolean specifying if an alpha test is needed.
  71893. */
  71894. needAlphaTesting(): boolean;
  71895. private _checkUniform;
  71896. /**
  71897. * Set a texture in the shader.
  71898. * @param name Define the name of the uniform samplers as defined in the shader
  71899. * @param texture Define the texture to bind to this sampler
  71900. * @return the material itself allowing "fluent" like uniform updates
  71901. */
  71902. setTexture(name: string, texture: Texture): ShaderMaterial;
  71903. /**
  71904. * Set a texture array in the shader.
  71905. * @param name Define the name of the uniform sampler array as defined in the shader
  71906. * @param textures Define the list of textures to bind to this sampler
  71907. * @return the material itself allowing "fluent" like uniform updates
  71908. */
  71909. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  71910. /**
  71911. * Set a float in the shader.
  71912. * @param name Define the name of the uniform as defined in the shader
  71913. * @param value Define the value to give to the uniform
  71914. * @return the material itself allowing "fluent" like uniform updates
  71915. */
  71916. setFloat(name: string, value: number): ShaderMaterial;
  71917. /**
  71918. * Set a int in the shader.
  71919. * @param name Define the name of the uniform as defined in the shader
  71920. * @param value Define the value to give to the uniform
  71921. * @return the material itself allowing "fluent" like uniform updates
  71922. */
  71923. setInt(name: string, value: number): ShaderMaterial;
  71924. /**
  71925. * Set an array of floats in the shader.
  71926. * @param name Define the name of the uniform as defined in the shader
  71927. * @param value Define the value to give to the uniform
  71928. * @return the material itself allowing "fluent" like uniform updates
  71929. */
  71930. setFloats(name: string, value: number[]): ShaderMaterial;
  71931. /**
  71932. * Set a vec3 in the shader from a Color3.
  71933. * @param name Define the name of the uniform as defined in the shader
  71934. * @param value Define the value to give to the uniform
  71935. * @return the material itself allowing "fluent" like uniform updates
  71936. */
  71937. setColor3(name: string, value: Color3): ShaderMaterial;
  71938. /**
  71939. * Set a vec3 array in the shader from a Color3 array.
  71940. * @param name Define the name of the uniform as defined in the shader
  71941. * @param value Define the value to give to the uniform
  71942. * @return the material itself allowing "fluent" like uniform updates
  71943. */
  71944. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  71945. /**
  71946. * Set a vec4 in the shader from a Color4.
  71947. * @param name Define the name of the uniform as defined in the shader
  71948. * @param value Define the value to give to the uniform
  71949. * @return the material itself allowing "fluent" like uniform updates
  71950. */
  71951. setColor4(name: string, value: Color4): ShaderMaterial;
  71952. /**
  71953. * Set a vec2 in the shader from a Vector2.
  71954. * @param name Define the name of the uniform as defined in the shader
  71955. * @param value Define the value to give to the uniform
  71956. * @return the material itself allowing "fluent" like uniform updates
  71957. */
  71958. setVector2(name: string, value: Vector2): ShaderMaterial;
  71959. /**
  71960. * Set a vec3 in the shader from a Vector3.
  71961. * @param name Define the name of the uniform as defined in the shader
  71962. * @param value Define the value to give to the uniform
  71963. * @return the material itself allowing "fluent" like uniform updates
  71964. */
  71965. setVector3(name: string, value: Vector3): ShaderMaterial;
  71966. /**
  71967. * Set a vec4 in the shader from a Vector4.
  71968. * @param name Define the name of the uniform as defined in the shader
  71969. * @param value Define the value to give to the uniform
  71970. * @return the material itself allowing "fluent" like uniform updates
  71971. */
  71972. setVector4(name: string, value: Vector4): ShaderMaterial;
  71973. /**
  71974. * Set a mat4 in the shader from a Matrix.
  71975. * @param name Define the name of the uniform as defined in the shader
  71976. * @param value Define the value to give to the uniform
  71977. * @return the material itself allowing "fluent" like uniform updates
  71978. */
  71979. setMatrix(name: string, value: Matrix): ShaderMaterial;
  71980. /**
  71981. * Set a mat3 in the shader from a Float32Array.
  71982. * @param name Define the name of the uniform as defined in the shader
  71983. * @param value Define the value to give to the uniform
  71984. * @return the material itself allowing "fluent" like uniform updates
  71985. */
  71986. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  71987. /**
  71988. * Set a mat2 in the shader from a Float32Array.
  71989. * @param name Define the name of the uniform as defined in the shader
  71990. * @param value Define the value to give to the uniform
  71991. * @return the material itself allowing "fluent" like uniform updates
  71992. */
  71993. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  71994. /**
  71995. * Set a vec2 array in the shader from a number array.
  71996. * @param name Define the name of the uniform as defined in the shader
  71997. * @param value Define the value to give to the uniform
  71998. * @return the material itself allowing "fluent" like uniform updates
  71999. */
  72000. setArray2(name: string, value: number[]): ShaderMaterial;
  72001. /**
  72002. * Set a vec3 array in the shader from a number array.
  72003. * @param name Define the name of the uniform as defined in the shader
  72004. * @param value Define the value to give to the uniform
  72005. * @return the material itself allowing "fluent" like uniform updates
  72006. */
  72007. setArray3(name: string, value: number[]): ShaderMaterial;
  72008. private _checkCache;
  72009. /**
  72010. * Checks if the material is ready to render the requested mesh
  72011. * @param mesh Define the mesh to render
  72012. * @param useInstances Define whether or not the material is used with instances
  72013. * @returns true if ready, otherwise false
  72014. */
  72015. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  72016. /**
  72017. * Binds the world matrix to the material
  72018. * @param world defines the world transformation matrix
  72019. */
  72020. bindOnlyWorldMatrix(world: Matrix): void;
  72021. /**
  72022. * Binds the material to the mesh
  72023. * @param world defines the world transformation matrix
  72024. * @param mesh defines the mesh to bind the material to
  72025. */
  72026. bind(world: Matrix, mesh?: Mesh): void;
  72027. /**
  72028. * Gets the active textures from the material
  72029. * @returns an array of textures
  72030. */
  72031. getActiveTextures(): BaseTexture[];
  72032. /**
  72033. * Specifies if the material uses a texture
  72034. * @param texture defines the texture to check against the material
  72035. * @returns a boolean specifying if the material uses the texture
  72036. */
  72037. hasTexture(texture: BaseTexture): boolean;
  72038. /**
  72039. * Makes a duplicate of the material, and gives it a new name
  72040. * @param name defines the new name for the duplicated material
  72041. * @returns the cloned material
  72042. */
  72043. clone(name: string): ShaderMaterial;
  72044. /**
  72045. * Disposes the material
  72046. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  72047. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  72048. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  72049. */
  72050. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  72051. /**
  72052. * Serializes this material in a JSON representation
  72053. * @returns the serialized material object
  72054. */
  72055. serialize(): any;
  72056. /**
  72057. * Creates a shader material from parsed shader material data
  72058. * @param source defines the JSON represnetation of the material
  72059. * @param scene defines the hosting scene
  72060. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72061. * @returns a new material
  72062. */
  72063. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  72064. }
  72065. }
  72066. declare module BABYLON {
  72067. /** @hidden */
  72068. export var colorPixelShader: {
  72069. name: string;
  72070. shader: string;
  72071. };
  72072. }
  72073. declare module BABYLON {
  72074. /** @hidden */
  72075. export var colorVertexShader: {
  72076. name: string;
  72077. shader: string;
  72078. };
  72079. }
  72080. declare module BABYLON {
  72081. /**
  72082. * Line mesh
  72083. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  72084. */
  72085. export class LinesMesh extends Mesh {
  72086. /**
  72087. * If vertex color should be applied to the mesh
  72088. */
  72089. useVertexColor?: boolean | undefined;
  72090. /**
  72091. * If vertex alpha should be applied to the mesh
  72092. */
  72093. useVertexAlpha?: boolean | undefined;
  72094. /**
  72095. * Color of the line (Default: White)
  72096. */
  72097. color: Color3;
  72098. /**
  72099. * Alpha of the line (Default: 1)
  72100. */
  72101. alpha: number;
  72102. /**
  72103. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  72104. * This margin is expressed in world space coordinates, so its value may vary.
  72105. * Default value is 0.1
  72106. */
  72107. intersectionThreshold: number;
  72108. private _colorShader;
  72109. /**
  72110. * Creates a new LinesMesh
  72111. * @param name defines the name
  72112. * @param scene defines the hosting scene
  72113. * @param parent defines the parent mesh if any
  72114. * @param source defines the optional source LinesMesh used to clone data from
  72115. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  72116. * When false, achieved by calling a clone(), also passing False.
  72117. * This will make creation of children, recursive.
  72118. * @param useVertexColor defines if this LinesMesh supports vertex color
  72119. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  72120. */
  72121. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  72122. /**
  72123. * If vertex color should be applied to the mesh
  72124. */
  72125. useVertexColor?: boolean | undefined,
  72126. /**
  72127. * If vertex alpha should be applied to the mesh
  72128. */
  72129. useVertexAlpha?: boolean | undefined);
  72130. /**
  72131. * Returns the string "LineMesh"
  72132. */
  72133. getClassName(): string;
  72134. /**
  72135. * @hidden
  72136. */
  72137. /**
  72138. * @hidden
  72139. */
  72140. material: Material;
  72141. /**
  72142. * @hidden
  72143. */
  72144. readonly checkCollisions: boolean;
  72145. /** @hidden */
  72146. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  72147. /** @hidden */
  72148. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  72149. /**
  72150. * Disposes of the line mesh
  72151. * @param doNotRecurse If children should be disposed
  72152. */
  72153. dispose(doNotRecurse?: boolean): void;
  72154. /**
  72155. * Returns a new LineMesh object cloned from the current one.
  72156. */
  72157. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  72158. /**
  72159. * Creates a new InstancedLinesMesh object from the mesh model.
  72160. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  72161. * @param name defines the name of the new instance
  72162. * @returns a new InstancedLinesMesh
  72163. */
  72164. createInstance(name: string): InstancedLinesMesh;
  72165. }
  72166. /**
  72167. * Creates an instance based on a source LinesMesh
  72168. */
  72169. export class InstancedLinesMesh extends InstancedMesh {
  72170. /**
  72171. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  72172. * This margin is expressed in world space coordinates, so its value may vary.
  72173. * Initilized with the intersectionThreshold value of the source LinesMesh
  72174. */
  72175. intersectionThreshold: number;
  72176. constructor(name: string, source: LinesMesh);
  72177. /**
  72178. * Returns the string "InstancedLinesMesh".
  72179. */
  72180. getClassName(): string;
  72181. }
  72182. }
  72183. declare module BABYLON {
  72184. /** @hidden */
  72185. export var linePixelShader: {
  72186. name: string;
  72187. shader: string;
  72188. };
  72189. }
  72190. declare module BABYLON {
  72191. /** @hidden */
  72192. export var lineVertexShader: {
  72193. name: string;
  72194. shader: string;
  72195. };
  72196. }
  72197. declare module BABYLON {
  72198. interface AbstractMesh {
  72199. /**
  72200. * Disables the mesh edge rendering mode
  72201. * @returns the currentAbstractMesh
  72202. */
  72203. disableEdgesRendering(): AbstractMesh;
  72204. /**
  72205. * Enables the edge rendering mode on the mesh.
  72206. * This mode makes the mesh edges visible
  72207. * @param epsilon defines the maximal distance between two angles to detect a face
  72208. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72209. * @returns the currentAbstractMesh
  72210. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72211. */
  72212. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72213. /**
  72214. * Gets the edgesRenderer associated with the mesh
  72215. */
  72216. edgesRenderer: Nullable<EdgesRenderer>;
  72217. }
  72218. interface LinesMesh {
  72219. /**
  72220. * Enables the edge rendering mode on the mesh.
  72221. * This mode makes the mesh edges visible
  72222. * @param epsilon defines the maximal distance between two angles to detect a face
  72223. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72224. * @returns the currentAbstractMesh
  72225. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72226. */
  72227. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  72228. }
  72229. interface InstancedLinesMesh {
  72230. /**
  72231. * Enables the edge rendering mode on the mesh.
  72232. * This mode makes the mesh edges visible
  72233. * @param epsilon defines the maximal distance between two angles to detect a face
  72234. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  72235. * @returns the current InstancedLinesMesh
  72236. * @see https://www.babylonjs-playground.com/#19O9TU#0
  72237. */
  72238. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  72239. }
  72240. /**
  72241. * Defines the minimum contract an Edges renderer should follow.
  72242. */
  72243. export interface IEdgesRenderer extends IDisposable {
  72244. /**
  72245. * Gets or sets a boolean indicating if the edgesRenderer is active
  72246. */
  72247. isEnabled: boolean;
  72248. /**
  72249. * Renders the edges of the attached mesh,
  72250. */
  72251. render(): void;
  72252. /**
  72253. * Checks wether or not the edges renderer is ready to render.
  72254. * @return true if ready, otherwise false.
  72255. */
  72256. isReady(): boolean;
  72257. }
  72258. /**
  72259. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  72260. */
  72261. export class EdgesRenderer implements IEdgesRenderer {
  72262. /**
  72263. * Define the size of the edges with an orthographic camera
  72264. */
  72265. edgesWidthScalerForOrthographic: number;
  72266. /**
  72267. * Define the size of the edges with a perspective camera
  72268. */
  72269. edgesWidthScalerForPerspective: number;
  72270. protected _source: AbstractMesh;
  72271. protected _linesPositions: number[];
  72272. protected _linesNormals: number[];
  72273. protected _linesIndices: number[];
  72274. protected _epsilon: number;
  72275. protected _indicesCount: number;
  72276. protected _lineShader: ShaderMaterial;
  72277. protected _ib: WebGLBuffer;
  72278. protected _buffers: {
  72279. [key: string]: Nullable<VertexBuffer>;
  72280. };
  72281. protected _checkVerticesInsteadOfIndices: boolean;
  72282. private _meshRebuildObserver;
  72283. private _meshDisposeObserver;
  72284. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  72285. isEnabled: boolean;
  72286. /**
  72287. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  72288. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  72289. * @param source Mesh used to create edges
  72290. * @param epsilon sum of angles in adjacency to check for edge
  72291. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  72292. * @param generateEdgesLines - should generate Lines or only prepare resources.
  72293. */
  72294. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  72295. protected _prepareRessources(): void;
  72296. /** @hidden */
  72297. _rebuild(): void;
  72298. /**
  72299. * Releases the required resources for the edges renderer
  72300. */
  72301. dispose(): void;
  72302. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  72303. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  72304. /**
  72305. * Checks if the pair of p0 and p1 is en edge
  72306. * @param faceIndex
  72307. * @param edge
  72308. * @param faceNormals
  72309. * @param p0
  72310. * @param p1
  72311. * @private
  72312. */
  72313. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  72314. /**
  72315. * push line into the position, normal and index buffer
  72316. * @protected
  72317. */
  72318. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  72319. /**
  72320. * Generates lines edges from adjacencjes
  72321. * @private
  72322. */
  72323. _generateEdgesLines(): void;
  72324. /**
  72325. * Checks wether or not the edges renderer is ready to render.
  72326. * @return true if ready, otherwise false.
  72327. */
  72328. isReady(): boolean;
  72329. /**
  72330. * Renders the edges of the attached mesh,
  72331. */
  72332. render(): void;
  72333. }
  72334. /**
  72335. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  72336. */
  72337. export class LineEdgesRenderer extends EdgesRenderer {
  72338. /**
  72339. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  72340. * @param source LineMesh used to generate edges
  72341. * @param epsilon not important (specified angle for edge detection)
  72342. * @param checkVerticesInsteadOfIndices not important for LineMesh
  72343. */
  72344. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  72345. /**
  72346. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  72347. */
  72348. _generateEdgesLines(): void;
  72349. }
  72350. }
  72351. declare module BABYLON {
  72352. /**
  72353. * This represents the object necessary to create a rendering group.
  72354. * This is exclusively used and created by the rendering manager.
  72355. * To modify the behavior, you use the available helpers in your scene or meshes.
  72356. * @hidden
  72357. */
  72358. export class RenderingGroup {
  72359. index: number;
  72360. private _scene;
  72361. private _opaqueSubMeshes;
  72362. private _transparentSubMeshes;
  72363. private _alphaTestSubMeshes;
  72364. private _depthOnlySubMeshes;
  72365. private _particleSystems;
  72366. private _spriteManagers;
  72367. private _opaqueSortCompareFn;
  72368. private _alphaTestSortCompareFn;
  72369. private _transparentSortCompareFn;
  72370. private _renderOpaque;
  72371. private _renderAlphaTest;
  72372. private _renderTransparent;
  72373. private _edgesRenderers;
  72374. onBeforeTransparentRendering: () => void;
  72375. /**
  72376. * Set the opaque sort comparison function.
  72377. * If null the sub meshes will be render in the order they were created
  72378. */
  72379. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  72380. /**
  72381. * Set the alpha test sort comparison function.
  72382. * If null the sub meshes will be render in the order they were created
  72383. */
  72384. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  72385. /**
  72386. * Set the transparent sort comparison function.
  72387. * If null the sub meshes will be render in the order they were created
  72388. */
  72389. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  72390. /**
  72391. * Creates a new rendering group.
  72392. * @param index The rendering group index
  72393. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  72394. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  72395. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  72396. */
  72397. 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>);
  72398. /**
  72399. * Render all the sub meshes contained in the group.
  72400. * @param customRenderFunction Used to override the default render behaviour of the group.
  72401. * @returns true if rendered some submeshes.
  72402. */
  72403. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  72404. /**
  72405. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  72406. * @param subMeshes The submeshes to render
  72407. */
  72408. private renderOpaqueSorted;
  72409. /**
  72410. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  72411. * @param subMeshes The submeshes to render
  72412. */
  72413. private renderAlphaTestSorted;
  72414. /**
  72415. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  72416. * @param subMeshes The submeshes to render
  72417. */
  72418. private renderTransparentSorted;
  72419. /**
  72420. * Renders the submeshes in a specified order.
  72421. * @param subMeshes The submeshes to sort before render
  72422. * @param sortCompareFn The comparison function use to sort
  72423. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  72424. * @param transparent Specifies to activate blending if true
  72425. */
  72426. private static renderSorted;
  72427. /**
  72428. * Renders the submeshes in the order they were dispatched (no sort applied).
  72429. * @param subMeshes The submeshes to render
  72430. */
  72431. private static renderUnsorted;
  72432. /**
  72433. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  72434. * are rendered back to front if in the same alpha index.
  72435. *
  72436. * @param a The first submesh
  72437. * @param b The second submesh
  72438. * @returns The result of the comparison
  72439. */
  72440. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  72441. /**
  72442. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  72443. * are rendered back to front.
  72444. *
  72445. * @param a The first submesh
  72446. * @param b The second submesh
  72447. * @returns The result of the comparison
  72448. */
  72449. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  72450. /**
  72451. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  72452. * are rendered front to back (prevent overdraw).
  72453. *
  72454. * @param a The first submesh
  72455. * @param b The second submesh
  72456. * @returns The result of the comparison
  72457. */
  72458. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  72459. /**
  72460. * Resets the different lists of submeshes to prepare a new frame.
  72461. */
  72462. prepare(): void;
  72463. dispose(): void;
  72464. /**
  72465. * Inserts the submesh in its correct queue depending on its material.
  72466. * @param subMesh The submesh to dispatch
  72467. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  72468. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  72469. */
  72470. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  72471. dispatchSprites(spriteManager: ISpriteManager): void;
  72472. dispatchParticles(particleSystem: IParticleSystem): void;
  72473. private _renderParticles;
  72474. private _renderSprites;
  72475. }
  72476. }
  72477. declare module BABYLON {
  72478. /**
  72479. * Interface describing the different options available in the rendering manager
  72480. * regarding Auto Clear between groups.
  72481. */
  72482. export interface IRenderingManagerAutoClearSetup {
  72483. /**
  72484. * Defines whether or not autoclear is enable.
  72485. */
  72486. autoClear: boolean;
  72487. /**
  72488. * Defines whether or not to autoclear the depth buffer.
  72489. */
  72490. depth: boolean;
  72491. /**
  72492. * Defines whether or not to autoclear the stencil buffer.
  72493. */
  72494. stencil: boolean;
  72495. }
  72496. /**
  72497. * This class is used by the onRenderingGroupObservable
  72498. */
  72499. export class RenderingGroupInfo {
  72500. /**
  72501. * The Scene that being rendered
  72502. */
  72503. scene: Scene;
  72504. /**
  72505. * The camera currently used for the rendering pass
  72506. */
  72507. camera: Nullable<Camera>;
  72508. /**
  72509. * The ID of the renderingGroup being processed
  72510. */
  72511. renderingGroupId: number;
  72512. }
  72513. /**
  72514. * This is the manager responsible of all the rendering for meshes sprites and particles.
  72515. * It is enable to manage the different groups as well as the different necessary sort functions.
  72516. * This should not be used directly aside of the few static configurations
  72517. */
  72518. export class RenderingManager {
  72519. /**
  72520. * The max id used for rendering groups (not included)
  72521. */
  72522. static MAX_RENDERINGGROUPS: number;
  72523. /**
  72524. * The min id used for rendering groups (included)
  72525. */
  72526. static MIN_RENDERINGGROUPS: number;
  72527. /**
  72528. * Used to globally prevent autoclearing scenes.
  72529. */
  72530. static AUTOCLEAR: boolean;
  72531. /**
  72532. * @hidden
  72533. */
  72534. _useSceneAutoClearSetup: boolean;
  72535. private _scene;
  72536. private _renderingGroups;
  72537. private _depthStencilBufferAlreadyCleaned;
  72538. private _autoClearDepthStencil;
  72539. private _customOpaqueSortCompareFn;
  72540. private _customAlphaTestSortCompareFn;
  72541. private _customTransparentSortCompareFn;
  72542. private _renderingGroupInfo;
  72543. /**
  72544. * Instantiates a new rendering group for a particular scene
  72545. * @param scene Defines the scene the groups belongs to
  72546. */
  72547. constructor(scene: Scene);
  72548. private _clearDepthStencilBuffer;
  72549. /**
  72550. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  72551. * @hidden
  72552. */
  72553. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  72554. /**
  72555. * Resets the different information of the group to prepare a new frame
  72556. * @hidden
  72557. */
  72558. reset(): void;
  72559. /**
  72560. * Dispose and release the group and its associated resources.
  72561. * @hidden
  72562. */
  72563. dispose(): void;
  72564. /**
  72565. * Clear the info related to rendering groups preventing retention points during dispose.
  72566. */
  72567. freeRenderingGroups(): void;
  72568. private _prepareRenderingGroup;
  72569. /**
  72570. * Add a sprite manager to the rendering manager in order to render it this frame.
  72571. * @param spriteManager Define the sprite manager to render
  72572. */
  72573. dispatchSprites(spriteManager: ISpriteManager): void;
  72574. /**
  72575. * Add a particle system to the rendering manager in order to render it this frame.
  72576. * @param particleSystem Define the particle system to render
  72577. */
  72578. dispatchParticles(particleSystem: IParticleSystem): void;
  72579. /**
  72580. * Add a submesh to the manager in order to render it this frame
  72581. * @param subMesh The submesh to dispatch
  72582. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  72583. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  72584. */
  72585. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  72586. /**
  72587. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  72588. * This allowed control for front to back rendering or reversly depending of the special needs.
  72589. *
  72590. * @param renderingGroupId The rendering group id corresponding to its index
  72591. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  72592. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  72593. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  72594. */
  72595. 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;
  72596. /**
  72597. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  72598. *
  72599. * @param renderingGroupId The rendering group id corresponding to its index
  72600. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  72601. * @param depth Automatically clears depth between groups if true and autoClear is true.
  72602. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  72603. */
  72604. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  72605. /**
  72606. * Gets the current auto clear configuration for one rendering group of the rendering
  72607. * manager.
  72608. * @param index the rendering group index to get the information for
  72609. * @returns The auto clear setup for the requested rendering group
  72610. */
  72611. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  72612. }
  72613. }
  72614. declare module BABYLON {
  72615. /**
  72616. * This Helps creating a texture that will be created from a camera in your scene.
  72617. * It is basically a dynamic texture that could be used to create special effects for instance.
  72618. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  72619. */
  72620. export class RenderTargetTexture extends Texture {
  72621. isCube: boolean;
  72622. /**
  72623. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  72624. */
  72625. static readonly REFRESHRATE_RENDER_ONCE: number;
  72626. /**
  72627. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  72628. */
  72629. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  72630. /**
  72631. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  72632. * the central point of your effect and can save a lot of performances.
  72633. */
  72634. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  72635. /**
  72636. * Use this predicate to dynamically define the list of mesh you want to render.
  72637. * If set, the renderList property will be overwritten.
  72638. */
  72639. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  72640. private _renderList;
  72641. /**
  72642. * Use this list to define the list of mesh you want to render.
  72643. */
  72644. renderList: Nullable<Array<AbstractMesh>>;
  72645. private _hookArray;
  72646. /**
  72647. * Define if particles should be rendered in your texture.
  72648. */
  72649. renderParticles: boolean;
  72650. /**
  72651. * Define if sprites should be rendered in your texture.
  72652. */
  72653. renderSprites: boolean;
  72654. /**
  72655. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  72656. */
  72657. coordinatesMode: number;
  72658. /**
  72659. * Define the camera used to render the texture.
  72660. */
  72661. activeCamera: Nullable<Camera>;
  72662. /**
  72663. * Override the render function of the texture with your own one.
  72664. */
  72665. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  72666. /**
  72667. * Define if camera post processes should be use while rendering the texture.
  72668. */
  72669. useCameraPostProcesses: boolean;
  72670. /**
  72671. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  72672. */
  72673. ignoreCameraViewport: boolean;
  72674. private _postProcessManager;
  72675. private _postProcesses;
  72676. private _resizeObserver;
  72677. /**
  72678. * An event triggered when the texture is unbind.
  72679. */
  72680. onBeforeBindObservable: Observable<RenderTargetTexture>;
  72681. /**
  72682. * An event triggered when the texture is unbind.
  72683. */
  72684. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  72685. private _onAfterUnbindObserver;
  72686. /**
  72687. * Set a after unbind callback in the texture.
  72688. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  72689. */
  72690. onAfterUnbind: () => void;
  72691. /**
  72692. * An event triggered before rendering the texture
  72693. */
  72694. onBeforeRenderObservable: Observable<number>;
  72695. private _onBeforeRenderObserver;
  72696. /**
  72697. * Set a before render callback in the texture.
  72698. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  72699. */
  72700. onBeforeRender: (faceIndex: number) => void;
  72701. /**
  72702. * An event triggered after rendering the texture
  72703. */
  72704. onAfterRenderObservable: Observable<number>;
  72705. private _onAfterRenderObserver;
  72706. /**
  72707. * Set a after render callback in the texture.
  72708. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  72709. */
  72710. onAfterRender: (faceIndex: number) => void;
  72711. /**
  72712. * An event triggered after the texture clear
  72713. */
  72714. onClearObservable: Observable<Engine>;
  72715. private _onClearObserver;
  72716. /**
  72717. * Set a clear callback in the texture.
  72718. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  72719. */
  72720. onClear: (Engine: Engine) => void;
  72721. /**
  72722. * Define the clear color of the Render Target if it should be different from the scene.
  72723. */
  72724. clearColor: Color4;
  72725. protected _size: number | {
  72726. width: number;
  72727. height: number;
  72728. };
  72729. protected _initialSizeParameter: number | {
  72730. width: number;
  72731. height: number;
  72732. } | {
  72733. ratio: number;
  72734. };
  72735. protected _sizeRatio: Nullable<number>;
  72736. /** @hidden */
  72737. _generateMipMaps: boolean;
  72738. protected _renderingManager: RenderingManager;
  72739. /** @hidden */
  72740. _waitingRenderList: string[];
  72741. protected _doNotChangeAspectRatio: boolean;
  72742. protected _currentRefreshId: number;
  72743. protected _refreshRate: number;
  72744. protected _textureMatrix: Matrix;
  72745. protected _samples: number;
  72746. protected _renderTargetOptions: RenderTargetCreationOptions;
  72747. /**
  72748. * Gets render target creation options that were used.
  72749. */
  72750. readonly renderTargetOptions: RenderTargetCreationOptions;
  72751. protected _engine: Engine;
  72752. protected _onRatioRescale(): void;
  72753. /**
  72754. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  72755. * It must define where the camera used to render the texture is set
  72756. */
  72757. boundingBoxPosition: Vector3;
  72758. private _boundingBoxSize;
  72759. /**
  72760. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  72761. * When defined, the cubemap will switch to local mode
  72762. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  72763. * @example https://www.babylonjs-playground.com/#RNASML
  72764. */
  72765. boundingBoxSize: Vector3;
  72766. /**
  72767. * In case the RTT has been created with a depth texture, get the associated
  72768. * depth texture.
  72769. * Otherwise, return null.
  72770. */
  72771. depthStencilTexture: Nullable<InternalTexture>;
  72772. /**
  72773. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  72774. * or used a shadow, depth texture...
  72775. * @param name The friendly name of the texture
  72776. * @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)
  72777. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  72778. * @param generateMipMaps True if mip maps need to be generated after render.
  72779. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  72780. * @param type The type of the buffer in the RTT (int, half float, float...)
  72781. * @param isCube True if a cube texture needs to be created
  72782. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  72783. * @param generateDepthBuffer True to generate a depth buffer
  72784. * @param generateStencilBuffer True to generate a stencil buffer
  72785. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  72786. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  72787. * @param delayAllocation if the texture allocation should be delayed (default: false)
  72788. */
  72789. constructor(name: string, size: number | {
  72790. width: number;
  72791. height: number;
  72792. } | {
  72793. ratio: number;
  72794. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  72795. /**
  72796. * Creates a depth stencil texture.
  72797. * This is only available in WebGL 2 or with the depth texture extension available.
  72798. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  72799. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  72800. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  72801. */
  72802. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  72803. private _processSizeParameter;
  72804. /**
  72805. * Define the number of samples to use in case of MSAA.
  72806. * It defaults to one meaning no MSAA has been enabled.
  72807. */
  72808. samples: number;
  72809. /**
  72810. * Resets the refresh counter of the texture and start bak from scratch.
  72811. * Could be useful to regenerate the texture if it is setup to render only once.
  72812. */
  72813. resetRefreshCounter(): void;
  72814. /**
  72815. * Define the refresh rate of the texture or the rendering frequency.
  72816. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  72817. */
  72818. refreshRate: number;
  72819. /**
  72820. * Adds a post process to the render target rendering passes.
  72821. * @param postProcess define the post process to add
  72822. */
  72823. addPostProcess(postProcess: PostProcess): void;
  72824. /**
  72825. * Clear all the post processes attached to the render target
  72826. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  72827. */
  72828. clearPostProcesses(dispose?: boolean): void;
  72829. /**
  72830. * Remove one of the post process from the list of attached post processes to the texture
  72831. * @param postProcess define the post process to remove from the list
  72832. */
  72833. removePostProcess(postProcess: PostProcess): void;
  72834. /** @hidden */
  72835. _shouldRender(): boolean;
  72836. /**
  72837. * Gets the actual render size of the texture.
  72838. * @returns the width of the render size
  72839. */
  72840. getRenderSize(): number;
  72841. /**
  72842. * Gets the actual render width of the texture.
  72843. * @returns the width of the render size
  72844. */
  72845. getRenderWidth(): number;
  72846. /**
  72847. * Gets the actual render height of the texture.
  72848. * @returns the height of the render size
  72849. */
  72850. getRenderHeight(): number;
  72851. /**
  72852. * Get if the texture can be rescaled or not.
  72853. */
  72854. readonly canRescale: boolean;
  72855. /**
  72856. * Resize the texture using a ratio.
  72857. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  72858. */
  72859. scale(ratio: number): void;
  72860. /**
  72861. * Get the texture reflection matrix used to rotate/transform the reflection.
  72862. * @returns the reflection matrix
  72863. */
  72864. getReflectionTextureMatrix(): Matrix;
  72865. /**
  72866. * Resize the texture to a new desired size.
  72867. * Be carrefull as it will recreate all the data in the new texture.
  72868. * @param size Define the new size. It can be:
  72869. * - a number for squared texture,
  72870. * - an object containing { width: number, height: number }
  72871. * - or an object containing a ratio { ratio: number }
  72872. */
  72873. resize(size: number | {
  72874. width: number;
  72875. height: number;
  72876. } | {
  72877. ratio: number;
  72878. }): void;
  72879. /**
  72880. * Renders all the objects from the render list into the texture.
  72881. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  72882. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  72883. */
  72884. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  72885. private _bestReflectionRenderTargetDimension;
  72886. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  72887. private renderToTarget;
  72888. /**
  72889. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  72890. * This allowed control for front to back rendering or reversly depending of the special needs.
  72891. *
  72892. * @param renderingGroupId The rendering group id corresponding to its index
  72893. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  72894. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  72895. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  72896. */
  72897. 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;
  72898. /**
  72899. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  72900. *
  72901. * @param renderingGroupId The rendering group id corresponding to its index
  72902. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  72903. */
  72904. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  72905. /**
  72906. * Clones the texture.
  72907. * @returns the cloned texture
  72908. */
  72909. clone(): RenderTargetTexture;
  72910. /**
  72911. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  72912. * @returns The JSON representation of the texture
  72913. */
  72914. serialize(): any;
  72915. /**
  72916. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  72917. */
  72918. disposeFramebufferObjects(): void;
  72919. /**
  72920. * Dispose the texture and release its associated resources.
  72921. */
  72922. dispose(): void;
  72923. /** @hidden */
  72924. _rebuild(): void;
  72925. /**
  72926. * Clear the info related to rendering groups preventing retention point in material dispose.
  72927. */
  72928. freeRenderingGroups(): void;
  72929. }
  72930. }
  72931. declare module BABYLON {
  72932. /**
  72933. * Base class for the main features of a material in Babylon.js
  72934. */
  72935. export class Material implements IAnimatable {
  72936. /**
  72937. * Returns the triangle fill mode
  72938. */
  72939. static readonly TriangleFillMode: number;
  72940. /**
  72941. * Returns the wireframe mode
  72942. */
  72943. static readonly WireFrameFillMode: number;
  72944. /**
  72945. * Returns the point fill mode
  72946. */
  72947. static readonly PointFillMode: number;
  72948. /**
  72949. * Returns the point list draw mode
  72950. */
  72951. static readonly PointListDrawMode: number;
  72952. /**
  72953. * Returns the line list draw mode
  72954. */
  72955. static readonly LineListDrawMode: number;
  72956. /**
  72957. * Returns the line loop draw mode
  72958. */
  72959. static readonly LineLoopDrawMode: number;
  72960. /**
  72961. * Returns the line strip draw mode
  72962. */
  72963. static readonly LineStripDrawMode: number;
  72964. /**
  72965. * Returns the triangle strip draw mode
  72966. */
  72967. static readonly TriangleStripDrawMode: number;
  72968. /**
  72969. * Returns the triangle fan draw mode
  72970. */
  72971. static readonly TriangleFanDrawMode: number;
  72972. /**
  72973. * Stores the clock-wise side orientation
  72974. */
  72975. static readonly ClockWiseSideOrientation: number;
  72976. /**
  72977. * Stores the counter clock-wise side orientation
  72978. */
  72979. static readonly CounterClockWiseSideOrientation: number;
  72980. /**
  72981. * The dirty texture flag value
  72982. */
  72983. static readonly TextureDirtyFlag: number;
  72984. /**
  72985. * The dirty light flag value
  72986. */
  72987. static readonly LightDirtyFlag: number;
  72988. /**
  72989. * The dirty fresnel flag value
  72990. */
  72991. static readonly FresnelDirtyFlag: number;
  72992. /**
  72993. * The dirty attribute flag value
  72994. */
  72995. static readonly AttributesDirtyFlag: number;
  72996. /**
  72997. * The dirty misc flag value
  72998. */
  72999. static readonly MiscDirtyFlag: number;
  73000. /**
  73001. * The all dirty flag value
  73002. */
  73003. static readonly AllDirtyFlag: number;
  73004. /**
  73005. * The ID of the material
  73006. */
  73007. id: string;
  73008. /**
  73009. * Gets or sets the unique id of the material
  73010. */
  73011. uniqueId: number;
  73012. /**
  73013. * The name of the material
  73014. */
  73015. name: string;
  73016. /**
  73017. * Gets or sets user defined metadata
  73018. */
  73019. metadata: any;
  73020. /**
  73021. * For internal use only. Please do not use.
  73022. */
  73023. reservedDataStore: any;
  73024. /**
  73025. * Specifies if the ready state should be checked on each call
  73026. */
  73027. checkReadyOnEveryCall: boolean;
  73028. /**
  73029. * Specifies if the ready state should be checked once
  73030. */
  73031. checkReadyOnlyOnce: boolean;
  73032. /**
  73033. * The state of the material
  73034. */
  73035. state: string;
  73036. /**
  73037. * The alpha value of the material
  73038. */
  73039. protected _alpha: number;
  73040. /**
  73041. * Sets the alpha value of the material
  73042. */
  73043. /**
  73044. * Gets the alpha value of the material
  73045. */
  73046. alpha: number;
  73047. /**
  73048. * Specifies if back face culling is enabled
  73049. */
  73050. protected _backFaceCulling: boolean;
  73051. /**
  73052. * Sets the back-face culling state
  73053. */
  73054. /**
  73055. * Gets the back-face culling state
  73056. */
  73057. backFaceCulling: boolean;
  73058. /**
  73059. * Stores the value for side orientation
  73060. */
  73061. sideOrientation: number;
  73062. /**
  73063. * Callback triggered when the material is compiled
  73064. */
  73065. onCompiled: (effect: Effect) => void;
  73066. /**
  73067. * Callback triggered when an error occurs
  73068. */
  73069. onError: (effect: Effect, errors: string) => void;
  73070. /**
  73071. * Callback triggered to get the render target textures
  73072. */
  73073. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  73074. /**
  73075. * Gets a boolean indicating that current material needs to register RTT
  73076. */
  73077. readonly hasRenderTargetTextures: boolean;
  73078. /**
  73079. * Specifies if the material should be serialized
  73080. */
  73081. doNotSerialize: boolean;
  73082. /**
  73083. * @hidden
  73084. */
  73085. _storeEffectOnSubMeshes: boolean;
  73086. /**
  73087. * Stores the animations for the material
  73088. */
  73089. animations: Array<Animation>;
  73090. /**
  73091. * An event triggered when the material is disposed
  73092. */
  73093. onDisposeObservable: Observable<Material>;
  73094. /**
  73095. * An observer which watches for dispose events
  73096. */
  73097. private _onDisposeObserver;
  73098. private _onUnBindObservable;
  73099. /**
  73100. * Called during a dispose event
  73101. */
  73102. onDispose: () => void;
  73103. private _onBindObservable;
  73104. /**
  73105. * An event triggered when the material is bound
  73106. */
  73107. readonly onBindObservable: Observable<AbstractMesh>;
  73108. /**
  73109. * An observer which watches for bind events
  73110. */
  73111. private _onBindObserver;
  73112. /**
  73113. * Called during a bind event
  73114. */
  73115. onBind: (Mesh: AbstractMesh) => void;
  73116. /**
  73117. * An event triggered when the material is unbound
  73118. */
  73119. readonly onUnBindObservable: Observable<Material>;
  73120. /**
  73121. * Stores the value of the alpha mode
  73122. */
  73123. private _alphaMode;
  73124. /**
  73125. * Sets the value of the alpha mode.
  73126. *
  73127. * | Value | Type | Description |
  73128. * | --- | --- | --- |
  73129. * | 0 | ALPHA_DISABLE | |
  73130. * | 1 | ALPHA_ADD | |
  73131. * | 2 | ALPHA_COMBINE | |
  73132. * | 3 | ALPHA_SUBTRACT | |
  73133. * | 4 | ALPHA_MULTIPLY | |
  73134. * | 5 | ALPHA_MAXIMIZED | |
  73135. * | 6 | ALPHA_ONEONE | |
  73136. * | 7 | ALPHA_PREMULTIPLIED | |
  73137. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  73138. * | 9 | ALPHA_INTERPOLATE | |
  73139. * | 10 | ALPHA_SCREENMODE | |
  73140. *
  73141. */
  73142. /**
  73143. * Gets the value of the alpha mode
  73144. */
  73145. alphaMode: number;
  73146. /**
  73147. * Stores the state of the need depth pre-pass value
  73148. */
  73149. private _needDepthPrePass;
  73150. /**
  73151. * Sets the need depth pre-pass value
  73152. */
  73153. /**
  73154. * Gets the depth pre-pass value
  73155. */
  73156. needDepthPrePass: boolean;
  73157. /**
  73158. * Specifies if depth writing should be disabled
  73159. */
  73160. disableDepthWrite: boolean;
  73161. /**
  73162. * Specifies if depth writing should be forced
  73163. */
  73164. forceDepthWrite: boolean;
  73165. /**
  73166. * Specifies if there should be a separate pass for culling
  73167. */
  73168. separateCullingPass: boolean;
  73169. /**
  73170. * Stores the state specifing if fog should be enabled
  73171. */
  73172. private _fogEnabled;
  73173. /**
  73174. * Sets the state for enabling fog
  73175. */
  73176. /**
  73177. * Gets the value of the fog enabled state
  73178. */
  73179. fogEnabled: boolean;
  73180. /**
  73181. * Stores the size of points
  73182. */
  73183. pointSize: number;
  73184. /**
  73185. * Stores the z offset value
  73186. */
  73187. zOffset: number;
  73188. /**
  73189. * Gets a value specifying if wireframe mode is enabled
  73190. */
  73191. /**
  73192. * Sets the state of wireframe mode
  73193. */
  73194. wireframe: boolean;
  73195. /**
  73196. * Gets the value specifying if point clouds are enabled
  73197. */
  73198. /**
  73199. * Sets the state of point cloud mode
  73200. */
  73201. pointsCloud: boolean;
  73202. /**
  73203. * Gets the material fill mode
  73204. */
  73205. /**
  73206. * Sets the material fill mode
  73207. */
  73208. fillMode: number;
  73209. /**
  73210. * @hidden
  73211. * Stores the effects for the material
  73212. */
  73213. _effect: Nullable<Effect>;
  73214. /**
  73215. * @hidden
  73216. * Specifies if the material was previously ready
  73217. */
  73218. _wasPreviouslyReady: boolean;
  73219. /**
  73220. * Specifies if uniform buffers should be used
  73221. */
  73222. private _useUBO;
  73223. /**
  73224. * Stores a reference to the scene
  73225. */
  73226. private _scene;
  73227. /**
  73228. * Stores the fill mode state
  73229. */
  73230. private _fillMode;
  73231. /**
  73232. * Specifies if the depth write state should be cached
  73233. */
  73234. private _cachedDepthWriteState;
  73235. /**
  73236. * Stores the uniform buffer
  73237. */
  73238. protected _uniformBuffer: UniformBuffer;
  73239. /** @hidden */
  73240. _indexInSceneMaterialArray: number;
  73241. /** @hidden */
  73242. meshMap: Nullable<{
  73243. [id: string]: AbstractMesh | undefined;
  73244. }>;
  73245. /**
  73246. * Creates a material instance
  73247. * @param name defines the name of the material
  73248. * @param scene defines the scene to reference
  73249. * @param doNotAdd specifies if the material should be added to the scene
  73250. */
  73251. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  73252. /**
  73253. * Returns a string representation of the current material
  73254. * @param fullDetails defines a boolean indicating which levels of logging is desired
  73255. * @returns a string with material information
  73256. */
  73257. toString(fullDetails?: boolean): string;
  73258. /**
  73259. * Gets the class name of the material
  73260. * @returns a string with the class name of the material
  73261. */
  73262. getClassName(): string;
  73263. /**
  73264. * Specifies if updates for the material been locked
  73265. */
  73266. readonly isFrozen: boolean;
  73267. /**
  73268. * Locks updates for the material
  73269. */
  73270. freeze(): void;
  73271. /**
  73272. * Unlocks updates for the material
  73273. */
  73274. unfreeze(): void;
  73275. /**
  73276. * Specifies if the material is ready to be used
  73277. * @param mesh defines the mesh to check
  73278. * @param useInstances specifies if instances should be used
  73279. * @returns a boolean indicating if the material is ready to be used
  73280. */
  73281. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  73282. /**
  73283. * Specifies that the submesh is ready to be used
  73284. * @param mesh defines the mesh to check
  73285. * @param subMesh defines which submesh to check
  73286. * @param useInstances specifies that instances should be used
  73287. * @returns a boolean indicating that the submesh is ready or not
  73288. */
  73289. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  73290. /**
  73291. * Returns the material effect
  73292. * @returns the effect associated with the material
  73293. */
  73294. getEffect(): Nullable<Effect>;
  73295. /**
  73296. * Returns the current scene
  73297. * @returns a Scene
  73298. */
  73299. getScene(): Scene;
  73300. /**
  73301. * Specifies if the material will require alpha blending
  73302. * @returns a boolean specifying if alpha blending is needed
  73303. */
  73304. needAlphaBlending(): boolean;
  73305. /**
  73306. * Specifies if the mesh will require alpha blending
  73307. * @param mesh defines the mesh to check
  73308. * @returns a boolean specifying if alpha blending is needed for the mesh
  73309. */
  73310. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  73311. /**
  73312. * Specifies if this material should be rendered in alpha test mode
  73313. * @returns a boolean specifying if an alpha test is needed.
  73314. */
  73315. needAlphaTesting(): boolean;
  73316. /**
  73317. * Gets the texture used for the alpha test
  73318. * @returns the texture to use for alpha testing
  73319. */
  73320. getAlphaTestTexture(): Nullable<BaseTexture>;
  73321. /**
  73322. * Marks the material to indicate that it needs to be re-calculated
  73323. */
  73324. markDirty(): void;
  73325. /** @hidden */
  73326. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  73327. /**
  73328. * Binds the material to the mesh
  73329. * @param world defines the world transformation matrix
  73330. * @param mesh defines the mesh to bind the material to
  73331. */
  73332. bind(world: Matrix, mesh?: Mesh): void;
  73333. /**
  73334. * Binds the submesh to the material
  73335. * @param world defines the world transformation matrix
  73336. * @param mesh defines the mesh containing the submesh
  73337. * @param subMesh defines the submesh to bind the material to
  73338. */
  73339. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  73340. /**
  73341. * Binds the world matrix to the material
  73342. * @param world defines the world transformation matrix
  73343. */
  73344. bindOnlyWorldMatrix(world: Matrix): void;
  73345. /**
  73346. * Binds the scene's uniform buffer to the effect.
  73347. * @param effect defines the effect to bind to the scene uniform buffer
  73348. * @param sceneUbo defines the uniform buffer storing scene data
  73349. */
  73350. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  73351. /**
  73352. * Binds the view matrix to the effect
  73353. * @param effect defines the effect to bind the view matrix to
  73354. */
  73355. bindView(effect: Effect): void;
  73356. /**
  73357. * Binds the view projection matrix to the effect
  73358. * @param effect defines the effect to bind the view projection matrix to
  73359. */
  73360. bindViewProjection(effect: Effect): void;
  73361. /**
  73362. * Specifies if material alpha testing should be turned on for the mesh
  73363. * @param mesh defines the mesh to check
  73364. */
  73365. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  73366. /**
  73367. * Processes to execute after binding the material to a mesh
  73368. * @param mesh defines the rendered mesh
  73369. */
  73370. protected _afterBind(mesh?: Mesh): void;
  73371. /**
  73372. * Unbinds the material from the mesh
  73373. */
  73374. unbind(): void;
  73375. /**
  73376. * Gets the active textures from the material
  73377. * @returns an array of textures
  73378. */
  73379. getActiveTextures(): BaseTexture[];
  73380. /**
  73381. * Specifies if the material uses a texture
  73382. * @param texture defines the texture to check against the material
  73383. * @returns a boolean specifying if the material uses the texture
  73384. */
  73385. hasTexture(texture: BaseTexture): boolean;
  73386. /**
  73387. * Makes a duplicate of the material, and gives it a new name
  73388. * @param name defines the new name for the duplicated material
  73389. * @returns the cloned material
  73390. */
  73391. clone(name: string): Nullable<Material>;
  73392. /**
  73393. * Gets the meshes bound to the material
  73394. * @returns an array of meshes bound to the material
  73395. */
  73396. getBindedMeshes(): AbstractMesh[];
  73397. /**
  73398. * Force shader compilation
  73399. * @param mesh defines the mesh associated with this material
  73400. * @param onCompiled defines a function to execute once the material is compiled
  73401. * @param options defines the options to configure the compilation
  73402. */
  73403. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  73404. clipPlane: boolean;
  73405. }>): void;
  73406. /**
  73407. * Force shader compilation
  73408. * @param mesh defines the mesh that will use this material
  73409. * @param options defines additional options for compiling the shaders
  73410. * @returns a promise that resolves when the compilation completes
  73411. */
  73412. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  73413. clipPlane: boolean;
  73414. }>): Promise<void>;
  73415. private static readonly _ImageProcessingDirtyCallBack;
  73416. private static readonly _TextureDirtyCallBack;
  73417. private static readonly _FresnelDirtyCallBack;
  73418. private static readonly _MiscDirtyCallBack;
  73419. private static readonly _LightsDirtyCallBack;
  73420. private static readonly _AttributeDirtyCallBack;
  73421. private static _FresnelAndMiscDirtyCallBack;
  73422. private static _TextureAndMiscDirtyCallBack;
  73423. private static readonly _DirtyCallbackArray;
  73424. private static readonly _RunDirtyCallBacks;
  73425. /**
  73426. * Marks a define in the material to indicate that it needs to be re-computed
  73427. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  73428. */
  73429. markAsDirty(flag: number): void;
  73430. /**
  73431. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  73432. * @param func defines a function which checks material defines against the submeshes
  73433. */
  73434. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  73435. /**
  73436. * Indicates that image processing needs to be re-calculated for all submeshes
  73437. */
  73438. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  73439. /**
  73440. * Indicates that textures need to be re-calculated for all submeshes
  73441. */
  73442. protected _markAllSubMeshesAsTexturesDirty(): void;
  73443. /**
  73444. * Indicates that fresnel needs to be re-calculated for all submeshes
  73445. */
  73446. protected _markAllSubMeshesAsFresnelDirty(): void;
  73447. /**
  73448. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  73449. */
  73450. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  73451. /**
  73452. * Indicates that lights need to be re-calculated for all submeshes
  73453. */
  73454. protected _markAllSubMeshesAsLightsDirty(): void;
  73455. /**
  73456. * Indicates that attributes need to be re-calculated for all submeshes
  73457. */
  73458. protected _markAllSubMeshesAsAttributesDirty(): void;
  73459. /**
  73460. * Indicates that misc needs to be re-calculated for all submeshes
  73461. */
  73462. protected _markAllSubMeshesAsMiscDirty(): void;
  73463. /**
  73464. * Indicates that textures and misc need to be re-calculated for all submeshes
  73465. */
  73466. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  73467. /**
  73468. * Disposes the material
  73469. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  73470. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  73471. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  73472. */
  73473. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  73474. /** @hidden */
  73475. private releaseVertexArrayObject;
  73476. /**
  73477. * Serializes this material
  73478. * @returns the serialized material object
  73479. */
  73480. serialize(): any;
  73481. /**
  73482. * Creates a material from parsed material data
  73483. * @param parsedMaterial defines parsed material data
  73484. * @param scene defines the hosting scene
  73485. * @param rootUrl defines the root URL to use to load textures
  73486. * @returns a new material
  73487. */
  73488. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  73489. }
  73490. }
  73491. declare module BABYLON {
  73492. /**
  73493. * Class used to represent data loading progression
  73494. */
  73495. export class SceneLoaderFlags {
  73496. private static _ForceFullSceneLoadingForIncremental;
  73497. private static _ShowLoadingScreen;
  73498. private static _CleanBoneMatrixWeights;
  73499. private static _loggingLevel;
  73500. /**
  73501. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  73502. */
  73503. static ForceFullSceneLoadingForIncremental: boolean;
  73504. /**
  73505. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  73506. */
  73507. static ShowLoadingScreen: boolean;
  73508. /**
  73509. * Defines the current logging level (while loading the scene)
  73510. * @ignorenaming
  73511. */
  73512. static loggingLevel: number;
  73513. /**
  73514. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  73515. */
  73516. static CleanBoneMatrixWeights: boolean;
  73517. }
  73518. }
  73519. declare module BABYLON {
  73520. /**
  73521. * Class used to override all child animations of a given target
  73522. */
  73523. export class AnimationPropertiesOverride {
  73524. /**
  73525. * Gets or sets a value indicating if animation blending must be used
  73526. */
  73527. enableBlending: boolean;
  73528. /**
  73529. * Gets or sets the blending speed to use when enableBlending is true
  73530. */
  73531. blendingSpeed: number;
  73532. /**
  73533. * Gets or sets the default loop mode to use
  73534. */
  73535. loopMode: number;
  73536. }
  73537. }
  73538. declare module BABYLON {
  73539. /**
  73540. * Defines a target to use with MorphTargetManager
  73541. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73542. */
  73543. export class MorphTarget implements IAnimatable {
  73544. /** defines the name of the target */
  73545. name: string;
  73546. /**
  73547. * Gets or sets the list of animations
  73548. */
  73549. animations: Animation[];
  73550. private _scene;
  73551. private _positions;
  73552. private _normals;
  73553. private _tangents;
  73554. private _influence;
  73555. /**
  73556. * Observable raised when the influence changes
  73557. */
  73558. onInfluenceChanged: Observable<boolean>;
  73559. /** @hidden */
  73560. _onDataLayoutChanged: Observable<void>;
  73561. /**
  73562. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  73563. */
  73564. influence: number;
  73565. /**
  73566. * Gets or sets the id of the morph Target
  73567. */
  73568. id: string;
  73569. private _animationPropertiesOverride;
  73570. /**
  73571. * Gets or sets the animation properties override
  73572. */
  73573. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  73574. /**
  73575. * Creates a new MorphTarget
  73576. * @param name defines the name of the target
  73577. * @param influence defines the influence to use
  73578. * @param scene defines the scene the morphtarget belongs to
  73579. */
  73580. constructor(
  73581. /** defines the name of the target */
  73582. name: string, influence?: number, scene?: Nullable<Scene>);
  73583. /**
  73584. * Gets a boolean defining if the target contains position data
  73585. */
  73586. readonly hasPositions: boolean;
  73587. /**
  73588. * Gets a boolean defining if the target contains normal data
  73589. */
  73590. readonly hasNormals: boolean;
  73591. /**
  73592. * Gets a boolean defining if the target contains tangent data
  73593. */
  73594. readonly hasTangents: boolean;
  73595. /**
  73596. * Affects position data to this target
  73597. * @param data defines the position data to use
  73598. */
  73599. setPositions(data: Nullable<FloatArray>): void;
  73600. /**
  73601. * Gets the position data stored in this target
  73602. * @returns a FloatArray containing the position data (or null if not present)
  73603. */
  73604. getPositions(): Nullable<FloatArray>;
  73605. /**
  73606. * Affects normal data to this target
  73607. * @param data defines the normal data to use
  73608. */
  73609. setNormals(data: Nullable<FloatArray>): void;
  73610. /**
  73611. * Gets the normal data stored in this target
  73612. * @returns a FloatArray containing the normal data (or null if not present)
  73613. */
  73614. getNormals(): Nullable<FloatArray>;
  73615. /**
  73616. * Affects tangent data to this target
  73617. * @param data defines the tangent data to use
  73618. */
  73619. setTangents(data: Nullable<FloatArray>): void;
  73620. /**
  73621. * Gets the tangent data stored in this target
  73622. * @returns a FloatArray containing the tangent data (or null if not present)
  73623. */
  73624. getTangents(): Nullable<FloatArray>;
  73625. /**
  73626. * Serializes the current target into a Serialization object
  73627. * @returns the serialized object
  73628. */
  73629. serialize(): any;
  73630. /**
  73631. * Returns the string "MorphTarget"
  73632. * @returns "MorphTarget"
  73633. */
  73634. getClassName(): string;
  73635. /**
  73636. * Creates a new target from serialized data
  73637. * @param serializationObject defines the serialized data to use
  73638. * @returns a new MorphTarget
  73639. */
  73640. static Parse(serializationObject: any): MorphTarget;
  73641. /**
  73642. * Creates a MorphTarget from mesh data
  73643. * @param mesh defines the source mesh
  73644. * @param name defines the name to use for the new target
  73645. * @param influence defines the influence to attach to the target
  73646. * @returns a new MorphTarget
  73647. */
  73648. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  73649. }
  73650. }
  73651. declare module BABYLON {
  73652. /**
  73653. * This class is used to deform meshes using morphing between different targets
  73654. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  73655. */
  73656. export class MorphTargetManager {
  73657. private _targets;
  73658. private _targetInfluenceChangedObservers;
  73659. private _targetDataLayoutChangedObservers;
  73660. private _activeTargets;
  73661. private _scene;
  73662. private _influences;
  73663. private _supportsNormals;
  73664. private _supportsTangents;
  73665. private _vertexCount;
  73666. private _uniqueId;
  73667. private _tempInfluences;
  73668. /**
  73669. * Creates a new MorphTargetManager
  73670. * @param scene defines the current scene
  73671. */
  73672. constructor(scene?: Nullable<Scene>);
  73673. /**
  73674. * Gets the unique ID of this manager
  73675. */
  73676. readonly uniqueId: number;
  73677. /**
  73678. * Gets the number of vertices handled by this manager
  73679. */
  73680. readonly vertexCount: number;
  73681. /**
  73682. * Gets a boolean indicating if this manager supports morphing of normals
  73683. */
  73684. readonly supportsNormals: boolean;
  73685. /**
  73686. * Gets a boolean indicating if this manager supports morphing of tangents
  73687. */
  73688. readonly supportsTangents: boolean;
  73689. /**
  73690. * Gets the number of targets stored in this manager
  73691. */
  73692. readonly numTargets: number;
  73693. /**
  73694. * Gets the number of influencers (ie. the number of targets with influences > 0)
  73695. */
  73696. readonly numInfluencers: number;
  73697. /**
  73698. * Gets the list of influences (one per target)
  73699. */
  73700. readonly influences: Float32Array;
  73701. /**
  73702. * Gets the active target at specified index. An active target is a target with an influence > 0
  73703. * @param index defines the index to check
  73704. * @returns the requested target
  73705. */
  73706. getActiveTarget(index: number): MorphTarget;
  73707. /**
  73708. * Gets the target at specified index
  73709. * @param index defines the index to check
  73710. * @returns the requested target
  73711. */
  73712. getTarget(index: number): MorphTarget;
  73713. /**
  73714. * Add a new target to this manager
  73715. * @param target defines the target to add
  73716. */
  73717. addTarget(target: MorphTarget): void;
  73718. /**
  73719. * Removes a target from the manager
  73720. * @param target defines the target to remove
  73721. */
  73722. removeTarget(target: MorphTarget): void;
  73723. /**
  73724. * Serializes the current manager into a Serialization object
  73725. * @returns the serialized object
  73726. */
  73727. serialize(): any;
  73728. private _syncActiveTargets;
  73729. /**
  73730. * Syncrhonize the targets with all the meshes using this morph target manager
  73731. */
  73732. synchronize(): void;
  73733. /**
  73734. * Creates a new MorphTargetManager from serialized data
  73735. * @param serializationObject defines the serialized data
  73736. * @param scene defines the hosting scene
  73737. * @returns the new MorphTargetManager
  73738. */
  73739. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  73740. }
  73741. }
  73742. declare module BABYLON {
  73743. /**
  73744. * Interface for Physics-Joint data
  73745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73746. */
  73747. export interface PhysicsJointData {
  73748. /**
  73749. * The main pivot of the joint
  73750. */
  73751. mainPivot?: Vector3;
  73752. /**
  73753. * The connected pivot of the joint
  73754. */
  73755. connectedPivot?: Vector3;
  73756. /**
  73757. * The main axis of the joint
  73758. */
  73759. mainAxis?: Vector3;
  73760. /**
  73761. * The connected axis of the joint
  73762. */
  73763. connectedAxis?: Vector3;
  73764. /**
  73765. * The collision of the joint
  73766. */
  73767. collision?: boolean;
  73768. /**
  73769. * Native Oimo/Cannon/Energy data
  73770. */
  73771. nativeParams?: any;
  73772. }
  73773. /**
  73774. * This is a holder class for the physics joint created by the physics plugin
  73775. * It holds a set of functions to control the underlying joint
  73776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73777. */
  73778. export class PhysicsJoint {
  73779. /**
  73780. * The type of the physics joint
  73781. */
  73782. type: number;
  73783. /**
  73784. * The data for the physics joint
  73785. */
  73786. jointData: PhysicsJointData;
  73787. private _physicsJoint;
  73788. protected _physicsPlugin: IPhysicsEnginePlugin;
  73789. /**
  73790. * Initializes the physics joint
  73791. * @param type The type of the physics joint
  73792. * @param jointData The data for the physics joint
  73793. */
  73794. constructor(
  73795. /**
  73796. * The type of the physics joint
  73797. */
  73798. type: number,
  73799. /**
  73800. * The data for the physics joint
  73801. */
  73802. jointData: PhysicsJointData);
  73803. /**
  73804. * Gets the physics joint
  73805. */
  73806. /**
  73807. * Sets the physics joint
  73808. */
  73809. physicsJoint: any;
  73810. /**
  73811. * Sets the physics plugin
  73812. */
  73813. physicsPlugin: IPhysicsEnginePlugin;
  73814. /**
  73815. * Execute a function that is physics-plugin specific.
  73816. * @param {Function} func the function that will be executed.
  73817. * It accepts two parameters: the physics world and the physics joint
  73818. */
  73819. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  73820. /**
  73821. * Distance-Joint type
  73822. */
  73823. static DistanceJoint: number;
  73824. /**
  73825. * Hinge-Joint type
  73826. */
  73827. static HingeJoint: number;
  73828. /**
  73829. * Ball-and-Socket joint type
  73830. */
  73831. static BallAndSocketJoint: number;
  73832. /**
  73833. * Wheel-Joint type
  73834. */
  73835. static WheelJoint: number;
  73836. /**
  73837. * Slider-Joint type
  73838. */
  73839. static SliderJoint: number;
  73840. /**
  73841. * Prismatic-Joint type
  73842. */
  73843. static PrismaticJoint: number;
  73844. /**
  73845. * Universal-Joint type
  73846. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  73847. */
  73848. static UniversalJoint: number;
  73849. /**
  73850. * Hinge-Joint 2 type
  73851. */
  73852. static Hinge2Joint: number;
  73853. /**
  73854. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  73855. */
  73856. static PointToPointJoint: number;
  73857. /**
  73858. * Spring-Joint type
  73859. */
  73860. static SpringJoint: number;
  73861. /**
  73862. * Lock-Joint type
  73863. */
  73864. static LockJoint: number;
  73865. }
  73866. /**
  73867. * A class representing a physics distance joint
  73868. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73869. */
  73870. export class DistanceJoint extends PhysicsJoint {
  73871. /**
  73872. *
  73873. * @param jointData The data for the Distance-Joint
  73874. */
  73875. constructor(jointData: DistanceJointData);
  73876. /**
  73877. * Update the predefined distance.
  73878. * @param maxDistance The maximum preferred distance
  73879. * @param minDistance The minimum preferred distance
  73880. */
  73881. updateDistance(maxDistance: number, minDistance?: number): void;
  73882. }
  73883. /**
  73884. * Represents a Motor-Enabled Joint
  73885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73886. */
  73887. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  73888. /**
  73889. * Initializes the Motor-Enabled Joint
  73890. * @param type The type of the joint
  73891. * @param jointData The physica joint data for the joint
  73892. */
  73893. constructor(type: number, jointData: PhysicsJointData);
  73894. /**
  73895. * Set the motor values.
  73896. * Attention, this function is plugin specific. Engines won't react 100% the same.
  73897. * @param force the force to apply
  73898. * @param maxForce max force for this motor.
  73899. */
  73900. setMotor(force?: number, maxForce?: number): void;
  73901. /**
  73902. * Set the motor's limits.
  73903. * Attention, this function is plugin specific. Engines won't react 100% the same.
  73904. * @param upperLimit The upper limit of the motor
  73905. * @param lowerLimit The lower limit of the motor
  73906. */
  73907. setLimit(upperLimit: number, lowerLimit?: number): void;
  73908. }
  73909. /**
  73910. * This class represents a single physics Hinge-Joint
  73911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73912. */
  73913. export class HingeJoint extends MotorEnabledJoint {
  73914. /**
  73915. * Initializes the Hinge-Joint
  73916. * @param jointData The joint data for the Hinge-Joint
  73917. */
  73918. constructor(jointData: PhysicsJointData);
  73919. /**
  73920. * Set the motor values.
  73921. * Attention, this function is plugin specific. Engines won't react 100% the same.
  73922. * @param {number} force the force to apply
  73923. * @param {number} maxForce max force for this motor.
  73924. */
  73925. setMotor(force?: number, maxForce?: number): void;
  73926. /**
  73927. * Set the motor's limits.
  73928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  73929. * @param upperLimit The upper limit of the motor
  73930. * @param lowerLimit The lower limit of the motor
  73931. */
  73932. setLimit(upperLimit: number, lowerLimit?: number): void;
  73933. }
  73934. /**
  73935. * This class represents a dual hinge physics joint (same as wheel joint)
  73936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73937. */
  73938. export class Hinge2Joint extends MotorEnabledJoint {
  73939. /**
  73940. * Initializes the Hinge2-Joint
  73941. * @param jointData The joint data for the Hinge2-Joint
  73942. */
  73943. constructor(jointData: PhysicsJointData);
  73944. /**
  73945. * Set the motor values.
  73946. * Attention, this function is plugin specific. Engines won't react 100% the same.
  73947. * @param {number} force the force to apply
  73948. * @param {number} maxForce max force for this motor.
  73949. * @param {motorIndex} the motor's index, 0 or 1.
  73950. */
  73951. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  73952. /**
  73953. * Set the motor limits.
  73954. * Attention, this function is plugin specific. Engines won't react 100% the same.
  73955. * @param {number} upperLimit the upper limit
  73956. * @param {number} lowerLimit lower limit
  73957. * @param {motorIndex} the motor's index, 0 or 1.
  73958. */
  73959. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  73960. }
  73961. /**
  73962. * Interface for a motor enabled joint
  73963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73964. */
  73965. export interface IMotorEnabledJoint {
  73966. /**
  73967. * Physics joint
  73968. */
  73969. physicsJoint: any;
  73970. /**
  73971. * Sets the motor of the motor-enabled joint
  73972. * @param force The force of the motor
  73973. * @param maxForce The maximum force of the motor
  73974. * @param motorIndex The index of the motor
  73975. */
  73976. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  73977. /**
  73978. * Sets the limit of the motor
  73979. * @param upperLimit The upper limit of the motor
  73980. * @param lowerLimit The lower limit of the motor
  73981. * @param motorIndex The index of the motor
  73982. */
  73983. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  73984. }
  73985. /**
  73986. * Joint data for a Distance-Joint
  73987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73988. */
  73989. export interface DistanceJointData extends PhysicsJointData {
  73990. /**
  73991. * Max distance the 2 joint objects can be apart
  73992. */
  73993. maxDistance: number;
  73994. }
  73995. /**
  73996. * Joint data from a spring joint
  73997. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73998. */
  73999. export interface SpringJointData extends PhysicsJointData {
  74000. /**
  74001. * Length of the spring
  74002. */
  74003. length: number;
  74004. /**
  74005. * Stiffness of the spring
  74006. */
  74007. stiffness: number;
  74008. /**
  74009. * Damping of the spring
  74010. */
  74011. damping: number;
  74012. /** this callback will be called when applying the force to the impostors. */
  74013. forceApplicationCallback: () => void;
  74014. }
  74015. }
  74016. declare module BABYLON {
  74017. /**
  74018. * Interface used to describe a physics joint
  74019. */
  74020. export interface PhysicsImpostorJoint {
  74021. /** Defines the main impostor to which the joint is linked */
  74022. mainImpostor: PhysicsImpostor;
  74023. /** Defines the impostor that is connected to the main impostor using this joint */
  74024. connectedImpostor: PhysicsImpostor;
  74025. /** Defines the joint itself */
  74026. joint: PhysicsJoint;
  74027. }
  74028. /** @hidden */
  74029. export interface IPhysicsEnginePlugin {
  74030. world: any;
  74031. name: string;
  74032. setGravity(gravity: Vector3): void;
  74033. setTimeStep(timeStep: number): void;
  74034. getTimeStep(): number;
  74035. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  74036. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74037. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  74038. generatePhysicsBody(impostor: PhysicsImpostor): void;
  74039. removePhysicsBody(impostor: PhysicsImpostor): void;
  74040. generateJoint(joint: PhysicsImpostorJoint): void;
  74041. removeJoint(joint: PhysicsImpostorJoint): void;
  74042. isSupported(): boolean;
  74043. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  74044. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  74045. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74046. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  74047. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74048. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  74049. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  74050. getBodyMass(impostor: PhysicsImpostor): number;
  74051. getBodyFriction(impostor: PhysicsImpostor): number;
  74052. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  74053. getBodyRestitution(impostor: PhysicsImpostor): number;
  74054. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  74055. sleepBody(impostor: PhysicsImpostor): void;
  74056. wakeUpBody(impostor: PhysicsImpostor): void;
  74057. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  74058. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  74059. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  74060. getRadius(impostor: PhysicsImpostor): number;
  74061. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  74062. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  74063. dispose(): void;
  74064. }
  74065. /**
  74066. * Interface used to define a physics engine
  74067. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  74068. */
  74069. export interface IPhysicsEngine {
  74070. /**
  74071. * Gets the gravity vector used by the simulation
  74072. */
  74073. gravity: Vector3;
  74074. /**
  74075. * Sets the gravity vector used by the simulation
  74076. * @param gravity defines the gravity vector to use
  74077. */
  74078. setGravity(gravity: Vector3): void;
  74079. /**
  74080. * Set the time step of the physics engine.
  74081. * Default is 1/60.
  74082. * To slow it down, enter 1/600 for example.
  74083. * To speed it up, 1/30
  74084. * @param newTimeStep the new timestep to apply to this world.
  74085. */
  74086. setTimeStep(newTimeStep: number): void;
  74087. /**
  74088. * Get the time step of the physics engine.
  74089. * @returns the current time step
  74090. */
  74091. getTimeStep(): number;
  74092. /**
  74093. * Release all resources
  74094. */
  74095. dispose(): void;
  74096. /**
  74097. * Gets the name of the current physics plugin
  74098. * @returns the name of the plugin
  74099. */
  74100. getPhysicsPluginName(): string;
  74101. /**
  74102. * Adding a new impostor for the impostor tracking.
  74103. * This will be done by the impostor itself.
  74104. * @param impostor the impostor to add
  74105. */
  74106. addImpostor(impostor: PhysicsImpostor): void;
  74107. /**
  74108. * Remove an impostor from the engine.
  74109. * This impostor and its mesh will not longer be updated by the physics engine.
  74110. * @param impostor the impostor to remove
  74111. */
  74112. removeImpostor(impostor: PhysicsImpostor): void;
  74113. /**
  74114. * Add a joint to the physics engine
  74115. * @param mainImpostor defines the main impostor to which the joint is added.
  74116. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  74117. * @param joint defines the joint that will connect both impostors.
  74118. */
  74119. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74120. /**
  74121. * Removes a joint from the simulation
  74122. * @param mainImpostor defines the impostor used with the joint
  74123. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  74124. * @param joint defines the joint to remove
  74125. */
  74126. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  74127. /**
  74128. * Gets the current plugin used to run the simulation
  74129. * @returns current plugin
  74130. */
  74131. getPhysicsPlugin(): IPhysicsEnginePlugin;
  74132. /**
  74133. * Gets the list of physic impostors
  74134. * @returns an array of PhysicsImpostor
  74135. */
  74136. getImpostors(): Array<PhysicsImpostor>;
  74137. /**
  74138. * Gets the impostor for a physics enabled object
  74139. * @param object defines the object impersonated by the impostor
  74140. * @returns the PhysicsImpostor or null if not found
  74141. */
  74142. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  74143. /**
  74144. * Gets the impostor for a physics body object
  74145. * @param body defines physics body used by the impostor
  74146. * @returns the PhysicsImpostor or null if not found
  74147. */
  74148. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  74149. /**
  74150. * Called by the scene. No need to call it.
  74151. * @param delta defines the timespam between frames
  74152. */
  74153. _step(delta: number): void;
  74154. }
  74155. }
  74156. declare module BABYLON {
  74157. /**
  74158. * The interface for the physics imposter parameters
  74159. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74160. */
  74161. export interface PhysicsImpostorParameters {
  74162. /**
  74163. * The mass of the physics imposter
  74164. */
  74165. mass: number;
  74166. /**
  74167. * The friction of the physics imposter
  74168. */
  74169. friction?: number;
  74170. /**
  74171. * The coefficient of restitution of the physics imposter
  74172. */
  74173. restitution?: number;
  74174. /**
  74175. * The native options of the physics imposter
  74176. */
  74177. nativeOptions?: any;
  74178. /**
  74179. * Specifies if the parent should be ignored
  74180. */
  74181. ignoreParent?: boolean;
  74182. /**
  74183. * Specifies if bi-directional transformations should be disabled
  74184. */
  74185. disableBidirectionalTransformation?: boolean;
  74186. }
  74187. /**
  74188. * Interface for a physics-enabled object
  74189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74190. */
  74191. export interface IPhysicsEnabledObject {
  74192. /**
  74193. * The position of the physics-enabled object
  74194. */
  74195. position: Vector3;
  74196. /**
  74197. * The rotation of the physics-enabled object
  74198. */
  74199. rotationQuaternion: Nullable<Quaternion>;
  74200. /**
  74201. * The scale of the physics-enabled object
  74202. */
  74203. scaling: Vector3;
  74204. /**
  74205. * The rotation of the physics-enabled object
  74206. */
  74207. rotation?: Vector3;
  74208. /**
  74209. * The parent of the physics-enabled object
  74210. */
  74211. parent?: any;
  74212. /**
  74213. * The bounding info of the physics-enabled object
  74214. * @returns The bounding info of the physics-enabled object
  74215. */
  74216. getBoundingInfo(): BoundingInfo;
  74217. /**
  74218. * Computes the world matrix
  74219. * @param force Specifies if the world matrix should be computed by force
  74220. * @returns A world matrix
  74221. */
  74222. computeWorldMatrix(force: boolean): Matrix;
  74223. /**
  74224. * Gets the world matrix
  74225. * @returns A world matrix
  74226. */
  74227. getWorldMatrix?(): Matrix;
  74228. /**
  74229. * Gets the child meshes
  74230. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  74231. * @returns An array of abstract meshes
  74232. */
  74233. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  74234. /**
  74235. * Gets the vertex data
  74236. * @param kind The type of vertex data
  74237. * @returns A nullable array of numbers, or a float32 array
  74238. */
  74239. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  74240. /**
  74241. * Gets the indices from the mesh
  74242. * @returns A nullable array of index arrays
  74243. */
  74244. getIndices?(): Nullable<IndicesArray>;
  74245. /**
  74246. * Gets the scene from the mesh
  74247. * @returns the indices array or null
  74248. */
  74249. getScene?(): Scene;
  74250. /**
  74251. * Gets the absolute position from the mesh
  74252. * @returns the absolute position
  74253. */
  74254. getAbsolutePosition(): Vector3;
  74255. /**
  74256. * Gets the absolute pivot point from the mesh
  74257. * @returns the absolute pivot point
  74258. */
  74259. getAbsolutePivotPoint(): Vector3;
  74260. /**
  74261. * Rotates the mesh
  74262. * @param axis The axis of rotation
  74263. * @param amount The amount of rotation
  74264. * @param space The space of the rotation
  74265. * @returns The rotation transform node
  74266. */
  74267. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  74268. /**
  74269. * Translates the mesh
  74270. * @param axis The axis of translation
  74271. * @param distance The distance of translation
  74272. * @param space The space of the translation
  74273. * @returns The transform node
  74274. */
  74275. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  74276. /**
  74277. * Sets the absolute position of the mesh
  74278. * @param absolutePosition The absolute position of the mesh
  74279. * @returns The transform node
  74280. */
  74281. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  74282. /**
  74283. * Gets the class name of the mesh
  74284. * @returns The class name
  74285. */
  74286. getClassName(): string;
  74287. }
  74288. /**
  74289. * Represents a physics imposter
  74290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  74291. */
  74292. export class PhysicsImpostor {
  74293. /**
  74294. * The physics-enabled object used as the physics imposter
  74295. */
  74296. object: IPhysicsEnabledObject;
  74297. /**
  74298. * The type of the physics imposter
  74299. */
  74300. type: number;
  74301. private _options;
  74302. private _scene?;
  74303. /**
  74304. * The default object size of the imposter
  74305. */
  74306. static DEFAULT_OBJECT_SIZE: Vector3;
  74307. /**
  74308. * The identity quaternion of the imposter
  74309. */
  74310. static IDENTITY_QUATERNION: Quaternion;
  74311. /** @hidden */
  74312. _pluginData: any;
  74313. private _physicsEngine;
  74314. private _physicsBody;
  74315. private _bodyUpdateRequired;
  74316. private _onBeforePhysicsStepCallbacks;
  74317. private _onAfterPhysicsStepCallbacks;
  74318. /** @hidden */
  74319. _onPhysicsCollideCallbacks: Array<{
  74320. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  74321. otherImpostors: Array<PhysicsImpostor>;
  74322. }>;
  74323. private _deltaPosition;
  74324. private _deltaRotation;
  74325. private _deltaRotationConjugated;
  74326. private _parent;
  74327. private _isDisposed;
  74328. private static _tmpVecs;
  74329. private static _tmpQuat;
  74330. /**
  74331. * Specifies if the physics imposter is disposed
  74332. */
  74333. readonly isDisposed: boolean;
  74334. /**
  74335. * Gets the mass of the physics imposter
  74336. */
  74337. mass: number;
  74338. /**
  74339. * Gets the coefficient of friction
  74340. */
  74341. /**
  74342. * Sets the coefficient of friction
  74343. */
  74344. friction: number;
  74345. /**
  74346. * Gets the coefficient of restitution
  74347. */
  74348. /**
  74349. * Sets the coefficient of restitution
  74350. */
  74351. restitution: number;
  74352. /**
  74353. * The unique id of the physics imposter
  74354. * set by the physics engine when adding this impostor to the array
  74355. */
  74356. uniqueId: number;
  74357. private _joints;
  74358. /**
  74359. * Initializes the physics imposter
  74360. * @param object The physics-enabled object used as the physics imposter
  74361. * @param type The type of the physics imposter
  74362. * @param _options The options for the physics imposter
  74363. * @param _scene The Babylon scene
  74364. */
  74365. constructor(
  74366. /**
  74367. * The physics-enabled object used as the physics imposter
  74368. */
  74369. object: IPhysicsEnabledObject,
  74370. /**
  74371. * The type of the physics imposter
  74372. */
  74373. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  74374. /**
  74375. * This function will completly initialize this impostor.
  74376. * It will create a new body - but only if this mesh has no parent.
  74377. * If it has, this impostor will not be used other than to define the impostor
  74378. * of the child mesh.
  74379. * @hidden
  74380. */
  74381. _init(): void;
  74382. private _getPhysicsParent;
  74383. /**
  74384. * Should a new body be generated.
  74385. * @returns boolean specifying if body initialization is required
  74386. */
  74387. isBodyInitRequired(): boolean;
  74388. /**
  74389. * Sets the updated scaling
  74390. * @param updated Specifies if the scaling is updated
  74391. */
  74392. setScalingUpdated(): void;
  74393. /**
  74394. * Force a regeneration of this or the parent's impostor's body.
  74395. * Use under cautious - This will remove all joints already implemented.
  74396. */
  74397. forceUpdate(): void;
  74398. /**
  74399. * Gets the body that holds this impostor. Either its own, or its parent.
  74400. */
  74401. /**
  74402. * Set the physics body. Used mainly by the physics engine/plugin
  74403. */
  74404. physicsBody: any;
  74405. /**
  74406. * Get the parent of the physics imposter
  74407. * @returns Physics imposter or null
  74408. */
  74409. /**
  74410. * Sets the parent of the physics imposter
  74411. */
  74412. parent: Nullable<PhysicsImpostor>;
  74413. /**
  74414. * Resets the update flags
  74415. */
  74416. resetUpdateFlags(): void;
  74417. /**
  74418. * Gets the object extend size
  74419. * @returns the object extend size
  74420. */
  74421. getObjectExtendSize(): Vector3;
  74422. /**
  74423. * Gets the object center
  74424. * @returns The object center
  74425. */
  74426. getObjectCenter(): Vector3;
  74427. /**
  74428. * Get a specific parametes from the options parameter
  74429. * @param paramName The object parameter name
  74430. * @returns The object parameter
  74431. */
  74432. getParam(paramName: string): any;
  74433. /**
  74434. * Sets a specific parameter in the options given to the physics plugin
  74435. * @param paramName The parameter name
  74436. * @param value The value of the parameter
  74437. */
  74438. setParam(paramName: string, value: number): void;
  74439. /**
  74440. * Specifically change the body's mass option. Won't recreate the physics body object
  74441. * @param mass The mass of the physics imposter
  74442. */
  74443. setMass(mass: number): void;
  74444. /**
  74445. * Gets the linear velocity
  74446. * @returns linear velocity or null
  74447. */
  74448. getLinearVelocity(): Nullable<Vector3>;
  74449. /**
  74450. * Sets the linear velocity
  74451. * @param velocity linear velocity or null
  74452. */
  74453. setLinearVelocity(velocity: Nullable<Vector3>): void;
  74454. /**
  74455. * Gets the angular velocity
  74456. * @returns angular velocity or null
  74457. */
  74458. getAngularVelocity(): Nullable<Vector3>;
  74459. /**
  74460. * Sets the angular velocity
  74461. * @param velocity The velocity or null
  74462. */
  74463. setAngularVelocity(velocity: Nullable<Vector3>): void;
  74464. /**
  74465. * Execute a function with the physics plugin native code
  74466. * Provide a function the will have two variables - the world object and the physics body object
  74467. * @param func The function to execute with the physics plugin native code
  74468. */
  74469. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  74470. /**
  74471. * Register a function that will be executed before the physics world is stepping forward
  74472. * @param func The function to execute before the physics world is stepped forward
  74473. */
  74474. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74475. /**
  74476. * Unregister a function that will be executed before the physics world is stepping forward
  74477. * @param func The function to execute before the physics world is stepped forward
  74478. */
  74479. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74480. /**
  74481. * Register a function that will be executed after the physics step
  74482. * @param func The function to execute after physics step
  74483. */
  74484. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74485. /**
  74486. * Unregisters a function that will be executed after the physics step
  74487. * @param func The function to execute after physics step
  74488. */
  74489. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  74490. /**
  74491. * register a function that will be executed when this impostor collides against a different body
  74492. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  74493. * @param func Callback that is executed on collision
  74494. */
  74495. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  74496. /**
  74497. * Unregisters the physics imposter on contact
  74498. * @param collideAgainst The physics object to collide against
  74499. * @param func Callback to execute on collision
  74500. */
  74501. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  74502. private _tmpQuat;
  74503. private _tmpQuat2;
  74504. /**
  74505. * Get the parent rotation
  74506. * @returns The parent rotation
  74507. */
  74508. getParentsRotation(): Quaternion;
  74509. /**
  74510. * this function is executed by the physics engine.
  74511. */
  74512. beforeStep: () => void;
  74513. /**
  74514. * this function is executed by the physics engine
  74515. */
  74516. afterStep: () => void;
  74517. /**
  74518. * Legacy collision detection event support
  74519. */
  74520. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  74521. /**
  74522. * event and body object due to cannon's event-based architecture.
  74523. */
  74524. onCollide: (e: {
  74525. body: any;
  74526. }) => void;
  74527. /**
  74528. * Apply a force
  74529. * @param force The force to apply
  74530. * @param contactPoint The contact point for the force
  74531. * @returns The physics imposter
  74532. */
  74533. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  74534. /**
  74535. * Apply an impulse
  74536. * @param force The impulse force
  74537. * @param contactPoint The contact point for the impulse force
  74538. * @returns The physics imposter
  74539. */
  74540. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  74541. /**
  74542. * A help function to create a joint
  74543. * @param otherImpostor A physics imposter used to create a joint
  74544. * @param jointType The type of joint
  74545. * @param jointData The data for the joint
  74546. * @returns The physics imposter
  74547. */
  74548. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  74549. /**
  74550. * Add a joint to this impostor with a different impostor
  74551. * @param otherImpostor A physics imposter used to add a joint
  74552. * @param joint The joint to add
  74553. * @returns The physics imposter
  74554. */
  74555. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  74556. /**
  74557. * Will keep this body still, in a sleep mode.
  74558. * @returns the physics imposter
  74559. */
  74560. sleep(): PhysicsImpostor;
  74561. /**
  74562. * Wake the body up.
  74563. * @returns The physics imposter
  74564. */
  74565. wakeUp(): PhysicsImpostor;
  74566. /**
  74567. * Clones the physics imposter
  74568. * @param newObject The physics imposter clones to this physics-enabled object
  74569. * @returns A nullable physics imposter
  74570. */
  74571. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  74572. /**
  74573. * Disposes the physics imposter
  74574. */
  74575. dispose(): void;
  74576. /**
  74577. * Sets the delta position
  74578. * @param position The delta position amount
  74579. */
  74580. setDeltaPosition(position: Vector3): void;
  74581. /**
  74582. * Sets the delta rotation
  74583. * @param rotation The delta rotation amount
  74584. */
  74585. setDeltaRotation(rotation: Quaternion): void;
  74586. /**
  74587. * Gets the box size of the physics imposter and stores the result in the input parameter
  74588. * @param result Stores the box size
  74589. * @returns The physics imposter
  74590. */
  74591. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  74592. /**
  74593. * Gets the radius of the physics imposter
  74594. * @returns Radius of the physics imposter
  74595. */
  74596. getRadius(): number;
  74597. /**
  74598. * Sync a bone with this impostor
  74599. * @param bone The bone to sync to the impostor.
  74600. * @param boneMesh The mesh that the bone is influencing.
  74601. * @param jointPivot The pivot of the joint / bone in local space.
  74602. * @param distToJoint Optional distance from the impostor to the joint.
  74603. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  74604. */
  74605. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  74606. /**
  74607. * Sync impostor to a bone
  74608. * @param bone The bone that the impostor will be synced to.
  74609. * @param boneMesh The mesh that the bone is influencing.
  74610. * @param jointPivot The pivot of the joint / bone in local space.
  74611. * @param distToJoint Optional distance from the impostor to the joint.
  74612. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  74613. * @param boneAxis Optional vector3 axis the bone is aligned with
  74614. */
  74615. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  74616. /**
  74617. * No-Imposter type
  74618. */
  74619. static NoImpostor: number;
  74620. /**
  74621. * Sphere-Imposter type
  74622. */
  74623. static SphereImpostor: number;
  74624. /**
  74625. * Box-Imposter type
  74626. */
  74627. static BoxImpostor: number;
  74628. /**
  74629. * Plane-Imposter type
  74630. */
  74631. static PlaneImpostor: number;
  74632. /**
  74633. * Mesh-imposter type
  74634. */
  74635. static MeshImpostor: number;
  74636. /**
  74637. * Cylinder-Imposter type
  74638. */
  74639. static CylinderImpostor: number;
  74640. /**
  74641. * Particle-Imposter type
  74642. */
  74643. static ParticleImpostor: number;
  74644. /**
  74645. * Heightmap-Imposter type
  74646. */
  74647. static HeightmapImpostor: number;
  74648. }
  74649. }
  74650. declare module BABYLON {
  74651. /**
  74652. * Mesh representing the gorund
  74653. */
  74654. export class GroundMesh extends Mesh {
  74655. /** If octree should be generated */
  74656. generateOctree: boolean;
  74657. private _heightQuads;
  74658. /** @hidden */
  74659. _subdivisionsX: number;
  74660. /** @hidden */
  74661. _subdivisionsY: number;
  74662. /** @hidden */
  74663. _width: number;
  74664. /** @hidden */
  74665. _height: number;
  74666. /** @hidden */
  74667. _minX: number;
  74668. /** @hidden */
  74669. _maxX: number;
  74670. /** @hidden */
  74671. _minZ: number;
  74672. /** @hidden */
  74673. _maxZ: number;
  74674. constructor(name: string, scene: Scene);
  74675. /**
  74676. * "GroundMesh"
  74677. * @returns "GroundMesh"
  74678. */
  74679. getClassName(): string;
  74680. /**
  74681. * The minimum of x and y subdivisions
  74682. */
  74683. readonly subdivisions: number;
  74684. /**
  74685. * X subdivisions
  74686. */
  74687. readonly subdivisionsX: number;
  74688. /**
  74689. * Y subdivisions
  74690. */
  74691. readonly subdivisionsY: number;
  74692. /**
  74693. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  74694. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  74695. * @param chunksCount the number of subdivisions for x and y
  74696. * @param octreeBlocksSize (Default: 32)
  74697. */
  74698. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  74699. /**
  74700. * Returns a height (y) value in the Worl system :
  74701. * the ground altitude at the coordinates (x, z) expressed in the World system.
  74702. * @param x x coordinate
  74703. * @param z z coordinate
  74704. * @returns the ground y position if (x, z) are outside the ground surface.
  74705. */
  74706. getHeightAtCoordinates(x: number, z: number): number;
  74707. /**
  74708. * Returns a normalized vector (Vector3) orthogonal to the ground
  74709. * at the ground coordinates (x, z) expressed in the World system.
  74710. * @param x x coordinate
  74711. * @param z z coordinate
  74712. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  74713. */
  74714. getNormalAtCoordinates(x: number, z: number): Vector3;
  74715. /**
  74716. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  74717. * at the ground coordinates (x, z) expressed in the World system.
  74718. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  74719. * @param x x coordinate
  74720. * @param z z coordinate
  74721. * @param ref vector to store the result
  74722. * @returns the GroundMesh.
  74723. */
  74724. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  74725. /**
  74726. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  74727. * if the ground has been updated.
  74728. * This can be used in the render loop.
  74729. * @returns the GroundMesh.
  74730. */
  74731. updateCoordinateHeights(): GroundMesh;
  74732. private _getFacetAt;
  74733. private _initHeightQuads;
  74734. private _computeHeightQuads;
  74735. /**
  74736. * Serializes this ground mesh
  74737. * @param serializationObject object to write serialization to
  74738. */
  74739. serialize(serializationObject: any): void;
  74740. /**
  74741. * Parses a serialized ground mesh
  74742. * @param parsedMesh the serialized mesh
  74743. * @param scene the scene to create the ground mesh in
  74744. * @returns the created ground mesh
  74745. */
  74746. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  74747. }
  74748. }
  74749. declare module BABYLON {
  74750. /**
  74751. * Class used to represent a specific level of detail of a mesh
  74752. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  74753. */
  74754. export class MeshLODLevel {
  74755. /** Defines the distance where this level should star being displayed */
  74756. distance: number;
  74757. /** Defines the mesh to use to render this level */
  74758. mesh: Nullable<Mesh>;
  74759. /**
  74760. * Creates a new LOD level
  74761. * @param distance defines the distance where this level should star being displayed
  74762. * @param mesh defines the mesh to use to render this level
  74763. */
  74764. constructor(
  74765. /** Defines the distance where this level should star being displayed */
  74766. distance: number,
  74767. /** Defines the mesh to use to render this level */
  74768. mesh: Nullable<Mesh>);
  74769. }
  74770. /**
  74771. * @hidden
  74772. **/
  74773. export class _CreationDataStorage {
  74774. closePath?: boolean;
  74775. closeArray?: boolean;
  74776. idx: number[];
  74777. dashSize: number;
  74778. gapSize: number;
  74779. path3D: Path3D;
  74780. pathArray: Vector3[][];
  74781. arc: number;
  74782. radius: number;
  74783. cap: number;
  74784. tessellation: number;
  74785. }
  74786. /**
  74787. * @hidden
  74788. **/
  74789. class _InstanceDataStorage {
  74790. visibleInstances: any;
  74791. renderIdForInstances: number[];
  74792. batchCache: _InstancesBatch;
  74793. instancesBufferSize: number;
  74794. instancesBuffer: Nullable<Buffer>;
  74795. instancesData: Float32Array;
  74796. overridenInstanceCount: number;
  74797. }
  74798. /**
  74799. * @hidden
  74800. **/
  74801. export class _InstancesBatch {
  74802. mustReturn: boolean;
  74803. visibleInstances: Nullable<InstancedMesh[]>[];
  74804. renderSelf: boolean[];
  74805. }
  74806. /**
  74807. * Class used to represent renderable models
  74808. */
  74809. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  74810. /**
  74811. * Mesh side orientation : usually the external or front surface
  74812. */
  74813. static readonly FRONTSIDE: number;
  74814. /**
  74815. * Mesh side orientation : usually the internal or back surface
  74816. */
  74817. static readonly BACKSIDE: number;
  74818. /**
  74819. * Mesh side orientation : both internal and external or front and back surfaces
  74820. */
  74821. static readonly DOUBLESIDE: number;
  74822. /**
  74823. * Mesh side orientation : by default, `FRONTSIDE`
  74824. */
  74825. static readonly DEFAULTSIDE: number;
  74826. /**
  74827. * Mesh cap setting : no cap
  74828. */
  74829. static readonly NO_CAP: number;
  74830. /**
  74831. * Mesh cap setting : one cap at the beginning of the mesh
  74832. */
  74833. static readonly CAP_START: number;
  74834. /**
  74835. * Mesh cap setting : one cap at the end of the mesh
  74836. */
  74837. static readonly CAP_END: number;
  74838. /**
  74839. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  74840. */
  74841. static readonly CAP_ALL: number;
  74842. /**
  74843. * Gets the default side orientation.
  74844. * @param orientation the orientation to value to attempt to get
  74845. * @returns the default orientation
  74846. * @hidden
  74847. */
  74848. static _GetDefaultSideOrientation(orientation?: number): number;
  74849. private _onBeforeRenderObservable;
  74850. private _onBeforeBindObservable;
  74851. private _onAfterRenderObservable;
  74852. private _onBeforeDrawObservable;
  74853. /**
  74854. * An event triggered before rendering the mesh
  74855. */
  74856. readonly onBeforeRenderObservable: Observable<Mesh>;
  74857. /**
  74858. * An event triggered before binding the mesh
  74859. */
  74860. readonly onBeforeBindObservable: Observable<Mesh>;
  74861. /**
  74862. * An event triggered after rendering the mesh
  74863. */
  74864. readonly onAfterRenderObservable: Observable<Mesh>;
  74865. /**
  74866. * An event triggered before drawing the mesh
  74867. */
  74868. readonly onBeforeDrawObservable: Observable<Mesh>;
  74869. private _onBeforeDrawObserver;
  74870. /**
  74871. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  74872. */
  74873. onBeforeDraw: () => void;
  74874. /**
  74875. * Gets the delay loading state of the mesh (when delay loading is turned on)
  74876. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  74877. */
  74878. delayLoadState: number;
  74879. /**
  74880. * Gets the list of instances created from this mesh
  74881. * it is not supposed to be modified manually.
  74882. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  74883. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  74884. */
  74885. instances: InstancedMesh[];
  74886. /**
  74887. * Gets the file containing delay loading data for this mesh
  74888. */
  74889. delayLoadingFile: string;
  74890. /** @hidden */
  74891. _binaryInfo: any;
  74892. private _LODLevels;
  74893. /**
  74894. * User defined function used to change how LOD level selection is done
  74895. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  74896. */
  74897. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  74898. private _morphTargetManager;
  74899. /**
  74900. * Gets or sets the morph target manager
  74901. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  74902. */
  74903. morphTargetManager: Nullable<MorphTargetManager>;
  74904. /** @hidden */
  74905. _creationDataStorage: Nullable<_CreationDataStorage>;
  74906. /** @hidden */
  74907. _geometry: Nullable<Geometry>;
  74908. /** @hidden */
  74909. _delayInfo: Array<string>;
  74910. /** @hidden */
  74911. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  74912. /** @hidden */
  74913. _instanceDataStorage: _InstanceDataStorage;
  74914. private _effectiveMaterial;
  74915. /** @hidden */
  74916. _shouldGenerateFlatShading: boolean;
  74917. private _preActivateId;
  74918. /** @hidden */
  74919. _originalBuilderSideOrientation: number;
  74920. /**
  74921. * Use this property to change the original side orientation defined at construction time
  74922. */
  74923. overrideMaterialSideOrientation: Nullable<number>;
  74924. private _areNormalsFrozen;
  74925. private _sourcePositions;
  74926. private _sourceNormals;
  74927. private _source;
  74928. private meshMap;
  74929. /**
  74930. * Gets the source mesh (the one used to clone this one from)
  74931. */
  74932. readonly source: Nullable<Mesh>;
  74933. /**
  74934. * Gets or sets a boolean indicating that this mesh does not use index buffer
  74935. */
  74936. isUnIndexed: boolean;
  74937. /**
  74938. * @constructor
  74939. * @param name The value used by scene.getMeshByName() to do a lookup.
  74940. * @param scene The scene to add this mesh to.
  74941. * @param parent The parent of this mesh, if it has one
  74942. * @param source An optional Mesh from which geometry is shared, cloned.
  74943. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  74944. * When false, achieved by calling a clone(), also passing False.
  74945. * This will make creation of children, recursive.
  74946. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  74947. */
  74948. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  74949. /**
  74950. * Gets the class name
  74951. * @returns the string "Mesh".
  74952. */
  74953. getClassName(): string;
  74954. /** @hidden */
  74955. readonly _isMesh: boolean;
  74956. /**
  74957. * Returns a description of this mesh
  74958. * @param fullDetails define if full details about this mesh must be used
  74959. * @returns a descriptive string representing this mesh
  74960. */
  74961. toString(fullDetails?: boolean): string;
  74962. /** @hidden */
  74963. _unBindEffect(): void;
  74964. /**
  74965. * Gets a boolean indicating if this mesh has LOD
  74966. */
  74967. readonly hasLODLevels: boolean;
  74968. /**
  74969. * Gets the list of MeshLODLevel associated with the current mesh
  74970. * @returns an array of MeshLODLevel
  74971. */
  74972. getLODLevels(): MeshLODLevel[];
  74973. private _sortLODLevels;
  74974. /**
  74975. * Add a mesh as LOD level triggered at the given distance.
  74976. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  74977. * @param distance The distance from the center of the object to show this level
  74978. * @param mesh The mesh to be added as LOD level (can be null)
  74979. * @return This mesh (for chaining)
  74980. */
  74981. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  74982. /**
  74983. * Returns the LOD level mesh at the passed distance or null if not found.
  74984. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  74985. * @param distance The distance from the center of the object to show this level
  74986. * @returns a Mesh or `null`
  74987. */
  74988. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  74989. /**
  74990. * Remove a mesh from the LOD array
  74991. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  74992. * @param mesh defines the mesh to be removed
  74993. * @return This mesh (for chaining)
  74994. */
  74995. removeLODLevel(mesh: Mesh): Mesh;
  74996. /**
  74997. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  74998. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  74999. * @param camera defines the camera to use to compute distance
  75000. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  75001. * @return This mesh (for chaining)
  75002. */
  75003. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  75004. /**
  75005. * Gets the mesh internal Geometry object
  75006. */
  75007. readonly geometry: Nullable<Geometry>;
  75008. /**
  75009. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  75010. * @returns the total number of vertices
  75011. */
  75012. getTotalVertices(): number;
  75013. /**
  75014. * Returns the content of an associated vertex buffer
  75015. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75016. * - VertexBuffer.PositionKind
  75017. * - VertexBuffer.UVKind
  75018. * - VertexBuffer.UV2Kind
  75019. * - VertexBuffer.UV3Kind
  75020. * - VertexBuffer.UV4Kind
  75021. * - VertexBuffer.UV5Kind
  75022. * - VertexBuffer.UV6Kind
  75023. * - VertexBuffer.ColorKind
  75024. * - VertexBuffer.MatricesIndicesKind
  75025. * - VertexBuffer.MatricesIndicesExtraKind
  75026. * - VertexBuffer.MatricesWeightsKind
  75027. * - VertexBuffer.MatricesWeightsExtraKind
  75028. * @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
  75029. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  75030. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  75031. */
  75032. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  75033. /**
  75034. * Returns the mesh VertexBuffer object from the requested `kind`
  75035. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75036. * - VertexBuffer.PositionKind
  75037. * - VertexBuffer.UVKind
  75038. * - VertexBuffer.UV2Kind
  75039. * - VertexBuffer.UV3Kind
  75040. * - VertexBuffer.UV4Kind
  75041. * - VertexBuffer.UV5Kind
  75042. * - VertexBuffer.UV6Kind
  75043. * - VertexBuffer.ColorKind
  75044. * - VertexBuffer.MatricesIndicesKind
  75045. * - VertexBuffer.MatricesIndicesExtraKind
  75046. * - VertexBuffer.MatricesWeightsKind
  75047. * - VertexBuffer.MatricesWeightsExtraKind
  75048. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  75049. */
  75050. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  75051. /**
  75052. * Tests if a specific vertex buffer is associated with this mesh
  75053. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75054. * - VertexBuffer.PositionKind
  75055. * - VertexBuffer.UVKind
  75056. * - VertexBuffer.UV2Kind
  75057. * - VertexBuffer.UV3Kind
  75058. * - VertexBuffer.UV4Kind
  75059. * - VertexBuffer.UV5Kind
  75060. * - VertexBuffer.UV6Kind
  75061. * - VertexBuffer.ColorKind
  75062. * - VertexBuffer.MatricesIndicesKind
  75063. * - VertexBuffer.MatricesIndicesExtraKind
  75064. * - VertexBuffer.MatricesWeightsKind
  75065. * - VertexBuffer.MatricesWeightsExtraKind
  75066. * @returns a boolean
  75067. */
  75068. isVerticesDataPresent(kind: string): boolean;
  75069. /**
  75070. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  75071. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  75072. * - VertexBuffer.PositionKind
  75073. * - VertexBuffer.UVKind
  75074. * - VertexBuffer.UV2Kind
  75075. * - VertexBuffer.UV3Kind
  75076. * - VertexBuffer.UV4Kind
  75077. * - VertexBuffer.UV5Kind
  75078. * - VertexBuffer.UV6Kind
  75079. * - VertexBuffer.ColorKind
  75080. * - VertexBuffer.MatricesIndicesKind
  75081. * - VertexBuffer.MatricesIndicesExtraKind
  75082. * - VertexBuffer.MatricesWeightsKind
  75083. * - VertexBuffer.MatricesWeightsExtraKind
  75084. * @returns a boolean
  75085. */
  75086. isVertexBufferUpdatable(kind: string): boolean;
  75087. /**
  75088. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  75089. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  75090. * - VertexBuffer.PositionKind
  75091. * - VertexBuffer.UVKind
  75092. * - VertexBuffer.UV2Kind
  75093. * - VertexBuffer.UV3Kind
  75094. * - VertexBuffer.UV4Kind
  75095. * - VertexBuffer.UV5Kind
  75096. * - VertexBuffer.UV6Kind
  75097. * - VertexBuffer.ColorKind
  75098. * - VertexBuffer.MatricesIndicesKind
  75099. * - VertexBuffer.MatricesIndicesExtraKind
  75100. * - VertexBuffer.MatricesWeightsKind
  75101. * - VertexBuffer.MatricesWeightsExtraKind
  75102. * @returns an array of strings
  75103. */
  75104. getVerticesDataKinds(): string[];
  75105. /**
  75106. * Returns a positive integer : the total number of indices in this mesh geometry.
  75107. * @returns the numner of indices or zero if the mesh has no geometry.
  75108. */
  75109. getTotalIndices(): number;
  75110. /**
  75111. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75112. * @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.
  75113. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  75114. * @returns the indices array or an empty array if the mesh has no geometry
  75115. */
  75116. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  75117. readonly isBlocked: boolean;
  75118. /**
  75119. * Determine if the current mesh is ready to be rendered
  75120. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75121. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  75122. * @returns true if all associated assets are ready (material, textures, shaders)
  75123. */
  75124. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  75125. /**
  75126. * 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.
  75127. */
  75128. readonly areNormalsFrozen: boolean;
  75129. /**
  75130. * 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.
  75131. * @returns the current mesh
  75132. */
  75133. freezeNormals(): Mesh;
  75134. /**
  75135. * 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
  75136. * @returns the current mesh
  75137. */
  75138. unfreezeNormals(): Mesh;
  75139. /**
  75140. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  75141. */
  75142. overridenInstanceCount: number;
  75143. /** @hidden */
  75144. _preActivate(): Mesh;
  75145. /** @hidden */
  75146. _preActivateForIntermediateRendering(renderId: number): Mesh;
  75147. /** @hidden */
  75148. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  75149. /**
  75150. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  75151. * This means the mesh underlying bounding box and sphere are recomputed.
  75152. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  75153. * @returns the current mesh
  75154. */
  75155. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  75156. /** @hidden */
  75157. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  75158. /**
  75159. * This function will subdivide the mesh into multiple submeshes
  75160. * @param count defines the expected number of submeshes
  75161. */
  75162. subdivide(count: number): void;
  75163. /**
  75164. * Copy a FloatArray into a specific associated vertex buffer
  75165. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75166. * - VertexBuffer.PositionKind
  75167. * - VertexBuffer.UVKind
  75168. * - VertexBuffer.UV2Kind
  75169. * - VertexBuffer.UV3Kind
  75170. * - VertexBuffer.UV4Kind
  75171. * - VertexBuffer.UV5Kind
  75172. * - VertexBuffer.UV6Kind
  75173. * - VertexBuffer.ColorKind
  75174. * - VertexBuffer.MatricesIndicesKind
  75175. * - VertexBuffer.MatricesIndicesExtraKind
  75176. * - VertexBuffer.MatricesWeightsKind
  75177. * - VertexBuffer.MatricesWeightsExtraKind
  75178. * @param data defines the data source
  75179. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75180. * @param stride defines the data stride size (can be null)
  75181. * @returns the current mesh
  75182. */
  75183. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75184. /**
  75185. * Flags an associated vertex buffer as updatable
  75186. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  75187. * - VertexBuffer.PositionKind
  75188. * - VertexBuffer.UVKind
  75189. * - VertexBuffer.UV2Kind
  75190. * - VertexBuffer.UV3Kind
  75191. * - VertexBuffer.UV4Kind
  75192. * - VertexBuffer.UV5Kind
  75193. * - VertexBuffer.UV6Kind
  75194. * - VertexBuffer.ColorKind
  75195. * - VertexBuffer.MatricesIndicesKind
  75196. * - VertexBuffer.MatricesIndicesExtraKind
  75197. * - VertexBuffer.MatricesWeightsKind
  75198. * - VertexBuffer.MatricesWeightsExtraKind
  75199. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  75200. */
  75201. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  75202. /**
  75203. * Sets the mesh global Vertex Buffer
  75204. * @param buffer defines the buffer to use
  75205. * @returns the current mesh
  75206. */
  75207. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  75208. /**
  75209. * Update a specific associated vertex buffer
  75210. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  75211. * - VertexBuffer.PositionKind
  75212. * - VertexBuffer.UVKind
  75213. * - VertexBuffer.UV2Kind
  75214. * - VertexBuffer.UV3Kind
  75215. * - VertexBuffer.UV4Kind
  75216. * - VertexBuffer.UV5Kind
  75217. * - VertexBuffer.UV6Kind
  75218. * - VertexBuffer.ColorKind
  75219. * - VertexBuffer.MatricesIndicesKind
  75220. * - VertexBuffer.MatricesIndicesExtraKind
  75221. * - VertexBuffer.MatricesWeightsKind
  75222. * - VertexBuffer.MatricesWeightsExtraKind
  75223. * @param data defines the data source
  75224. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  75225. * @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)
  75226. * @returns the current mesh
  75227. */
  75228. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  75229. /**
  75230. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  75231. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  75232. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  75233. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  75234. * @returns the current mesh
  75235. */
  75236. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  75237. /**
  75238. * Creates a un-shared specific occurence of the geometry for the mesh.
  75239. * @returns the current mesh
  75240. */
  75241. makeGeometryUnique(): Mesh;
  75242. /**
  75243. * Set the index buffer of this mesh
  75244. * @param indices defines the source data
  75245. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  75246. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  75247. * @returns the current mesh
  75248. */
  75249. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  75250. /**
  75251. * Update the current index buffer
  75252. * @param indices defines the source data
  75253. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  75254. * @returns the current mesh
  75255. */
  75256. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  75257. /**
  75258. * Invert the geometry to move from a right handed system to a left handed one.
  75259. * @returns the current mesh
  75260. */
  75261. toLeftHanded(): Mesh;
  75262. /** @hidden */
  75263. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  75264. /** @hidden */
  75265. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  75266. /**
  75267. * Registers for this mesh a javascript function called just before the rendering process
  75268. * @param func defines the function to call before rendering this mesh
  75269. * @returns the current mesh
  75270. */
  75271. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75272. /**
  75273. * Disposes a previously registered javascript function called before the rendering
  75274. * @param func defines the function to remove
  75275. * @returns the current mesh
  75276. */
  75277. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  75278. /**
  75279. * Registers for this mesh a javascript function called just after the rendering is complete
  75280. * @param func defines the function to call after rendering this mesh
  75281. * @returns the current mesh
  75282. */
  75283. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75284. /**
  75285. * Disposes a previously registered javascript function called after the rendering.
  75286. * @param func defines the function to remove
  75287. * @returns the current mesh
  75288. */
  75289. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  75290. /** @hidden */
  75291. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  75292. /** @hidden */
  75293. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  75294. /** @hidden */
  75295. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  75296. /**
  75297. * 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
  75298. * @param subMesh defines the subMesh to render
  75299. * @param enableAlphaMode defines if alpha mode can be changed
  75300. * @returns the current mesh
  75301. */
  75302. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  75303. private _onBeforeDraw;
  75304. /**
  75305. * Renormalize the mesh and patch it up if there are no weights
  75306. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  75307. * However in the case of zero weights then we set just a single influence to 1.
  75308. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  75309. */
  75310. cleanMatrixWeights(): void;
  75311. private normalizeSkinFourWeights;
  75312. private normalizeSkinWeightsAndExtra;
  75313. /**
  75314. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  75315. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  75316. * the user know there was an issue with importing the mesh
  75317. * @returns a validation object with skinned, valid and report string
  75318. */
  75319. validateSkinning(): {
  75320. skinned: boolean;
  75321. valid: boolean;
  75322. report: string;
  75323. };
  75324. /** @hidden */
  75325. _checkDelayState(): Mesh;
  75326. private _queueLoad;
  75327. /**
  75328. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  75329. * A mesh is in the frustum if its bounding box intersects the frustum
  75330. * @param frustumPlanes defines the frustum to test
  75331. * @returns true if the mesh is in the frustum planes
  75332. */
  75333. isInFrustum(frustumPlanes: Plane[]): boolean;
  75334. /**
  75335. * Sets the mesh material by the material or multiMaterial `id` property
  75336. * @param id is a string identifying the material or the multiMaterial
  75337. * @returns the current mesh
  75338. */
  75339. setMaterialByID(id: string): Mesh;
  75340. /**
  75341. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  75342. * @returns an array of IAnimatable
  75343. */
  75344. getAnimatables(): IAnimatable[];
  75345. /**
  75346. * Modifies the mesh geometry according to the passed transformation matrix.
  75347. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  75348. * The mesh normals are modified using the same transformation.
  75349. * Note that, under the hood, this method sets a new VertexBuffer each call.
  75350. * @param transform defines the transform matrix to use
  75351. * @see http://doc.babylonjs.com/resources/baking_transformations
  75352. * @returns the current mesh
  75353. */
  75354. bakeTransformIntoVertices(transform: Matrix): Mesh;
  75355. /**
  75356. * Modifies the mesh geometry according to its own current World Matrix.
  75357. * The mesh World Matrix is then reset.
  75358. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  75359. * Note that, under the hood, this method sets a new VertexBuffer each call.
  75360. * @see http://doc.babylonjs.com/resources/baking_transformations
  75361. * @returns the current mesh
  75362. */
  75363. bakeCurrentTransformIntoVertices(): Mesh;
  75364. /** @hidden */
  75365. readonly _positions: Nullable<Vector3[]>;
  75366. /** @hidden */
  75367. _resetPointsArrayCache(): Mesh;
  75368. /** @hidden */
  75369. _generatePointsArray(): boolean;
  75370. /**
  75371. * Returns a new Mesh object generated from the current mesh properties.
  75372. * This method must not get confused with createInstance()
  75373. * @param name is a string, the name given to the new mesh
  75374. * @param newParent can be any Node object (default `null`)
  75375. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  75376. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  75377. * @returns a new mesh
  75378. */
  75379. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  75380. /**
  75381. * Releases resources associated with this mesh.
  75382. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  75383. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  75384. */
  75385. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  75386. /**
  75387. * Modifies the mesh geometry according to a displacement map.
  75388. * 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.
  75389. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  75390. * @param url is a string, the URL from the image file is to be downloaded.
  75391. * @param minHeight is the lower limit of the displacement.
  75392. * @param maxHeight is the upper limit of the displacement.
  75393. * @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.
  75394. * @param uvOffset is an optional vector2 used to offset UV.
  75395. * @param uvScale is an optional vector2 used to scale UV.
  75396. * @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.
  75397. * @returns the Mesh.
  75398. */
  75399. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  75400. /**
  75401. * Modifies the mesh geometry according to a displacementMap buffer.
  75402. * 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.
  75403. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  75404. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  75405. * @param heightMapWidth is the width of the buffer image.
  75406. * @param heightMapHeight is the height of the buffer image.
  75407. * @param minHeight is the lower limit of the displacement.
  75408. * @param maxHeight is the upper limit of the displacement.
  75409. * @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.
  75410. * @param uvOffset is an optional vector2 used to offset UV.
  75411. * @param uvScale is an optional vector2 used to scale UV.
  75412. * @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.
  75413. * @returns the Mesh.
  75414. */
  75415. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  75416. /**
  75417. * Modify the mesh to get a flat shading rendering.
  75418. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  75419. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  75420. * @returns current mesh
  75421. */
  75422. convertToFlatShadedMesh(): Mesh;
  75423. /**
  75424. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  75425. * In other words, more vertices, no more indices and a single bigger VBO.
  75426. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  75427. * @returns current mesh
  75428. */
  75429. convertToUnIndexedMesh(): Mesh;
  75430. /**
  75431. * Inverses facet orientations.
  75432. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  75433. * @param flipNormals will also inverts the normals
  75434. * @returns current mesh
  75435. */
  75436. flipFaces(flipNormals?: boolean): Mesh;
  75437. /** @hidden */
  75438. static _instancedMeshFactory: (name: string, mesh: Mesh) => InstancedMesh;
  75439. /**
  75440. * Creates a new InstancedMesh object from the mesh model.
  75441. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75442. * @param name defines the name of the new instance
  75443. * @returns a new InstancedMesh
  75444. */
  75445. createInstance(name: string): InstancedMesh;
  75446. /**
  75447. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  75448. * After this call, all the mesh instances have the same submeshes than the current mesh.
  75449. * @returns the current mesh
  75450. */
  75451. synchronizeInstances(): Mesh;
  75452. /**
  75453. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  75454. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  75455. * This should be used together with the simplification to avoid disappearing triangles.
  75456. * @param successCallback an optional success callback to be called after the optimization finished.
  75457. * @returns the current mesh
  75458. */
  75459. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  75460. /**
  75461. * Serialize current mesh
  75462. * @param serializationObject defines the object which will receive the serialization data
  75463. */
  75464. serialize(serializationObject: any): void;
  75465. /** @hidden */
  75466. _syncGeometryWithMorphTargetManager(): void;
  75467. /** @hidden */
  75468. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  75469. /**
  75470. * Returns a new Mesh object parsed from the source provided.
  75471. * @param parsedMesh is the source
  75472. * @param scene defines the hosting scene
  75473. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  75474. * @returns a new Mesh
  75475. */
  75476. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  75477. /**
  75478. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  75479. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  75480. * @param name defines the name of the mesh to create
  75481. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  75482. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  75483. * @param closePath creates a seam between the first and the last points of each path of the path array
  75484. * @param offset is taken in account only if the `pathArray` is containing a single path
  75485. * @param scene defines the hosting scene
  75486. * @param updatable defines if the mesh must be flagged as updatable
  75487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75488. * @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)
  75489. * @returns a new Mesh
  75490. */
  75491. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  75492. /**
  75493. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  75494. * @param name defines the name of the mesh to create
  75495. * @param radius sets the radius size (float) of the polygon (default 0.5)
  75496. * @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
  75497. * @param scene defines the hosting scene
  75498. * @param updatable defines if the mesh must be flagged as updatable
  75499. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75500. * @returns a new Mesh
  75501. */
  75502. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  75503. /**
  75504. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  75505. * @param name defines the name of the mesh to create
  75506. * @param size sets the size (float) of each box side (default 1)
  75507. * @param scene defines the hosting scene
  75508. * @param updatable defines if the mesh must be flagged as updatable
  75509. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75510. * @returns a new Mesh
  75511. */
  75512. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  75513. /**
  75514. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  75515. * @param name defines the name of the mesh to create
  75516. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  75517. * @param diameter sets the diameter size (float) of the sphere (default 1)
  75518. * @param scene defines the hosting scene
  75519. * @param updatable defines if the mesh must be flagged as updatable
  75520. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75521. * @returns a new Mesh
  75522. */
  75523. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75524. /**
  75525. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  75526. * @param name defines the name of the mesh to create
  75527. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  75528. * @param diameterTop set the top cap diameter (floats, default 1)
  75529. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  75530. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  75531. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  75532. * @param scene defines the hosting scene
  75533. * @param updatable defines if the mesh must be flagged as updatable
  75534. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75535. * @returns a new Mesh
  75536. */
  75537. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  75538. /**
  75539. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  75540. * @param name defines the name of the mesh to create
  75541. * @param diameter sets the diameter size (float) of the torus (default 1)
  75542. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  75543. * @param tessellation sets the number of torus sides (postive integer, default 16)
  75544. * @param scene defines the hosting scene
  75545. * @param updatable defines if the mesh must be flagged as updatable
  75546. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75547. * @returns a new Mesh
  75548. */
  75549. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75550. /**
  75551. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  75552. * @param name defines the name of the mesh to create
  75553. * @param radius sets the global radius size (float) of the torus knot (default 2)
  75554. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  75555. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  75556. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  75557. * @param p the number of windings on X axis (positive integers, default 2)
  75558. * @param q the number of windings on Y axis (positive integers, default 3)
  75559. * @param scene defines the hosting scene
  75560. * @param updatable defines if the mesh must be flagged as updatable
  75561. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75562. * @returns a new Mesh
  75563. */
  75564. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75565. /**
  75566. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  75567. * @param name defines the name of the mesh to create
  75568. * @param points is an array successive Vector3
  75569. * @param scene defines the hosting scene
  75570. * @param updatable defines if the mesh must be flagged as updatable
  75571. * @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).
  75572. * @returns a new Mesh
  75573. */
  75574. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  75575. /**
  75576. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  75577. * @param name defines the name of the mesh to create
  75578. * @param points is an array successive Vector3
  75579. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  75580. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  75581. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  75582. * @param scene defines the hosting scene
  75583. * @param updatable defines if the mesh must be flagged as updatable
  75584. * @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)
  75585. * @returns a new Mesh
  75586. */
  75587. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  75588. /**
  75589. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  75590. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  75591. * 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.
  75592. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  75593. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75594. * Remember you can only change the shape positions, not their number when updating a polygon.
  75595. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  75596. * @param name defines the name of the mesh to create
  75597. * @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
  75598. * @param scene defines the hosting scene
  75599. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  75600. * @param updatable defines if the mesh must be flagged as updatable
  75601. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75602. * @param earcutInjection can be used to inject your own earcut reference
  75603. * @returns a new Mesh
  75604. */
  75605. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  75606. /**
  75607. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  75608. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  75609. * @param name defines the name of the mesh to create
  75610. * @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
  75611. * @param depth defines the height of extrusion
  75612. * @param scene defines the hosting scene
  75613. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  75614. * @param updatable defines if the mesh must be flagged as updatable
  75615. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75616. * @param earcutInjection can be used to inject your own earcut reference
  75617. * @returns a new Mesh
  75618. */
  75619. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  75620. /**
  75621. * Creates an extruded shape mesh.
  75622. * 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
  75623. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  75624. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  75625. * @param name defines the name of the mesh to create
  75626. * @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
  75627. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  75628. * @param scale is the value to scale the shape
  75629. * @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
  75630. * @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
  75631. * @param scene defines the hosting scene
  75632. * @param updatable defines if the mesh must be flagged as updatable
  75633. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75634. * @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)
  75635. * @returns a new Mesh
  75636. */
  75637. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  75638. /**
  75639. * Creates an custom extruded shape mesh.
  75640. * The custom extrusion is a parametric shape.
  75641. * It has no predefined shape. Its final shape will depend on the input parameters.
  75642. * Please consider using the same method from the MeshBuilder class instead
  75643. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  75644. * @param name defines the name of the mesh to create
  75645. * @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
  75646. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  75647. * @param scaleFunction is a custom Javascript function called on each path point
  75648. * @param rotationFunction is a custom Javascript function called on each path point
  75649. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  75650. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  75651. * @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
  75652. * @param scene defines the hosting scene
  75653. * @param updatable defines if the mesh must be flagged as updatable
  75654. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75655. * @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)
  75656. * @returns a new Mesh
  75657. */
  75658. 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;
  75659. /**
  75660. * Creates lathe mesh.
  75661. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  75662. * Please consider using the same method from the MeshBuilder class instead
  75663. * @param name defines the name of the mesh to create
  75664. * @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
  75665. * @param radius is the radius value of the lathe
  75666. * @param tessellation is the side number of the lathe.
  75667. * @param scene defines the hosting scene
  75668. * @param updatable defines if the mesh must be flagged as updatable
  75669. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75670. * @returns a new Mesh
  75671. */
  75672. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75673. /**
  75674. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  75675. * @param name defines the name of the mesh to create
  75676. * @param size sets the size (float) of both sides of the plane at once (default 1)
  75677. * @param scene defines the hosting scene
  75678. * @param updatable defines if the mesh must be flagged as updatable
  75679. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75680. * @returns a new Mesh
  75681. */
  75682. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  75683. /**
  75684. * Creates a ground mesh.
  75685. * Please consider using the same method from the MeshBuilder class instead
  75686. * @param name defines the name of the mesh to create
  75687. * @param width set the width of the ground
  75688. * @param height set the height of the ground
  75689. * @param subdivisions sets the number of subdivisions per side
  75690. * @param scene defines the hosting scene
  75691. * @param updatable defines if the mesh must be flagged as updatable
  75692. * @returns a new Mesh
  75693. */
  75694. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  75695. /**
  75696. * Creates a tiled ground mesh.
  75697. * Please consider using the same method from the MeshBuilder class instead
  75698. * @param name defines the name of the mesh to create
  75699. * @param xmin set the ground minimum X coordinate
  75700. * @param zmin set the ground minimum Y coordinate
  75701. * @param xmax set the ground maximum X coordinate
  75702. * @param zmax set the ground maximum Z coordinate
  75703. * @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
  75704. * @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
  75705. * @param scene defines the hosting scene
  75706. * @param updatable defines if the mesh must be flagged as updatable
  75707. * @returns a new Mesh
  75708. */
  75709. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  75710. w: number;
  75711. h: number;
  75712. }, precision: {
  75713. w: number;
  75714. h: number;
  75715. }, scene: Scene, updatable?: boolean): Mesh;
  75716. /**
  75717. * Creates a ground mesh from a height map.
  75718. * Please consider using the same method from the MeshBuilder class instead
  75719. * @see http://doc.babylonjs.com/babylon101/height_map
  75720. * @param name defines the name of the mesh to create
  75721. * @param url sets the URL of the height map image resource
  75722. * @param width set the ground width size
  75723. * @param height set the ground height size
  75724. * @param subdivisions sets the number of subdivision per side
  75725. * @param minHeight is the minimum altitude on the ground
  75726. * @param maxHeight is the maximum altitude on the ground
  75727. * @param scene defines the hosting scene
  75728. * @param updatable defines if the mesh must be flagged as updatable
  75729. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  75730. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  75731. * @returns a new Mesh
  75732. */
  75733. 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;
  75734. /**
  75735. * Creates a tube mesh.
  75736. * The tube is a parametric shape.
  75737. * It has no predefined shape. Its final shape will depend on the input parameters.
  75738. * Please consider using the same method from the MeshBuilder class instead
  75739. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  75740. * @param name defines the name of the mesh to create
  75741. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  75742. * @param radius sets the tube radius size
  75743. * @param tessellation is the number of sides on the tubular surface
  75744. * @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
  75745. * @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
  75746. * @param scene defines the hosting scene
  75747. * @param updatable defines if the mesh must be flagged as updatable
  75748. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  75749. * @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)
  75750. * @returns a new Mesh
  75751. */
  75752. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  75753. (i: number, distance: number): number;
  75754. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  75755. /**
  75756. * Creates a polyhedron mesh.
  75757. * Please consider using the same method from the MeshBuilder class instead.
  75758. * * 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
  75759. * * The parameter `size` (positive float, default 1) sets the polygon size
  75760. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  75761. * * 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`
  75762. * * 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
  75763. * * 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)`)
  75764. * * 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
  75765. * * 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
  75766. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  75767. * * If you create a double-sided mesh, you can choose what parts of 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
  75768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75769. * @param name defines the name of the mesh to create
  75770. * @param options defines the options used to create the mesh
  75771. * @param scene defines the hosting scene
  75772. * @returns a new Mesh
  75773. */
  75774. static CreatePolyhedron(name: string, options: {
  75775. type?: number;
  75776. size?: number;
  75777. sizeX?: number;
  75778. sizeY?: number;
  75779. sizeZ?: number;
  75780. custom?: any;
  75781. faceUV?: Vector4[];
  75782. faceColors?: Color4[];
  75783. updatable?: boolean;
  75784. sideOrientation?: number;
  75785. }, scene: Scene): Mesh;
  75786. /**
  75787. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  75788. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  75789. * * 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`)
  75790. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  75791. * * 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
  75792. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  75793. * * If you create a double-sided mesh, you can choose what parts of 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
  75794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75795. * @param name defines the name of the mesh
  75796. * @param options defines the options used to create the mesh
  75797. * @param scene defines the hosting scene
  75798. * @returns a new Mesh
  75799. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  75800. */
  75801. static CreateIcoSphere(name: string, options: {
  75802. radius?: number;
  75803. flat?: boolean;
  75804. subdivisions?: number;
  75805. sideOrientation?: number;
  75806. updatable?: boolean;
  75807. }, scene: Scene): Mesh;
  75808. /**
  75809. * Creates a decal mesh.
  75810. * Please consider using the same method from the MeshBuilder class instead.
  75811. * A decal is a mesh usually applied as a model onto the surface of another mesh
  75812. * @param name defines the name of the mesh
  75813. * @param sourceMesh defines the mesh receiving the decal
  75814. * @param position sets the position of the decal in world coordinates
  75815. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  75816. * @param size sets the decal scaling
  75817. * @param angle sets the angle to rotate the decal
  75818. * @returns a new Mesh
  75819. */
  75820. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  75821. /**
  75822. * Prepare internal position array for software CPU skinning
  75823. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  75824. */
  75825. setPositionsForCPUSkinning(): Float32Array;
  75826. /**
  75827. * Prepare internal normal array for software CPU skinning
  75828. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  75829. */
  75830. setNormalsForCPUSkinning(): Float32Array;
  75831. /**
  75832. * Updates the vertex buffer by applying transformation from the bones
  75833. * @param skeleton defines the skeleton to apply to current mesh
  75834. * @returns the current mesh
  75835. */
  75836. applySkeleton(skeleton: Skeleton): Mesh;
  75837. /**
  75838. * 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
  75839. * @param meshes defines the list of meshes to scan
  75840. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  75841. */
  75842. static MinMax(meshes: AbstractMesh[]): {
  75843. min: Vector3;
  75844. max: Vector3;
  75845. };
  75846. /**
  75847. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  75848. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  75849. * @returns a vector3
  75850. */
  75851. static Center(meshesOrMinMaxVector: {
  75852. min: Vector3;
  75853. max: Vector3;
  75854. } | AbstractMesh[]): Vector3;
  75855. /**
  75856. * Merge the array of meshes into a single mesh for performance reasons.
  75857. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  75858. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  75859. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  75860. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  75861. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  75862. * @returns a new mesh
  75863. */
  75864. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  75865. /** @hidden */
  75866. addInstance(instance: InstancedMesh): void;
  75867. /** @hidden */
  75868. removeInstance(instance: InstancedMesh): void;
  75869. }
  75870. }
  75871. declare module BABYLON {
  75872. /**
  75873. * Interface used to define Action
  75874. */
  75875. export interface IAction {
  75876. /**
  75877. * Trigger for the action
  75878. */
  75879. trigger: number;
  75880. /** the trigger, with or without parameters, for the action */
  75881. triggerOptions: any;
  75882. /**
  75883. * Gets the trigger parameters
  75884. * @returns the trigger parameters
  75885. */
  75886. getTriggerParameter(): any;
  75887. /**
  75888. * Internal only - executes current action event
  75889. * @hidden
  75890. */
  75891. _executeCurrent(evt?: ActionEvent): void;
  75892. /**
  75893. * Serialize placeholder for child classes
  75894. * @param parent of child
  75895. * @returns the serialized object
  75896. */
  75897. serialize(parent: any): any;
  75898. }
  75899. /**
  75900. * The action to be carried out following a trigger
  75901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  75902. */
  75903. export class Action implements IAction {
  75904. /** the trigger, with or without parameters, for the action */
  75905. triggerOptions: any;
  75906. /**
  75907. * Trigger for the action
  75908. */
  75909. trigger: number;
  75910. /**
  75911. * Internal only - manager for action
  75912. * @hidden
  75913. */
  75914. _actionManager: ActionManager;
  75915. private _nextActiveAction;
  75916. private _child;
  75917. private _condition?;
  75918. private _triggerParameter;
  75919. /**
  75920. * An event triggered prior to action being executed.
  75921. */
  75922. onBeforeExecuteObservable: Observable<Action>;
  75923. /**
  75924. * Creates a new Action
  75925. * @param triggerOptions the trigger, with or without parameters, for the action
  75926. * @param condition an optional determinant of action
  75927. */
  75928. constructor(
  75929. /** the trigger, with or without parameters, for the action */
  75930. triggerOptions: any, condition?: Condition);
  75931. /**
  75932. * Internal only
  75933. * @hidden
  75934. */
  75935. _prepare(): void;
  75936. /**
  75937. * Gets the trigger parameters
  75938. * @returns the trigger parameters
  75939. */
  75940. getTriggerParameter(): any;
  75941. /**
  75942. * Internal only - executes current action event
  75943. * @hidden
  75944. */
  75945. _executeCurrent(evt?: ActionEvent): void;
  75946. /**
  75947. * Execute placeholder for child classes
  75948. * @param evt optional action event
  75949. */
  75950. execute(evt?: ActionEvent): void;
  75951. /**
  75952. * Skips to next active action
  75953. */
  75954. skipToNextActiveAction(): void;
  75955. /**
  75956. * Adds action to chain of actions, may be a DoNothingAction
  75957. * @param action defines the next action to execute
  75958. * @returns The action passed in
  75959. * @see https://www.babylonjs-playground.com/#1T30HR#0
  75960. */
  75961. then(action: Action): Action;
  75962. /**
  75963. * Internal only
  75964. * @hidden
  75965. */
  75966. _getProperty(propertyPath: string): string;
  75967. /**
  75968. * Internal only
  75969. * @hidden
  75970. */
  75971. _getEffectiveTarget(target: any, propertyPath: string): any;
  75972. /**
  75973. * Serialize placeholder for child classes
  75974. * @param parent of child
  75975. * @returns the serialized object
  75976. */
  75977. serialize(parent: any): any;
  75978. /**
  75979. * Internal only called by serialize
  75980. * @hidden
  75981. */
  75982. protected _serialize(serializedAction: any, parent?: any): any;
  75983. /**
  75984. * Internal only
  75985. * @hidden
  75986. */
  75987. static _SerializeValueAsString: (value: any) => string;
  75988. /**
  75989. * Internal only
  75990. * @hidden
  75991. */
  75992. static _GetTargetProperty: (target: Scene | Node) => {
  75993. name: string;
  75994. targetType: string;
  75995. value: string;
  75996. };
  75997. }
  75998. }
  75999. declare module BABYLON {
  76000. /**
  76001. * A Condition applied to an Action
  76002. */
  76003. export class Condition {
  76004. /**
  76005. * Internal only - manager for action
  76006. * @hidden
  76007. */
  76008. _actionManager: ActionManager;
  76009. /**
  76010. * Internal only
  76011. * @hidden
  76012. */
  76013. _evaluationId: number;
  76014. /**
  76015. * Internal only
  76016. * @hidden
  76017. */
  76018. _currentResult: boolean;
  76019. /**
  76020. * Creates a new Condition
  76021. * @param actionManager the manager of the action the condition is applied to
  76022. */
  76023. constructor(actionManager: ActionManager);
  76024. /**
  76025. * Check if the current condition is valid
  76026. * @returns a boolean
  76027. */
  76028. isValid(): boolean;
  76029. /**
  76030. * Internal only
  76031. * @hidden
  76032. */
  76033. _getProperty(propertyPath: string): string;
  76034. /**
  76035. * Internal only
  76036. * @hidden
  76037. */
  76038. _getEffectiveTarget(target: any, propertyPath: string): any;
  76039. /**
  76040. * Serialize placeholder for child classes
  76041. * @returns the serialized object
  76042. */
  76043. serialize(): any;
  76044. /**
  76045. * Internal only
  76046. * @hidden
  76047. */
  76048. protected _serialize(serializedCondition: any): any;
  76049. }
  76050. /**
  76051. * Defines specific conditional operators as extensions of Condition
  76052. */
  76053. export class ValueCondition extends Condition {
  76054. /** path to specify the property of the target the conditional operator uses */
  76055. propertyPath: string;
  76056. /** the value compared by the conditional operator against the current value of the property */
  76057. value: any;
  76058. /** the conditional operator, default ValueCondition.IsEqual */
  76059. operator: number;
  76060. /**
  76061. * Internal only
  76062. * @hidden
  76063. */
  76064. private static _IsEqual;
  76065. /**
  76066. * Internal only
  76067. * @hidden
  76068. */
  76069. private static _IsDifferent;
  76070. /**
  76071. * Internal only
  76072. * @hidden
  76073. */
  76074. private static _IsGreater;
  76075. /**
  76076. * Internal only
  76077. * @hidden
  76078. */
  76079. private static _IsLesser;
  76080. /**
  76081. * returns the number for IsEqual
  76082. */
  76083. static readonly IsEqual: number;
  76084. /**
  76085. * Returns the number for IsDifferent
  76086. */
  76087. static readonly IsDifferent: number;
  76088. /**
  76089. * Returns the number for IsGreater
  76090. */
  76091. static readonly IsGreater: number;
  76092. /**
  76093. * Returns the number for IsLesser
  76094. */
  76095. static readonly IsLesser: number;
  76096. /**
  76097. * Internal only The action manager for the condition
  76098. * @hidden
  76099. */
  76100. _actionManager: ActionManager;
  76101. /**
  76102. * Internal only
  76103. * @hidden
  76104. */
  76105. private _target;
  76106. /**
  76107. * Internal only
  76108. * @hidden
  76109. */
  76110. private _effectiveTarget;
  76111. /**
  76112. * Internal only
  76113. * @hidden
  76114. */
  76115. private _property;
  76116. /**
  76117. * Creates a new ValueCondition
  76118. * @param actionManager manager for the action the condition applies to
  76119. * @param target for the action
  76120. * @param propertyPath path to specify the property of the target the conditional operator uses
  76121. * @param value the value compared by the conditional operator against the current value of the property
  76122. * @param operator the conditional operator, default ValueCondition.IsEqual
  76123. */
  76124. constructor(actionManager: ActionManager, target: any,
  76125. /** path to specify the property of the target the conditional operator uses */
  76126. propertyPath: string,
  76127. /** the value compared by the conditional operator against the current value of the property */
  76128. value: any,
  76129. /** the conditional operator, default ValueCondition.IsEqual */
  76130. operator?: number);
  76131. /**
  76132. * Compares the given value with the property value for the specified conditional operator
  76133. * @returns the result of the comparison
  76134. */
  76135. isValid(): boolean;
  76136. /**
  76137. * Serialize the ValueCondition into a JSON compatible object
  76138. * @returns serialization object
  76139. */
  76140. serialize(): any;
  76141. /**
  76142. * Gets the name of the conditional operator for the ValueCondition
  76143. * @param operator the conditional operator
  76144. * @returns the name
  76145. */
  76146. static GetOperatorName(operator: number): string;
  76147. }
  76148. /**
  76149. * Defines a predicate condition as an extension of Condition
  76150. */
  76151. export class PredicateCondition extends Condition {
  76152. /** defines the predicate function used to validate the condition */
  76153. predicate: () => boolean;
  76154. /**
  76155. * Internal only - manager for action
  76156. * @hidden
  76157. */
  76158. _actionManager: ActionManager;
  76159. /**
  76160. * Creates a new PredicateCondition
  76161. * @param actionManager manager for the action the condition applies to
  76162. * @param predicate defines the predicate function used to validate the condition
  76163. */
  76164. constructor(actionManager: ActionManager,
  76165. /** defines the predicate function used to validate the condition */
  76166. predicate: () => boolean);
  76167. /**
  76168. * @returns the validity of the predicate condition
  76169. */
  76170. isValid(): boolean;
  76171. }
  76172. /**
  76173. * Defines a state condition as an extension of Condition
  76174. */
  76175. export class StateCondition extends Condition {
  76176. /** Value to compare with target state */
  76177. value: string;
  76178. /**
  76179. * Internal only - manager for action
  76180. * @hidden
  76181. */
  76182. _actionManager: ActionManager;
  76183. /**
  76184. * Internal only
  76185. * @hidden
  76186. */
  76187. private _target;
  76188. /**
  76189. * Creates a new StateCondition
  76190. * @param actionManager manager for the action the condition applies to
  76191. * @param target of the condition
  76192. * @param value to compare with target state
  76193. */
  76194. constructor(actionManager: ActionManager, target: any,
  76195. /** Value to compare with target state */
  76196. value: string);
  76197. /**
  76198. * Gets a boolean indicating if the current condition is met
  76199. * @returns the validity of the state
  76200. */
  76201. isValid(): boolean;
  76202. /**
  76203. * Serialize the StateCondition into a JSON compatible object
  76204. * @returns serialization object
  76205. */
  76206. serialize(): any;
  76207. }
  76208. }
  76209. declare module BABYLON {
  76210. /**
  76211. * This defines an action responsible to toggle a boolean once triggered.
  76212. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76213. */
  76214. export class SwitchBooleanAction extends Action {
  76215. /**
  76216. * The path to the boolean property in the target object
  76217. */
  76218. propertyPath: string;
  76219. private _target;
  76220. private _effectiveTarget;
  76221. private _property;
  76222. /**
  76223. * Instantiate the action
  76224. * @param triggerOptions defines the trigger options
  76225. * @param target defines the object containing the boolean
  76226. * @param propertyPath defines the path to the boolean property in the target object
  76227. * @param condition defines the trigger related conditions
  76228. */
  76229. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  76230. /** @hidden */
  76231. _prepare(): void;
  76232. /**
  76233. * Execute the action toggle the boolean value.
  76234. */
  76235. execute(): void;
  76236. /**
  76237. * Serializes the actions and its related information.
  76238. * @param parent defines the object to serialize in
  76239. * @returns the serialized object
  76240. */
  76241. serialize(parent: any): any;
  76242. }
  76243. /**
  76244. * This defines an action responsible to set a the state field of the target
  76245. * to a desired value once triggered.
  76246. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76247. */
  76248. export class SetStateAction extends Action {
  76249. /**
  76250. * The value to store in the state field.
  76251. */
  76252. value: string;
  76253. private _target;
  76254. /**
  76255. * Instantiate the action
  76256. * @param triggerOptions defines the trigger options
  76257. * @param target defines the object containing the state property
  76258. * @param value defines the value to store in the state field
  76259. * @param condition defines the trigger related conditions
  76260. */
  76261. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  76262. /**
  76263. * Execute the action and store the value on the target state property.
  76264. */
  76265. execute(): void;
  76266. /**
  76267. * Serializes the actions and its related information.
  76268. * @param parent defines the object to serialize in
  76269. * @returns the serialized object
  76270. */
  76271. serialize(parent: any): any;
  76272. }
  76273. /**
  76274. * This defines an action responsible to set a property of the target
  76275. * to a desired value once triggered.
  76276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76277. */
  76278. export class SetValueAction extends Action {
  76279. /**
  76280. * The path of the property to set in the target.
  76281. */
  76282. propertyPath: string;
  76283. /**
  76284. * The value to set in the property
  76285. */
  76286. value: any;
  76287. private _target;
  76288. private _effectiveTarget;
  76289. private _property;
  76290. /**
  76291. * Instantiate the action
  76292. * @param triggerOptions defines the trigger options
  76293. * @param target defines the object containing the property
  76294. * @param propertyPath defines the path of the property to set in the target
  76295. * @param value defines the value to set in the property
  76296. * @param condition defines the trigger related conditions
  76297. */
  76298. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76299. /** @hidden */
  76300. _prepare(): void;
  76301. /**
  76302. * Execute the action and set the targetted property to the desired value.
  76303. */
  76304. execute(): void;
  76305. /**
  76306. * Serializes the actions and its related information.
  76307. * @param parent defines the object to serialize in
  76308. * @returns the serialized object
  76309. */
  76310. serialize(parent: any): any;
  76311. }
  76312. /**
  76313. * This defines an action responsible to increment the target value
  76314. * to a desired value once triggered.
  76315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76316. */
  76317. export class IncrementValueAction extends Action {
  76318. /**
  76319. * The path of the property to increment in the target.
  76320. */
  76321. propertyPath: string;
  76322. /**
  76323. * The value we should increment the property by.
  76324. */
  76325. value: any;
  76326. private _target;
  76327. private _effectiveTarget;
  76328. private _property;
  76329. /**
  76330. * Instantiate the action
  76331. * @param triggerOptions defines the trigger options
  76332. * @param target defines the object containing the property
  76333. * @param propertyPath defines the path of the property to increment in the target
  76334. * @param value defines the value value we should increment the property by
  76335. * @param condition defines the trigger related conditions
  76336. */
  76337. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  76338. /** @hidden */
  76339. _prepare(): void;
  76340. /**
  76341. * Execute the action and increment the target of the value amount.
  76342. */
  76343. execute(): void;
  76344. /**
  76345. * Serializes the actions and its related information.
  76346. * @param parent defines the object to serialize in
  76347. * @returns the serialized object
  76348. */
  76349. serialize(parent: any): any;
  76350. }
  76351. /**
  76352. * This defines an action responsible to start an animation once triggered.
  76353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76354. */
  76355. export class PlayAnimationAction extends Action {
  76356. /**
  76357. * Where the animation should start (animation frame)
  76358. */
  76359. from: number;
  76360. /**
  76361. * Where the animation should stop (animation frame)
  76362. */
  76363. to: number;
  76364. /**
  76365. * Define if the animation should loop or stop after the first play.
  76366. */
  76367. loop?: boolean;
  76368. private _target;
  76369. /**
  76370. * Instantiate the action
  76371. * @param triggerOptions defines the trigger options
  76372. * @param target defines the target animation or animation name
  76373. * @param from defines from where the animation should start (animation frame)
  76374. * @param end defines where the animation should stop (animation frame)
  76375. * @param loop defines if the animation should loop or stop after the first play
  76376. * @param condition defines the trigger related conditions
  76377. */
  76378. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  76379. /** @hidden */
  76380. _prepare(): void;
  76381. /**
  76382. * Execute the action and play the animation.
  76383. */
  76384. execute(): void;
  76385. /**
  76386. * Serializes the actions and its related information.
  76387. * @param parent defines the object to serialize in
  76388. * @returns the serialized object
  76389. */
  76390. serialize(parent: any): any;
  76391. }
  76392. /**
  76393. * This defines an action responsible to stop an animation once triggered.
  76394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76395. */
  76396. export class StopAnimationAction extends Action {
  76397. private _target;
  76398. /**
  76399. * Instantiate the action
  76400. * @param triggerOptions defines the trigger options
  76401. * @param target defines the target animation or animation name
  76402. * @param condition defines the trigger related conditions
  76403. */
  76404. constructor(triggerOptions: any, target: any, condition?: Condition);
  76405. /** @hidden */
  76406. _prepare(): void;
  76407. /**
  76408. * Execute the action and stop the animation.
  76409. */
  76410. execute(): void;
  76411. /**
  76412. * Serializes the actions and its related information.
  76413. * @param parent defines the object to serialize in
  76414. * @returns the serialized object
  76415. */
  76416. serialize(parent: any): any;
  76417. }
  76418. /**
  76419. * This defines an action responsible that does nothing once triggered.
  76420. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76421. */
  76422. export class DoNothingAction extends Action {
  76423. /**
  76424. * Instantiate the action
  76425. * @param triggerOptions defines the trigger options
  76426. * @param condition defines the trigger related conditions
  76427. */
  76428. constructor(triggerOptions?: any, condition?: Condition);
  76429. /**
  76430. * Execute the action and do nothing.
  76431. */
  76432. execute(): void;
  76433. /**
  76434. * Serializes the actions and its related information.
  76435. * @param parent defines the object to serialize in
  76436. * @returns the serialized object
  76437. */
  76438. serialize(parent: any): any;
  76439. }
  76440. /**
  76441. * This defines an action responsible to trigger several actions once triggered.
  76442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76443. */
  76444. export class CombineAction extends Action {
  76445. /**
  76446. * The list of aggregated animations to run.
  76447. */
  76448. children: Action[];
  76449. /**
  76450. * Instantiate the action
  76451. * @param triggerOptions defines the trigger options
  76452. * @param children defines the list of aggregated animations to run
  76453. * @param condition defines the trigger related conditions
  76454. */
  76455. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  76456. /** @hidden */
  76457. _prepare(): void;
  76458. /**
  76459. * Execute the action and executes all the aggregated actions.
  76460. */
  76461. execute(evt: ActionEvent): void;
  76462. /**
  76463. * Serializes the actions and its related information.
  76464. * @param parent defines the object to serialize in
  76465. * @returns the serialized object
  76466. */
  76467. serialize(parent: any): any;
  76468. }
  76469. /**
  76470. * This defines an action responsible to run code (external event) once triggered.
  76471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76472. */
  76473. export class ExecuteCodeAction extends Action {
  76474. /**
  76475. * The callback function to run.
  76476. */
  76477. func: (evt: ActionEvent) => void;
  76478. /**
  76479. * Instantiate the action
  76480. * @param triggerOptions defines the trigger options
  76481. * @param func defines the callback function to run
  76482. * @param condition defines the trigger related conditions
  76483. */
  76484. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  76485. /**
  76486. * Execute the action and run the attached code.
  76487. */
  76488. execute(evt: ActionEvent): void;
  76489. }
  76490. /**
  76491. * This defines an action responsible to set the parent property of the target once triggered.
  76492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76493. */
  76494. export class SetParentAction extends Action {
  76495. private _parent;
  76496. private _target;
  76497. /**
  76498. * Instantiate the action
  76499. * @param triggerOptions defines the trigger options
  76500. * @param target defines the target containing the parent property
  76501. * @param parent defines from where the animation should start (animation frame)
  76502. * @param condition defines the trigger related conditions
  76503. */
  76504. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  76505. /** @hidden */
  76506. _prepare(): void;
  76507. /**
  76508. * Execute the action and set the parent property.
  76509. */
  76510. execute(): void;
  76511. /**
  76512. * Serializes the actions and its related information.
  76513. * @param parent defines the object to serialize in
  76514. * @returns the serialized object
  76515. */
  76516. serialize(parent: any): any;
  76517. }
  76518. }
  76519. declare module BABYLON {
  76520. /**
  76521. * Abstract class used to decouple action Manager from scene and meshes.
  76522. * Do not instantiate.
  76523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76524. */
  76525. export abstract class AbstractActionManager implements IDisposable {
  76526. /** Gets the list of active triggers */
  76527. static Triggers: {
  76528. [key: string]: number;
  76529. };
  76530. /** Gets the cursor to use when hovering items */
  76531. hoverCursor: string;
  76532. /** Gets the list of actions */
  76533. actions: IAction[];
  76534. /**
  76535. * Releases all associated resources
  76536. */
  76537. abstract dispose(): void;
  76538. /**
  76539. * Does this action manager has pointer triggers
  76540. */
  76541. abstract readonly hasPointerTriggers: boolean;
  76542. /**
  76543. * Does this action manager has pick triggers
  76544. */
  76545. abstract readonly hasPickTriggers: boolean;
  76546. /**
  76547. * Process a specific trigger
  76548. * @param trigger defines the trigger to process
  76549. * @param evt defines the event details to be processed
  76550. */
  76551. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  76552. /**
  76553. * Does this action manager handles actions of any of the given triggers
  76554. * @param triggers defines the triggers to be tested
  76555. * @return a boolean indicating whether one (or more) of the triggers is handled
  76556. */
  76557. abstract hasSpecificTriggers(triggers: number[]): boolean;
  76558. /**
  76559. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76560. * speed.
  76561. * @param triggerA defines the trigger to be tested
  76562. * @param triggerB defines the trigger to be tested
  76563. * @return a boolean indicating whether one (or more) of the triggers is handled
  76564. */
  76565. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76566. /**
  76567. * Does this action manager handles actions of a given trigger
  76568. * @param trigger defines the trigger to be tested
  76569. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76570. * @return whether the trigger is handled
  76571. */
  76572. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76573. /**
  76574. * Serialize this manager to a JSON object
  76575. * @param name defines the property name to store this manager
  76576. * @returns a JSON representation of this manager
  76577. */
  76578. abstract serialize(name: string): any;
  76579. /**
  76580. * Does exist one action manager with at least one trigger
  76581. **/
  76582. static readonly HasTriggers: boolean;
  76583. /**
  76584. * Does exist one action manager with at least one pick trigger
  76585. **/
  76586. static readonly HasPickTriggers: boolean;
  76587. /**
  76588. * Does exist one action manager that handles actions of a given trigger
  76589. * @param trigger defines the trigger to be tested
  76590. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  76591. **/
  76592. static HasSpecificTrigger(trigger: number): boolean;
  76593. }
  76594. }
  76595. declare module BABYLON {
  76596. /**
  76597. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  76598. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  76599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  76600. */
  76601. export class ActionManager extends AbstractActionManager {
  76602. /**
  76603. * Nothing
  76604. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76605. */
  76606. static readonly NothingTrigger: number;
  76607. /**
  76608. * On pick
  76609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76610. */
  76611. static readonly OnPickTrigger: number;
  76612. /**
  76613. * On left pick
  76614. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76615. */
  76616. static readonly OnLeftPickTrigger: number;
  76617. /**
  76618. * On right pick
  76619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76620. */
  76621. static readonly OnRightPickTrigger: number;
  76622. /**
  76623. * On center pick
  76624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76625. */
  76626. static readonly OnCenterPickTrigger: number;
  76627. /**
  76628. * On pick down
  76629. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76630. */
  76631. static readonly OnPickDownTrigger: number;
  76632. /**
  76633. * On double pick
  76634. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76635. */
  76636. static readonly OnDoublePickTrigger: number;
  76637. /**
  76638. * On pick up
  76639. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76640. */
  76641. static readonly OnPickUpTrigger: number;
  76642. /**
  76643. * On pick out.
  76644. * This trigger will only be raised if you also declared a OnPickDown
  76645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76646. */
  76647. static readonly OnPickOutTrigger: number;
  76648. /**
  76649. * On long press
  76650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76651. */
  76652. static readonly OnLongPressTrigger: number;
  76653. /**
  76654. * On pointer over
  76655. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76656. */
  76657. static readonly OnPointerOverTrigger: number;
  76658. /**
  76659. * On pointer out
  76660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76661. */
  76662. static readonly OnPointerOutTrigger: number;
  76663. /**
  76664. * On every frame
  76665. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76666. */
  76667. static readonly OnEveryFrameTrigger: number;
  76668. /**
  76669. * On intersection enter
  76670. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76671. */
  76672. static readonly OnIntersectionEnterTrigger: number;
  76673. /**
  76674. * On intersection exit
  76675. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76676. */
  76677. static readonly OnIntersectionExitTrigger: number;
  76678. /**
  76679. * On key down
  76680. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76681. */
  76682. static readonly OnKeyDownTrigger: number;
  76683. /**
  76684. * On key up
  76685. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  76686. */
  76687. static readonly OnKeyUpTrigger: number;
  76688. private _scene;
  76689. /**
  76690. * Creates a new action manager
  76691. * @param scene defines the hosting scene
  76692. */
  76693. constructor(scene: Scene);
  76694. /**
  76695. * Releases all associated resources
  76696. */
  76697. dispose(): void;
  76698. /**
  76699. * Gets hosting scene
  76700. * @returns the hosting scene
  76701. */
  76702. getScene(): Scene;
  76703. /**
  76704. * Does this action manager handles actions of any of the given triggers
  76705. * @param triggers defines the triggers to be tested
  76706. * @return a boolean indicating whether one (or more) of the triggers is handled
  76707. */
  76708. hasSpecificTriggers(triggers: number[]): boolean;
  76709. /**
  76710. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  76711. * speed.
  76712. * @param triggerA defines the trigger to be tested
  76713. * @param triggerB defines the trigger to be tested
  76714. * @return a boolean indicating whether one (or more) of the triggers is handled
  76715. */
  76716. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  76717. /**
  76718. * Does this action manager handles actions of a given trigger
  76719. * @param trigger defines the trigger to be tested
  76720. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  76721. * @return whether the trigger is handled
  76722. */
  76723. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  76724. /**
  76725. * Does this action manager has pointer triggers
  76726. */
  76727. readonly hasPointerTriggers: boolean;
  76728. /**
  76729. * Does this action manager has pick triggers
  76730. */
  76731. readonly hasPickTriggers: boolean;
  76732. /**
  76733. * Registers an action to this action manager
  76734. * @param action defines the action to be registered
  76735. * @return the action amended (prepared) after registration
  76736. */
  76737. registerAction(action: Action): Nullable<Action>;
  76738. /**
  76739. * Unregisters an action to this action manager
  76740. * @param action defines the action to be unregistered
  76741. * @return a boolean indicating whether the action has been unregistered
  76742. */
  76743. unregisterAction(action: Action): Boolean;
  76744. /**
  76745. * Process a specific trigger
  76746. * @param trigger defines the trigger to process
  76747. * @param evt defines the event details to be processed
  76748. */
  76749. processTrigger(trigger: number, evt?: IActionEvent): void;
  76750. /** @hidden */
  76751. _getEffectiveTarget(target: any, propertyPath: string): any;
  76752. /** @hidden */
  76753. _getProperty(propertyPath: string): string;
  76754. /**
  76755. * Serialize this manager to a JSON object
  76756. * @param name defines the property name to store this manager
  76757. * @returns a JSON representation of this manager
  76758. */
  76759. serialize(name: string): any;
  76760. /**
  76761. * Creates a new ActionManager from a JSON data
  76762. * @param parsedActions defines the JSON data to read from
  76763. * @param object defines the hosting mesh
  76764. * @param scene defines the hosting scene
  76765. */
  76766. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  76767. /**
  76768. * Get a trigger name by index
  76769. * @param trigger defines the trigger index
  76770. * @returns a trigger name
  76771. */
  76772. static GetTriggerName(trigger: number): string;
  76773. }
  76774. }
  76775. declare module BABYLON {
  76776. /**
  76777. * Class used to represent a sprite
  76778. * @see http://doc.babylonjs.com/babylon101/sprites
  76779. */
  76780. export class Sprite {
  76781. /** defines the name */
  76782. name: string;
  76783. /** Gets or sets the current world position */
  76784. position: Vector3;
  76785. /** Gets or sets the main color */
  76786. color: Color4;
  76787. /** Gets or sets the width */
  76788. width: number;
  76789. /** Gets or sets the height */
  76790. height: number;
  76791. /** Gets or sets rotation angle */
  76792. angle: number;
  76793. /** Gets or sets the cell index in the sprite sheet */
  76794. cellIndex: number;
  76795. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  76796. invertU: number;
  76797. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  76798. invertV: number;
  76799. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  76800. disposeWhenFinishedAnimating: boolean;
  76801. /** Gets the list of attached animations */
  76802. animations: Animation[];
  76803. /** Gets or sets a boolean indicating if the sprite can be picked */
  76804. isPickable: boolean;
  76805. /**
  76806. * Gets or sets the associated action manager
  76807. */
  76808. actionManager: Nullable<ActionManager>;
  76809. private _animationStarted;
  76810. private _loopAnimation;
  76811. private _fromIndex;
  76812. private _toIndex;
  76813. private _delay;
  76814. private _direction;
  76815. private _manager;
  76816. private _time;
  76817. private _onAnimationEnd;
  76818. /**
  76819. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  76820. */
  76821. isVisible: boolean;
  76822. /**
  76823. * Gets or sets the sprite size
  76824. */
  76825. size: number;
  76826. /**
  76827. * Creates a new Sprite
  76828. * @param name defines the name
  76829. * @param manager defines the manager
  76830. */
  76831. constructor(
  76832. /** defines the name */
  76833. name: string, manager: ISpriteManager);
  76834. /**
  76835. * Starts an animation
  76836. * @param from defines the initial key
  76837. * @param to defines the end key
  76838. * @param loop defines if the animation must loop
  76839. * @param delay defines the start delay (in ms)
  76840. * @param onAnimationEnd defines a callback to call when animation ends
  76841. */
  76842. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  76843. /** Stops current animation (if any) */
  76844. stopAnimation(): void;
  76845. /** @hidden */
  76846. _animate(deltaTime: number): void;
  76847. /** Release associated resources */
  76848. dispose(): void;
  76849. }
  76850. }
  76851. declare module BABYLON {
  76852. /**
  76853. * Information about the result of picking within a scene
  76854. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  76855. */
  76856. export class PickingInfo {
  76857. /**
  76858. * If the pick collided with an object
  76859. */
  76860. hit: boolean;
  76861. /**
  76862. * Distance away where the pick collided
  76863. */
  76864. distance: number;
  76865. /**
  76866. * The location of pick collision
  76867. */
  76868. pickedPoint: Nullable<Vector3>;
  76869. /**
  76870. * The mesh corresponding the the pick collision
  76871. */
  76872. pickedMesh: Nullable<AbstractMesh>;
  76873. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  76874. bu: number;
  76875. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  76876. bv: number;
  76877. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  76878. faceId: number;
  76879. /** Id of the the submesh that was picked */
  76880. subMeshId: number;
  76881. /** If a sprite was picked, this will be the sprite the pick collided with */
  76882. pickedSprite: Nullable<Sprite>;
  76883. /**
  76884. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  76885. */
  76886. originMesh: Nullable<AbstractMesh>;
  76887. /**
  76888. * The ray that was used to perform the picking.
  76889. */
  76890. ray: Nullable<Ray>;
  76891. /**
  76892. * Gets the normal correspodning to the face the pick collided with
  76893. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  76894. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  76895. * @returns The normal correspodning to the face the pick collided with
  76896. */
  76897. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  76898. /**
  76899. * Gets the texture coordinates of where the pick occured
  76900. * @returns the vector containing the coordnates of the texture
  76901. */
  76902. getTextureCoordinates(): Nullable<Vector2>;
  76903. }
  76904. }
  76905. declare module BABYLON {
  76906. /**
  76907. * Class representing a ray with position and direction
  76908. */
  76909. export class Ray {
  76910. /** origin point */
  76911. origin: Vector3;
  76912. /** direction */
  76913. direction: Vector3;
  76914. /** length of the ray */
  76915. length: number;
  76916. private static readonly TmpVector3;
  76917. private _tmpRay;
  76918. /**
  76919. * Creates a new ray
  76920. * @param origin origin point
  76921. * @param direction direction
  76922. * @param length length of the ray
  76923. */
  76924. constructor(
  76925. /** origin point */
  76926. origin: Vector3,
  76927. /** direction */
  76928. direction: Vector3,
  76929. /** length of the ray */
  76930. length?: number);
  76931. /**
  76932. * Checks if the ray intersects a box
  76933. * @param minimum bound of the box
  76934. * @param maximum bound of the box
  76935. * @param intersectionTreshold extra extend to be added to the box in all direction
  76936. * @returns if the box was hit
  76937. */
  76938. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  76939. /**
  76940. * Checks if the ray intersects a box
  76941. * @param box the bounding box to check
  76942. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  76943. * @returns if the box was hit
  76944. */
  76945. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  76946. /**
  76947. * If the ray hits a sphere
  76948. * @param sphere the bounding sphere to check
  76949. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  76950. * @returns true if it hits the sphere
  76951. */
  76952. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  76953. /**
  76954. * If the ray hits a triange
  76955. * @param vertex0 triangle vertex
  76956. * @param vertex1 triangle vertex
  76957. * @param vertex2 triangle vertex
  76958. * @returns intersection information if hit
  76959. */
  76960. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  76961. /**
  76962. * Checks if ray intersects a plane
  76963. * @param plane the plane to check
  76964. * @returns the distance away it was hit
  76965. */
  76966. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  76967. /**
  76968. * Checks if ray intersects a mesh
  76969. * @param mesh the mesh to check
  76970. * @param fastCheck if only the bounding box should checked
  76971. * @returns picking info of the intersecton
  76972. */
  76973. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  76974. /**
  76975. * Checks if ray intersects a mesh
  76976. * @param meshes the meshes to check
  76977. * @param fastCheck if only the bounding box should checked
  76978. * @param results array to store result in
  76979. * @returns Array of picking infos
  76980. */
  76981. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  76982. private _comparePickingInfo;
  76983. private static smallnum;
  76984. private static rayl;
  76985. /**
  76986. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  76987. * @param sega the first point of the segment to test the intersection against
  76988. * @param segb the second point of the segment to test the intersection against
  76989. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  76990. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  76991. */
  76992. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  76993. /**
  76994. * Update the ray from viewport position
  76995. * @param x position
  76996. * @param y y position
  76997. * @param viewportWidth viewport width
  76998. * @param viewportHeight viewport height
  76999. * @param world world matrix
  77000. * @param view view matrix
  77001. * @param projection projection matrix
  77002. * @returns this ray updated
  77003. */
  77004. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77005. /**
  77006. * Creates a ray with origin and direction of 0,0,0
  77007. * @returns the new ray
  77008. */
  77009. static Zero(): Ray;
  77010. /**
  77011. * Creates a new ray from screen space and viewport
  77012. * @param x position
  77013. * @param y y position
  77014. * @param viewportWidth viewport width
  77015. * @param viewportHeight viewport height
  77016. * @param world world matrix
  77017. * @param view view matrix
  77018. * @param projection projection matrix
  77019. * @returns new ray
  77020. */
  77021. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77022. /**
  77023. * 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
  77024. * transformed to the given world matrix.
  77025. * @param origin The origin point
  77026. * @param end The end point
  77027. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77028. * @returns the new ray
  77029. */
  77030. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77031. /**
  77032. * Transforms a ray by a matrix
  77033. * @param ray ray to transform
  77034. * @param matrix matrix to apply
  77035. * @returns the resulting new ray
  77036. */
  77037. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77038. /**
  77039. * Transforms a ray by a matrix
  77040. * @param ray ray to transform
  77041. * @param matrix matrix to apply
  77042. * @param result ray to store result in
  77043. */
  77044. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77045. /**
  77046. * Unproject a ray from screen space to object space
  77047. * @param sourceX defines the screen space x coordinate to use
  77048. * @param sourceY defines the screen space y coordinate to use
  77049. * @param viewportWidth defines the current width of the viewport
  77050. * @param viewportHeight defines the current height of the viewport
  77051. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77052. * @param view defines the view matrix to use
  77053. * @param projection defines the projection matrix to use
  77054. */
  77055. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77056. }
  77057. }
  77058. declare module BABYLON {
  77059. /**
  77060. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77061. * separate meshes. This can be use to improve performances.
  77062. * @see http://doc.babylonjs.com/how_to/multi_materials
  77063. */
  77064. export class MultiMaterial extends Material {
  77065. private _subMaterials;
  77066. /**
  77067. * Gets or Sets the list of Materials used within the multi material.
  77068. * They need to be ordered according to the submeshes order in the associated mesh
  77069. */
  77070. subMaterials: Nullable<Material>[];
  77071. /**
  77072. * Function used to align with Node.getChildren()
  77073. * @returns the list of Materials used within the multi material
  77074. */
  77075. getChildren(): Nullable<Material>[];
  77076. /**
  77077. * Instantiates a new Multi Material
  77078. * A multi-material is used to apply different materials to different parts of the same object without the need of
  77079. * separate meshes. This can be use to improve performances.
  77080. * @see http://doc.babylonjs.com/how_to/multi_materials
  77081. * @param name Define the name in the scene
  77082. * @param scene Define the scene the material belongs to
  77083. */
  77084. constructor(name: string, scene: Scene);
  77085. private _hookArray;
  77086. /**
  77087. * Get one of the submaterial by its index in the submaterials array
  77088. * @param index The index to look the sub material at
  77089. * @returns The Material if the index has been defined
  77090. */
  77091. getSubMaterial(index: number): Nullable<Material>;
  77092. /**
  77093. * Get the list of active textures for the whole sub materials list.
  77094. * @returns All the textures that will be used during the rendering
  77095. */
  77096. getActiveTextures(): BaseTexture[];
  77097. /**
  77098. * Gets the current class name of the material e.g. "MultiMaterial"
  77099. * Mainly use in serialization.
  77100. * @returns the class name
  77101. */
  77102. getClassName(): string;
  77103. /**
  77104. * Checks if the material is ready to render the requested sub mesh
  77105. * @param mesh Define the mesh the submesh belongs to
  77106. * @param subMesh Define the sub mesh to look readyness for
  77107. * @param useInstances Define whether or not the material is used with instances
  77108. * @returns true if ready, otherwise false
  77109. */
  77110. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  77111. /**
  77112. * Clones the current material and its related sub materials
  77113. * @param name Define the name of the newly cloned material
  77114. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  77115. * @returns the cloned material
  77116. */
  77117. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  77118. /**
  77119. * Serializes the materials into a JSON representation.
  77120. * @returns the JSON representation
  77121. */
  77122. serialize(): any;
  77123. /**
  77124. * Dispose the material and release its associated resources
  77125. * @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)
  77126. * @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)
  77127. * @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)
  77128. */
  77129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  77130. /**
  77131. * Creates a MultiMaterial from parsed MultiMaterial data.
  77132. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  77133. * @param scene defines the hosting scene
  77134. * @returns a new MultiMaterial
  77135. */
  77136. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  77137. }
  77138. }
  77139. declare module BABYLON {
  77140. /**
  77141. * Base class for submeshes
  77142. */
  77143. export class BaseSubMesh {
  77144. /** @hidden */
  77145. _materialDefines: Nullable<MaterialDefines>;
  77146. /** @hidden */
  77147. _materialEffect: Nullable<Effect>;
  77148. /**
  77149. * Gets associated effect
  77150. */
  77151. readonly effect: Nullable<Effect>;
  77152. /**
  77153. * Sets associated effect (effect used to render this submesh)
  77154. * @param effect defines the effect to associate with
  77155. * @param defines defines the set of defines used to compile this effect
  77156. */
  77157. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  77158. }
  77159. /**
  77160. * Defines a subdivision inside a mesh
  77161. */
  77162. export class SubMesh extends BaseSubMesh implements ICullable {
  77163. /** the material index to use */
  77164. materialIndex: number;
  77165. /** vertex index start */
  77166. verticesStart: number;
  77167. /** vertices count */
  77168. verticesCount: number;
  77169. /** index start */
  77170. indexStart: number;
  77171. /** indices count */
  77172. indexCount: number;
  77173. /** @hidden */
  77174. _linesIndexCount: number;
  77175. private _mesh;
  77176. private _renderingMesh;
  77177. private _boundingInfo;
  77178. private _linesIndexBuffer;
  77179. /** @hidden */
  77180. _lastColliderWorldVertices: Nullable<Vector3[]>;
  77181. /** @hidden */
  77182. _trianglePlanes: Plane[];
  77183. /** @hidden */
  77184. _lastColliderTransformMatrix: Matrix;
  77185. /** @hidden */
  77186. _renderId: number;
  77187. /** @hidden */
  77188. _alphaIndex: number;
  77189. /** @hidden */
  77190. _distanceToCamera: number;
  77191. /** @hidden */
  77192. _id: number;
  77193. private _currentMaterial;
  77194. /**
  77195. * Add a new submesh to a mesh
  77196. * @param materialIndex defines the material index to use
  77197. * @param verticesStart defines vertex index start
  77198. * @param verticesCount defines vertices count
  77199. * @param indexStart defines index start
  77200. * @param indexCount defines indices count
  77201. * @param mesh defines the parent mesh
  77202. * @param renderingMesh defines an optional rendering mesh
  77203. * @param createBoundingBox defines if bounding box should be created for this submesh
  77204. * @returns the new submesh
  77205. */
  77206. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  77207. /**
  77208. * Creates a new submesh
  77209. * @param materialIndex defines the material index to use
  77210. * @param verticesStart defines vertex index start
  77211. * @param verticesCount defines vertices count
  77212. * @param indexStart defines index start
  77213. * @param indexCount defines indices count
  77214. * @param mesh defines the parent mesh
  77215. * @param renderingMesh defines an optional rendering mesh
  77216. * @param createBoundingBox defines if bounding box should be created for this submesh
  77217. */
  77218. constructor(
  77219. /** the material index to use */
  77220. materialIndex: number,
  77221. /** vertex index start */
  77222. verticesStart: number,
  77223. /** vertices count */
  77224. verticesCount: number,
  77225. /** index start */
  77226. indexStart: number,
  77227. /** indices count */
  77228. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  77229. /**
  77230. * Returns true if this submesh covers the entire parent mesh
  77231. * @ignorenaming
  77232. */
  77233. readonly IsGlobal: boolean;
  77234. /**
  77235. * Returns the submesh BoudingInfo object
  77236. * @returns current bounding info (or mesh's one if the submesh is global)
  77237. */
  77238. getBoundingInfo(): BoundingInfo;
  77239. /**
  77240. * Sets the submesh BoundingInfo
  77241. * @param boundingInfo defines the new bounding info to use
  77242. * @returns the SubMesh
  77243. */
  77244. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  77245. /**
  77246. * Returns the mesh of the current submesh
  77247. * @return the parent mesh
  77248. */
  77249. getMesh(): AbstractMesh;
  77250. /**
  77251. * Returns the rendering mesh of the submesh
  77252. * @returns the rendering mesh (could be different from parent mesh)
  77253. */
  77254. getRenderingMesh(): Mesh;
  77255. /**
  77256. * Returns the submesh material
  77257. * @returns null or the current material
  77258. */
  77259. getMaterial(): Nullable<Material>;
  77260. /**
  77261. * Sets a new updated BoundingInfo object to the submesh
  77262. * @returns the SubMesh
  77263. */
  77264. refreshBoundingInfo(): SubMesh;
  77265. /** @hidden */
  77266. _checkCollision(collider: Collider): boolean;
  77267. /**
  77268. * Updates the submesh BoundingInfo
  77269. * @param world defines the world matrix to use to update the bounding info
  77270. * @returns the submesh
  77271. */
  77272. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  77273. /**
  77274. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  77275. * @param frustumPlanes defines the frustum planes
  77276. * @returns true if the submesh is intersecting with the frustum
  77277. */
  77278. isInFrustum(frustumPlanes: Plane[]): boolean;
  77279. /**
  77280. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  77281. * @param frustumPlanes defines the frustum planes
  77282. * @returns true if the submesh is inside the frustum
  77283. */
  77284. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  77285. /**
  77286. * Renders the submesh
  77287. * @param enableAlphaMode defines if alpha needs to be used
  77288. * @returns the submesh
  77289. */
  77290. render(enableAlphaMode: boolean): SubMesh;
  77291. /**
  77292. * @hidden
  77293. */
  77294. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  77295. /**
  77296. * Checks if the submesh intersects with a ray
  77297. * @param ray defines the ray to test
  77298. * @returns true is the passed ray intersects the submesh bounding box
  77299. */
  77300. canIntersects(ray: Ray): boolean;
  77301. /**
  77302. * Intersects current submesh with a ray
  77303. * @param ray defines the ray to test
  77304. * @param positions defines mesh's positions array
  77305. * @param indices defines mesh's indices array
  77306. * @param fastCheck defines if only bounding info should be used
  77307. * @returns intersection info or null if no intersection
  77308. */
  77309. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  77310. /** @hidden */
  77311. private _intersectLines;
  77312. /** @hidden */
  77313. private _intersectTriangles;
  77314. /** @hidden */
  77315. _rebuild(): void;
  77316. /**
  77317. * Creates a new submesh from the passed mesh
  77318. * @param newMesh defines the new hosting mesh
  77319. * @param newRenderingMesh defines an optional rendering mesh
  77320. * @returns the new submesh
  77321. */
  77322. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  77323. /**
  77324. * Release associated resources
  77325. */
  77326. dispose(): void;
  77327. /**
  77328. * Gets the class name
  77329. * @returns the string "SubMesh".
  77330. */
  77331. getClassName(): string;
  77332. /**
  77333. * Creates a new submesh from indices data
  77334. * @param materialIndex the index of the main mesh material
  77335. * @param startIndex the index where to start the copy in the mesh indices array
  77336. * @param indexCount the number of indices to copy then from the startIndex
  77337. * @param mesh the main mesh to create the submesh from
  77338. * @param renderingMesh the optional rendering mesh
  77339. * @returns a new submesh
  77340. */
  77341. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  77342. }
  77343. }
  77344. declare module BABYLON {
  77345. /**
  77346. * Class used to store geometry data (vertex buffers + index buffer)
  77347. */
  77348. export class Geometry implements IGetSetVerticesData {
  77349. /**
  77350. * Gets or sets the ID of the geometry
  77351. */
  77352. id: string;
  77353. /**
  77354. * Gets or sets the unique ID of the geometry
  77355. */
  77356. uniqueId: number;
  77357. /**
  77358. * Gets the delay loading state of the geometry (none by default which means not delayed)
  77359. */
  77360. delayLoadState: number;
  77361. /**
  77362. * Gets the file containing the data to load when running in delay load state
  77363. */
  77364. delayLoadingFile: Nullable<string>;
  77365. /**
  77366. * Callback called when the geometry is updated
  77367. */
  77368. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  77369. private _scene;
  77370. private _engine;
  77371. private _meshes;
  77372. private _totalVertices;
  77373. /** @hidden */
  77374. _indices: IndicesArray;
  77375. /** @hidden */
  77376. _vertexBuffers: {
  77377. [key: string]: VertexBuffer;
  77378. };
  77379. private _isDisposed;
  77380. private _extend;
  77381. private _boundingBias;
  77382. /** @hidden */
  77383. _delayInfo: Array<string>;
  77384. private _indexBuffer;
  77385. private _indexBufferIsUpdatable;
  77386. /** @hidden */
  77387. _boundingInfo: Nullable<BoundingInfo>;
  77388. /** @hidden */
  77389. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  77390. /** @hidden */
  77391. _softwareSkinningFrameId: number;
  77392. private _vertexArrayObjects;
  77393. private _updatable;
  77394. /** @hidden */
  77395. _positions: Nullable<Vector3[]>;
  77396. /**
  77397. * 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
  77398. */
  77399. /**
  77400. * 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
  77401. */
  77402. boundingBias: Vector2;
  77403. /**
  77404. * Static function used to attach a new empty geometry to a mesh
  77405. * @param mesh defines the mesh to attach the geometry to
  77406. * @returns the new Geometry
  77407. */
  77408. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  77409. /**
  77410. * Creates a new geometry
  77411. * @param id defines the unique ID
  77412. * @param scene defines the hosting scene
  77413. * @param vertexData defines the VertexData used to get geometry data
  77414. * @param updatable defines if geometry must be updatable (false by default)
  77415. * @param mesh defines the mesh that will be associated with the geometry
  77416. */
  77417. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  77418. /**
  77419. * Gets the current extend of the geometry
  77420. */
  77421. readonly extend: {
  77422. minimum: Vector3;
  77423. maximum: Vector3;
  77424. };
  77425. /**
  77426. * Gets the hosting scene
  77427. * @returns the hosting Scene
  77428. */
  77429. getScene(): Scene;
  77430. /**
  77431. * Gets the hosting engine
  77432. * @returns the hosting Engine
  77433. */
  77434. getEngine(): Engine;
  77435. /**
  77436. * Defines if the geometry is ready to use
  77437. * @returns true if the geometry is ready to be used
  77438. */
  77439. isReady(): boolean;
  77440. /**
  77441. * Gets a value indicating that the geometry should not be serialized
  77442. */
  77443. readonly doNotSerialize: boolean;
  77444. /** @hidden */
  77445. _rebuild(): void;
  77446. /**
  77447. * Affects all geometry data in one call
  77448. * @param vertexData defines the geometry data
  77449. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  77450. */
  77451. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  77452. /**
  77453. * Set specific vertex data
  77454. * @param kind defines the data kind (Position, normal, etc...)
  77455. * @param data defines the vertex data to use
  77456. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77457. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77458. */
  77459. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  77460. /**
  77461. * Removes a specific vertex data
  77462. * @param kind defines the data kind (Position, normal, etc...)
  77463. */
  77464. removeVerticesData(kind: string): void;
  77465. /**
  77466. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  77467. * @param buffer defines the vertex buffer to use
  77468. * @param totalVertices defines the total number of vertices for position kind (could be null)
  77469. */
  77470. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  77471. /**
  77472. * Update a specific vertex buffer
  77473. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  77474. * It will do nothing if the buffer is not updatable
  77475. * @param kind defines the data kind (Position, normal, etc...)
  77476. * @param data defines the data to use
  77477. * @param offset defines the offset in the target buffer where to store the data
  77478. * @param useBytes set to true if the offset is in bytes
  77479. */
  77480. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  77481. /**
  77482. * Update a specific vertex buffer
  77483. * This function will create a new buffer if the current one is not updatable
  77484. * @param kind defines the data kind (Position, normal, etc...)
  77485. * @param data defines the data to use
  77486. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  77487. */
  77488. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  77489. private _updateBoundingInfo;
  77490. /** @hidden */
  77491. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  77492. /**
  77493. * Gets total number of vertices
  77494. * @returns the total number of vertices
  77495. */
  77496. getTotalVertices(): number;
  77497. /**
  77498. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77499. * @param kind defines the data kind (Position, normal, etc...)
  77500. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77501. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77502. * @returns a float array containing vertex data
  77503. */
  77504. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77505. /**
  77506. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  77507. * @param kind defines the data kind (Position, normal, etc...)
  77508. * @returns true if the vertex buffer with the specified kind is updatable
  77509. */
  77510. isVertexBufferUpdatable(kind: string): boolean;
  77511. /**
  77512. * Gets a specific vertex buffer
  77513. * @param kind defines the data kind (Position, normal, etc...)
  77514. * @returns a VertexBuffer
  77515. */
  77516. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  77517. /**
  77518. * Returns all vertex buffers
  77519. * @return an object holding all vertex buffers indexed by kind
  77520. */
  77521. getVertexBuffers(): Nullable<{
  77522. [key: string]: VertexBuffer;
  77523. }>;
  77524. /**
  77525. * Gets a boolean indicating if specific vertex buffer is present
  77526. * @param kind defines the data kind (Position, normal, etc...)
  77527. * @returns true if data is present
  77528. */
  77529. isVerticesDataPresent(kind: string): boolean;
  77530. /**
  77531. * Gets a list of all attached data kinds (Position, normal, etc...)
  77532. * @returns a list of string containing all kinds
  77533. */
  77534. getVerticesDataKinds(): string[];
  77535. /**
  77536. * Update index buffer
  77537. * @param indices defines the indices to store in the index buffer
  77538. * @param offset defines the offset in the target buffer where to store the data
  77539. */
  77540. updateIndices(indices: IndicesArray, offset?: number): void;
  77541. /**
  77542. * Creates a new index buffer
  77543. * @param indices defines the indices to store in the index buffer
  77544. * @param totalVertices defines the total number of vertices (could be null)
  77545. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77546. */
  77547. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  77548. /**
  77549. * Return the total number of indices
  77550. * @returns the total number of indices
  77551. */
  77552. getTotalIndices(): number;
  77553. /**
  77554. * Gets the index buffer array
  77555. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77556. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77557. * @returns the index buffer array
  77558. */
  77559. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77560. /**
  77561. * Gets the index buffer
  77562. * @return the index buffer
  77563. */
  77564. getIndexBuffer(): Nullable<WebGLBuffer>;
  77565. /** @hidden */
  77566. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  77567. /**
  77568. * Release the associated resources for a specific mesh
  77569. * @param mesh defines the source mesh
  77570. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  77571. */
  77572. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  77573. /**
  77574. * Apply current geometry to a given mesh
  77575. * @param mesh defines the mesh to apply geometry to
  77576. */
  77577. applyToMesh(mesh: Mesh): void;
  77578. private _updateExtend;
  77579. private _applyToMesh;
  77580. private notifyUpdate;
  77581. /**
  77582. * Load the geometry if it was flagged as delay loaded
  77583. * @param scene defines the hosting scene
  77584. * @param onLoaded defines a callback called when the geometry is loaded
  77585. */
  77586. load(scene: Scene, onLoaded?: () => void): void;
  77587. private _queueLoad;
  77588. /**
  77589. * Invert the geometry to move from a right handed system to a left handed one.
  77590. */
  77591. toLeftHanded(): void;
  77592. /** @hidden */
  77593. _resetPointsArrayCache(): void;
  77594. /** @hidden */
  77595. _generatePointsArray(): boolean;
  77596. /**
  77597. * Gets a value indicating if the geometry is disposed
  77598. * @returns true if the geometry was disposed
  77599. */
  77600. isDisposed(): boolean;
  77601. private _disposeVertexArrayObjects;
  77602. /**
  77603. * Free all associated resources
  77604. */
  77605. dispose(): void;
  77606. /**
  77607. * Clone the current geometry into a new geometry
  77608. * @param id defines the unique ID of the new geometry
  77609. * @returns a new geometry object
  77610. */
  77611. copy(id: string): Geometry;
  77612. /**
  77613. * Serialize the current geometry info (and not the vertices data) into a JSON object
  77614. * @return a JSON representation of the current geometry data (without the vertices data)
  77615. */
  77616. serialize(): any;
  77617. private toNumberArray;
  77618. /**
  77619. * Serialize all vertices data into a JSON oject
  77620. * @returns a JSON representation of the current geometry data
  77621. */
  77622. serializeVerticeData(): any;
  77623. /**
  77624. * Extracts a clone of a mesh geometry
  77625. * @param mesh defines the source mesh
  77626. * @param id defines the unique ID of the new geometry object
  77627. * @returns the new geometry object
  77628. */
  77629. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  77630. /**
  77631. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  77632. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  77633. * Be aware Math.random() could cause collisions, but:
  77634. * "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"
  77635. * @returns a string containing a new GUID
  77636. */
  77637. static RandomId(): string;
  77638. /** @hidden */
  77639. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  77640. private static _CleanMatricesWeights;
  77641. /**
  77642. * Create a new geometry from persisted data (Using .babylon file format)
  77643. * @param parsedVertexData defines the persisted data
  77644. * @param scene defines the hosting scene
  77645. * @param rootUrl defines the root url to use to load assets (like delayed data)
  77646. * @returns the new geometry object
  77647. */
  77648. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  77649. }
  77650. }
  77651. declare module BABYLON {
  77652. /**
  77653. * Define an interface for all classes that will get and set the data on vertices
  77654. */
  77655. export interface IGetSetVerticesData {
  77656. /**
  77657. * Gets a boolean indicating if specific vertex data is present
  77658. * @param kind defines the vertex data kind to use
  77659. * @returns true is data kind is present
  77660. */
  77661. isVerticesDataPresent(kind: string): boolean;
  77662. /**
  77663. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  77664. * @param kind defines the data kind (Position, normal, etc...)
  77665. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  77666. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77667. * @returns a float array containing vertex data
  77668. */
  77669. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  77670. /**
  77671. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  77672. * @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.
  77673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  77674. * @returns the indices array or an empty array if the mesh has no geometry
  77675. */
  77676. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  77677. /**
  77678. * Set specific vertex data
  77679. * @param kind defines the data kind (Position, normal, etc...)
  77680. * @param data defines the vertex data to use
  77681. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  77682. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  77683. */
  77684. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  77685. /**
  77686. * Update a specific associated vertex buffer
  77687. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  77688. * - VertexBuffer.PositionKind
  77689. * - VertexBuffer.UVKind
  77690. * - VertexBuffer.UV2Kind
  77691. * - VertexBuffer.UV3Kind
  77692. * - VertexBuffer.UV4Kind
  77693. * - VertexBuffer.UV5Kind
  77694. * - VertexBuffer.UV6Kind
  77695. * - VertexBuffer.ColorKind
  77696. * - VertexBuffer.MatricesIndicesKind
  77697. * - VertexBuffer.MatricesIndicesExtraKind
  77698. * - VertexBuffer.MatricesWeightsKind
  77699. * - VertexBuffer.MatricesWeightsExtraKind
  77700. * @param data defines the data source
  77701. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  77702. * @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)
  77703. */
  77704. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  77705. /**
  77706. * Creates a new index buffer
  77707. * @param indices defines the indices to store in the index buffer
  77708. * @param totalVertices defines the total number of vertices (could be null)
  77709. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  77710. */
  77711. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  77712. }
  77713. /**
  77714. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  77715. */
  77716. export class VertexData {
  77717. /**
  77718. * Mesh side orientation : usually the external or front surface
  77719. */
  77720. static readonly FRONTSIDE: number;
  77721. /**
  77722. * Mesh side orientation : usually the internal or back surface
  77723. */
  77724. static readonly BACKSIDE: number;
  77725. /**
  77726. * Mesh side orientation : both internal and external or front and back surfaces
  77727. */
  77728. static readonly DOUBLESIDE: number;
  77729. /**
  77730. * Mesh side orientation : by default, `FRONTSIDE`
  77731. */
  77732. static readonly DEFAULTSIDE: number;
  77733. /**
  77734. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  77735. */
  77736. positions: Nullable<FloatArray>;
  77737. /**
  77738. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  77739. */
  77740. normals: Nullable<FloatArray>;
  77741. /**
  77742. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  77743. */
  77744. tangents: Nullable<FloatArray>;
  77745. /**
  77746. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77747. */
  77748. uvs: Nullable<FloatArray>;
  77749. /**
  77750. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77751. */
  77752. uvs2: Nullable<FloatArray>;
  77753. /**
  77754. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77755. */
  77756. uvs3: Nullable<FloatArray>;
  77757. /**
  77758. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77759. */
  77760. uvs4: Nullable<FloatArray>;
  77761. /**
  77762. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77763. */
  77764. uvs5: Nullable<FloatArray>;
  77765. /**
  77766. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  77767. */
  77768. uvs6: Nullable<FloatArray>;
  77769. /**
  77770. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  77771. */
  77772. colors: Nullable<FloatArray>;
  77773. /**
  77774. * 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).
  77775. */
  77776. matricesIndices: Nullable<FloatArray>;
  77777. /**
  77778. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  77779. */
  77780. matricesWeights: Nullable<FloatArray>;
  77781. /**
  77782. * An array extending the number of possible indices
  77783. */
  77784. matricesIndicesExtra: Nullable<FloatArray>;
  77785. /**
  77786. * An array extending the number of possible weights when the number of indices is extended
  77787. */
  77788. matricesWeightsExtra: Nullable<FloatArray>;
  77789. /**
  77790. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  77791. */
  77792. indices: Nullable<IndicesArray>;
  77793. /**
  77794. * Uses the passed data array to set the set the values for the specified kind of data
  77795. * @param data a linear array of floating numbers
  77796. * @param kind the type of data that is being set, eg positions, colors etc
  77797. */
  77798. set(data: FloatArray, kind: string): void;
  77799. /**
  77800. * Associates the vertexData to the passed Mesh.
  77801. * Sets it as updatable or not (default `false`)
  77802. * @param mesh the mesh the vertexData is applied to
  77803. * @param updatable when used and having the value true allows new data to update the vertexData
  77804. * @returns the VertexData
  77805. */
  77806. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  77807. /**
  77808. * Associates the vertexData to the passed Geometry.
  77809. * Sets it as updatable or not (default `false`)
  77810. * @param geometry the geometry the vertexData is applied to
  77811. * @param updatable when used and having the value true allows new data to update the vertexData
  77812. * @returns VertexData
  77813. */
  77814. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  77815. /**
  77816. * Updates the associated mesh
  77817. * @param mesh the mesh to be updated
  77818. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77819. * @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
  77820. * @returns VertexData
  77821. */
  77822. updateMesh(mesh: Mesh): VertexData;
  77823. /**
  77824. * Updates the associated geometry
  77825. * @param geometry the geometry to be updated
  77826. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  77827. * @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
  77828. * @returns VertexData.
  77829. */
  77830. updateGeometry(geometry: Geometry): VertexData;
  77831. private _applyTo;
  77832. private _update;
  77833. /**
  77834. * Transforms each position and each normal of the vertexData according to the passed Matrix
  77835. * @param matrix the transforming matrix
  77836. * @returns the VertexData
  77837. */
  77838. transform(matrix: Matrix): VertexData;
  77839. /**
  77840. * Merges the passed VertexData into the current one
  77841. * @param other the VertexData to be merged into the current one
  77842. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  77843. * @returns the modified VertexData
  77844. */
  77845. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  77846. private _mergeElement;
  77847. private _validate;
  77848. /**
  77849. * Serializes the VertexData
  77850. * @returns a serialized object
  77851. */
  77852. serialize(): any;
  77853. /**
  77854. * Extracts the vertexData from a mesh
  77855. * @param mesh the mesh from which to extract the VertexData
  77856. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  77857. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77858. * @returns the object VertexData associated to the passed mesh
  77859. */
  77860. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77861. /**
  77862. * Extracts the vertexData from the geometry
  77863. * @param geometry the geometry from which to extract the VertexData
  77864. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  77865. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  77866. * @returns the object VertexData associated to the passed mesh
  77867. */
  77868. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  77869. private static _ExtractFrom;
  77870. /**
  77871. * Creates the VertexData for a Ribbon
  77872. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  77873. * * pathArray array of paths, each of which an array of successive Vector3
  77874. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  77875. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  77876. * * 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
  77877. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77878. * * 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)
  77879. * * 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)
  77880. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  77881. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  77882. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  77883. * @returns the VertexData of the ribbon
  77884. */
  77885. static CreateRibbon(options: {
  77886. pathArray: Vector3[][];
  77887. closeArray?: boolean;
  77888. closePath?: boolean;
  77889. offset?: number;
  77890. sideOrientation?: number;
  77891. frontUVs?: Vector4;
  77892. backUVs?: Vector4;
  77893. invertUV?: boolean;
  77894. uvs?: Vector2[];
  77895. colors?: Color4[];
  77896. }): VertexData;
  77897. /**
  77898. * Creates the VertexData for a box
  77899. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77900. * * size sets the width, height and depth of the box to the value of size, optional default 1
  77901. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  77902. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  77903. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  77904. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  77905. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  77906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77907. * * 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)
  77908. * * 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)
  77909. * @returns the VertexData of the box
  77910. */
  77911. static CreateBox(options: {
  77912. size?: number;
  77913. width?: number;
  77914. height?: number;
  77915. depth?: number;
  77916. faceUV?: Vector4[];
  77917. faceColors?: Color4[];
  77918. sideOrientation?: number;
  77919. frontUVs?: Vector4;
  77920. backUVs?: Vector4;
  77921. }): VertexData;
  77922. /**
  77923. * Creates the VertexData for an ellipsoid, defaults to a sphere
  77924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77925. * * segments sets the number of horizontal strips optional, default 32
  77926. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  77927. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  77928. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  77929. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  77930. * * 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
  77931. * * 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
  77932. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77933. * * 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)
  77934. * * 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)
  77935. * @returns the VertexData of the ellipsoid
  77936. */
  77937. static CreateSphere(options: {
  77938. segments?: number;
  77939. diameter?: number;
  77940. diameterX?: number;
  77941. diameterY?: number;
  77942. diameterZ?: number;
  77943. arc?: number;
  77944. slice?: number;
  77945. sideOrientation?: number;
  77946. frontUVs?: Vector4;
  77947. backUVs?: Vector4;
  77948. }): VertexData;
  77949. /**
  77950. * Creates the VertexData for a cylinder, cone or prism
  77951. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77952. * * height sets the height (y direction) of the cylinder, optional, default 2
  77953. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  77954. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  77955. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  77956. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  77957. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  77958. * * 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
  77959. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  77960. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  77961. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  77962. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  77963. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77964. * * 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)
  77965. * * 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)
  77966. * @returns the VertexData of the cylinder, cone or prism
  77967. */
  77968. static CreateCylinder(options: {
  77969. height?: number;
  77970. diameterTop?: number;
  77971. diameterBottom?: number;
  77972. diameter?: number;
  77973. tessellation?: number;
  77974. subdivisions?: number;
  77975. arc?: number;
  77976. faceColors?: Color4[];
  77977. faceUV?: Vector4[];
  77978. hasRings?: boolean;
  77979. enclose?: boolean;
  77980. sideOrientation?: number;
  77981. frontUVs?: Vector4;
  77982. backUVs?: Vector4;
  77983. }): VertexData;
  77984. /**
  77985. * Creates the VertexData for a torus
  77986. * @param options an object used to set the following optional parameters for the box, required but can be empty
  77987. * * diameter the diameter of the torus, optional default 1
  77988. * * thickness the diameter of the tube forming the torus, optional default 0.5
  77989. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  77990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77991. * * 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)
  77992. * * 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)
  77993. * @returns the VertexData of the torus
  77994. */
  77995. static CreateTorus(options: {
  77996. diameter?: number;
  77997. thickness?: number;
  77998. tessellation?: number;
  77999. sideOrientation?: number;
  78000. frontUVs?: Vector4;
  78001. backUVs?: Vector4;
  78002. }): VertexData;
  78003. /**
  78004. * Creates the VertexData of the LineSystem
  78005. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  78006. * - lines an array of lines, each line being an array of successive Vector3
  78007. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  78008. * @returns the VertexData of the LineSystem
  78009. */
  78010. static CreateLineSystem(options: {
  78011. lines: Vector3[][];
  78012. colors?: Nullable<Color4[][]>;
  78013. }): VertexData;
  78014. /**
  78015. * Create the VertexData for a DashedLines
  78016. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  78017. * - points an array successive Vector3
  78018. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  78019. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  78020. * - dashNb the intended total number of dashes, optional, default 200
  78021. * @returns the VertexData for the DashedLines
  78022. */
  78023. static CreateDashedLines(options: {
  78024. points: Vector3[];
  78025. dashSize?: number;
  78026. gapSize?: number;
  78027. dashNb?: number;
  78028. }): VertexData;
  78029. /**
  78030. * Creates the VertexData for a Ground
  78031. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78032. * - width the width (x direction) of the ground, optional, default 1
  78033. * - height the height (z direction) of the ground, optional, default 1
  78034. * - subdivisions the number of subdivisions per side, optional, default 1
  78035. * @returns the VertexData of the Ground
  78036. */
  78037. static CreateGround(options: {
  78038. width?: number;
  78039. height?: number;
  78040. subdivisions?: number;
  78041. subdivisionsX?: number;
  78042. subdivisionsY?: number;
  78043. }): VertexData;
  78044. /**
  78045. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  78046. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  78047. * * xmin the ground minimum X coordinate, optional, default -1
  78048. * * zmin the ground minimum Z coordinate, optional, default -1
  78049. * * xmax the ground maximum X coordinate, optional, default 1
  78050. * * zmax the ground maximum Z coordinate, optional, default 1
  78051. * * 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}
  78052. * * 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}
  78053. * @returns the VertexData of the TiledGround
  78054. */
  78055. static CreateTiledGround(options: {
  78056. xmin: number;
  78057. zmin: number;
  78058. xmax: number;
  78059. zmax: number;
  78060. subdivisions?: {
  78061. w: number;
  78062. h: number;
  78063. };
  78064. precision?: {
  78065. w: number;
  78066. h: number;
  78067. };
  78068. }): VertexData;
  78069. /**
  78070. * Creates the VertexData of the Ground designed from a heightmap
  78071. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  78072. * * width the width (x direction) of the ground
  78073. * * height the height (z direction) of the ground
  78074. * * subdivisions the number of subdivisions per side
  78075. * * minHeight the minimum altitude on the ground, optional, default 0
  78076. * * maxHeight the maximum altitude on the ground, optional default 1
  78077. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  78078. * * buffer the array holding the image color data
  78079. * * bufferWidth the width of image
  78080. * * bufferHeight the height of image
  78081. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  78082. * @returns the VertexData of the Ground designed from a heightmap
  78083. */
  78084. static CreateGroundFromHeightMap(options: {
  78085. width: number;
  78086. height: number;
  78087. subdivisions: number;
  78088. minHeight: number;
  78089. maxHeight: number;
  78090. colorFilter: Color3;
  78091. buffer: Uint8Array;
  78092. bufferWidth: number;
  78093. bufferHeight: number;
  78094. alphaFilter: number;
  78095. }): VertexData;
  78096. /**
  78097. * Creates the VertexData for a Plane
  78098. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  78099. * * size sets the width and height of the plane to the value of size, optional default 1
  78100. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  78101. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  78102. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78103. * * 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)
  78104. * * 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)
  78105. * @returns the VertexData of the box
  78106. */
  78107. static CreatePlane(options: {
  78108. size?: number;
  78109. width?: number;
  78110. height?: number;
  78111. sideOrientation?: number;
  78112. frontUVs?: Vector4;
  78113. backUVs?: Vector4;
  78114. }): VertexData;
  78115. /**
  78116. * Creates the VertexData of the Disc or regular Polygon
  78117. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  78118. * * radius the radius of the disc, optional default 0.5
  78119. * * tessellation the number of polygon sides, optional, default 64
  78120. * * 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
  78121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78122. * * 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)
  78123. * * 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)
  78124. * @returns the VertexData of the box
  78125. */
  78126. static CreateDisc(options: {
  78127. radius?: number;
  78128. tessellation?: number;
  78129. arc?: number;
  78130. sideOrientation?: number;
  78131. frontUVs?: Vector4;
  78132. backUVs?: Vector4;
  78133. }): VertexData;
  78134. /**
  78135. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  78136. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  78137. * @param polygon a mesh built from polygonTriangulation.build()
  78138. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78139. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78140. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78141. * @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)
  78142. * @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)
  78143. * @returns the VertexData of the Polygon
  78144. */
  78145. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  78146. /**
  78147. * Creates the VertexData of the IcoSphere
  78148. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  78149. * * radius the radius of the IcoSphere, optional default 1
  78150. * * radiusX allows stretching in the x direction, optional, default radius
  78151. * * radiusY allows stretching in the y direction, optional, default radius
  78152. * * radiusZ allows stretching in the z direction, optional, default radius
  78153. * * flat when true creates a flat shaded mesh, optional, default true
  78154. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78155. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78156. * * 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)
  78157. * * 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)
  78158. * @returns the VertexData of the IcoSphere
  78159. */
  78160. static CreateIcoSphere(options: {
  78161. radius?: number;
  78162. radiusX?: number;
  78163. radiusY?: number;
  78164. radiusZ?: number;
  78165. flat?: boolean;
  78166. subdivisions?: number;
  78167. sideOrientation?: number;
  78168. frontUVs?: Vector4;
  78169. backUVs?: Vector4;
  78170. }): VertexData;
  78171. /**
  78172. * Creates the VertexData for a Polyhedron
  78173. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  78174. * * type provided types are:
  78175. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  78176. * * 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)
  78177. * * size the size of the IcoSphere, optional default 1
  78178. * * sizeX allows stretching in the x direction, optional, default size
  78179. * * sizeY allows stretching in the y direction, optional, default size
  78180. * * sizeZ allows stretching in the z direction, optional, default size
  78181. * * 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
  78182. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  78183. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  78184. * * flat when true creates a flat shaded mesh, optional, default true
  78185. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  78186. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78187. * * 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)
  78188. * * 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)
  78189. * @returns the VertexData of the Polyhedron
  78190. */
  78191. static CreatePolyhedron(options: {
  78192. type?: number;
  78193. size?: number;
  78194. sizeX?: number;
  78195. sizeY?: number;
  78196. sizeZ?: number;
  78197. custom?: any;
  78198. faceUV?: Vector4[];
  78199. faceColors?: Color4[];
  78200. flat?: boolean;
  78201. sideOrientation?: number;
  78202. frontUVs?: Vector4;
  78203. backUVs?: Vector4;
  78204. }): VertexData;
  78205. /**
  78206. * Creates the VertexData for a TorusKnot
  78207. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  78208. * * radius the radius of the torus knot, optional, default 2
  78209. * * tube the thickness of the tube, optional, default 0.5
  78210. * * radialSegments the number of sides on each tube segments, optional, default 32
  78211. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  78212. * * p the number of windings around the z axis, optional, default 2
  78213. * * q the number of windings around the x axis, optional, default 3
  78214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  78215. * * 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)
  78216. * * 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)
  78217. * @returns the VertexData of the Torus Knot
  78218. */
  78219. static CreateTorusKnot(options: {
  78220. radius?: number;
  78221. tube?: number;
  78222. radialSegments?: number;
  78223. tubularSegments?: number;
  78224. p?: number;
  78225. q?: number;
  78226. sideOrientation?: number;
  78227. frontUVs?: Vector4;
  78228. backUVs?: Vector4;
  78229. }): VertexData;
  78230. /**
  78231. * Compute normals for given positions and indices
  78232. * @param positions an array of vertex positions, [...., x, y, z, ......]
  78233. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  78234. * @param normals an array of vertex normals, [...., x, y, z, ......]
  78235. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  78236. * * facetNormals : optional array of facet normals (vector3)
  78237. * * facetPositions : optional array of facet positions (vector3)
  78238. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  78239. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  78240. * * bInfo : optional bounding info, required for facetPartitioning computation
  78241. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  78242. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  78243. * * useRightHandedSystem: optional boolean to for right handed system computation
  78244. * * depthSort : optional boolean to enable the facet depth sort computation
  78245. * * distanceTo : optional Vector3 to compute the facet depth from this location
  78246. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  78247. */
  78248. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  78249. facetNormals?: any;
  78250. facetPositions?: any;
  78251. facetPartitioning?: any;
  78252. ratio?: number;
  78253. bInfo?: any;
  78254. bbSize?: Vector3;
  78255. subDiv?: any;
  78256. useRightHandedSystem?: boolean;
  78257. depthSort?: boolean;
  78258. distanceTo?: Vector3;
  78259. depthSortedFacets?: any;
  78260. }): void;
  78261. /** @hidden */
  78262. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  78263. /**
  78264. * Applies VertexData created from the imported parameters to the geometry
  78265. * @param parsedVertexData the parsed data from an imported file
  78266. * @param geometry the geometry to apply the VertexData to
  78267. */
  78268. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  78269. }
  78270. }
  78271. declare module BABYLON {
  78272. /**
  78273. * Class containing static functions to help procedurally build meshes
  78274. */
  78275. export class DiscBuilder {
  78276. /**
  78277. * Creates a plane polygonal mesh. By default, this is a disc
  78278. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  78279. * * 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
  78280. * * 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
  78281. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78282. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  78283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78284. * @param name defines the name of the mesh
  78285. * @param options defines the options used to create the mesh
  78286. * @param scene defines the hosting scene
  78287. * @returns the plane polygonal mesh
  78288. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  78289. */
  78290. static CreateDisc(name: string, options: {
  78291. radius?: number;
  78292. tessellation?: number;
  78293. arc?: number;
  78294. updatable?: boolean;
  78295. sideOrientation?: number;
  78296. frontUVs?: Vector4;
  78297. backUVs?: Vector4;
  78298. }, scene?: Nullable<Scene>): Mesh;
  78299. }
  78300. }
  78301. declare module BABYLON {
  78302. /**
  78303. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  78304. *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.
  78305. * The SPS is also a particle system. It provides some methods to manage the particles.
  78306. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  78307. *
  78308. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  78309. */
  78310. export class SolidParticleSystem implements IDisposable {
  78311. /**
  78312. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  78313. * Example : var p = SPS.particles[i];
  78314. */
  78315. particles: SolidParticle[];
  78316. /**
  78317. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  78318. */
  78319. nbParticles: number;
  78320. /**
  78321. * If the particles must ever face the camera (default false). Useful for planar particles.
  78322. */
  78323. billboard: boolean;
  78324. /**
  78325. * Recompute normals when adding a shape
  78326. */
  78327. recomputeNormals: boolean;
  78328. /**
  78329. * This a counter ofr your own usage. It's not set by any SPS functions.
  78330. */
  78331. counter: number;
  78332. /**
  78333. * The SPS name. This name is also given to the underlying mesh.
  78334. */
  78335. name: string;
  78336. /**
  78337. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  78338. */
  78339. mesh: Mesh;
  78340. /**
  78341. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  78342. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  78343. */
  78344. vars: any;
  78345. /**
  78346. * This array is populated when the SPS is set as 'pickable'.
  78347. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  78348. * Each element of this array is an object `{idx: int, faceId: int}`.
  78349. * `idx` is the picked particle index in the `SPS.particles` array
  78350. * `faceId` is the picked face index counted within this particle.
  78351. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  78352. */
  78353. pickedParticles: {
  78354. idx: number;
  78355. faceId: number;
  78356. }[];
  78357. /**
  78358. * This array is populated when `enableDepthSort` is set to true.
  78359. * Each element of this array is an instance of the class DepthSortedParticle.
  78360. */
  78361. depthSortedParticles: DepthSortedParticle[];
  78362. /**
  78363. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  78364. * @hidden
  78365. */
  78366. _bSphereOnly: boolean;
  78367. /**
  78368. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  78369. * @hidden
  78370. */
  78371. _bSphereRadiusFactor: number;
  78372. private _scene;
  78373. private _positions;
  78374. private _indices;
  78375. private _normals;
  78376. private _colors;
  78377. private _uvs;
  78378. private _indices32;
  78379. private _positions32;
  78380. private _normals32;
  78381. private _fixedNormal32;
  78382. private _colors32;
  78383. private _uvs32;
  78384. private _index;
  78385. private _updatable;
  78386. private _pickable;
  78387. private _isVisibilityBoxLocked;
  78388. private _alwaysVisible;
  78389. private _depthSort;
  78390. private _shapeCounter;
  78391. private _copy;
  78392. private _color;
  78393. private _computeParticleColor;
  78394. private _computeParticleTexture;
  78395. private _computeParticleRotation;
  78396. private _computeParticleVertex;
  78397. private _computeBoundingBox;
  78398. private _depthSortParticles;
  78399. private _camera;
  78400. private _mustUnrotateFixedNormals;
  78401. private _particlesIntersect;
  78402. private _needs32Bits;
  78403. /**
  78404. * Creates a SPS (Solid Particle System) object.
  78405. * @param name (String) is the SPS name, this will be the underlying mesh name.
  78406. * @param scene (Scene) is the scene in which the SPS is added.
  78407. * @param options defines the options of the sps e.g.
  78408. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  78409. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  78410. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  78411. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  78412. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  78413. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  78414. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  78415. */
  78416. constructor(name: string, scene: Scene, options?: {
  78417. updatable?: boolean;
  78418. isPickable?: boolean;
  78419. enableDepthSort?: boolean;
  78420. particleIntersection?: boolean;
  78421. boundingSphereOnly?: boolean;
  78422. bSphereRadiusFactor?: number;
  78423. });
  78424. /**
  78425. * Builds the SPS underlying mesh. Returns a standard Mesh.
  78426. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  78427. * @returns the created mesh
  78428. */
  78429. buildMesh(): Mesh;
  78430. /**
  78431. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  78432. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  78433. * Thus the particles generated from `digest()` have their property `position` set yet.
  78434. * @param mesh ( Mesh ) is the mesh to be digested
  78435. * @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
  78436. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  78437. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  78438. * @returns the current SPS
  78439. */
  78440. digest(mesh: Mesh, options?: {
  78441. facetNb?: number;
  78442. number?: number;
  78443. delta?: number;
  78444. }): SolidParticleSystem;
  78445. private _unrotateFixedNormals;
  78446. private _resetCopy;
  78447. private _meshBuilder;
  78448. private _posToShape;
  78449. private _uvsToShapeUV;
  78450. private _addParticle;
  78451. /**
  78452. * Adds some particles to the SPS from the model shape. Returns the shape id.
  78453. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  78454. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  78455. * @param nb (positive integer) the number of particles to be created from this model
  78456. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  78457. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  78458. * @returns the number of shapes in the system
  78459. */
  78460. addShape(mesh: Mesh, nb: number, options?: {
  78461. positionFunction?: any;
  78462. vertexFunction?: any;
  78463. }): number;
  78464. private _rebuildParticle;
  78465. /**
  78466. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  78467. * @returns the SPS.
  78468. */
  78469. rebuildMesh(): SolidParticleSystem;
  78470. /**
  78471. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  78472. * This method calls `updateParticle()` for each particle of the SPS.
  78473. * For an animated SPS, it is usually called within the render loop.
  78474. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  78475. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  78476. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  78477. * @returns the SPS.
  78478. */
  78479. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  78480. /**
  78481. * Disposes the SPS.
  78482. */
  78483. dispose(): void;
  78484. /**
  78485. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  78486. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78487. * @returns the SPS.
  78488. */
  78489. refreshVisibleSize(): SolidParticleSystem;
  78490. /**
  78491. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  78492. * @param size the size (float) of the visibility box
  78493. * note : this doesn't lock the SPS mesh bounding box.
  78494. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78495. */
  78496. setVisibilityBox(size: number): void;
  78497. /**
  78498. * Gets whether the SPS as always visible or not
  78499. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78500. */
  78501. /**
  78502. * Sets the SPS as always visible or not
  78503. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78504. */
  78505. isAlwaysVisible: boolean;
  78506. /**
  78507. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78508. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78509. */
  78510. /**
  78511. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  78512. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  78513. */
  78514. isVisibilityBoxLocked: boolean;
  78515. /**
  78516. * Tells to `setParticles()` to compute the particle rotations or not.
  78517. * Default value : true. The SPS is faster when it's set to false.
  78518. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78519. */
  78520. /**
  78521. * Gets if `setParticles()` computes the particle rotations or not.
  78522. * Default value : true. The SPS is faster when it's set to false.
  78523. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  78524. */
  78525. computeParticleRotation: boolean;
  78526. /**
  78527. * Tells to `setParticles()` to compute the particle colors or not.
  78528. * Default value : true. The SPS is faster when it's set to false.
  78529. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78530. */
  78531. /**
  78532. * Gets if `setParticles()` computes the particle colors or not.
  78533. * Default value : true. The SPS is faster when it's set to false.
  78534. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  78535. */
  78536. computeParticleColor: boolean;
  78537. /**
  78538. * Gets if `setParticles()` computes the particle textures or not.
  78539. * Default value : true. The SPS is faster when it's set to false.
  78540. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  78541. */
  78542. computeParticleTexture: boolean;
  78543. /**
  78544. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  78545. * Default value : false. The SPS is faster when it's set to false.
  78546. * Note : the particle custom vertex positions aren't stored values.
  78547. */
  78548. /**
  78549. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  78550. * Default value : false. The SPS is faster when it's set to false.
  78551. * Note : the particle custom vertex positions aren't stored values.
  78552. */
  78553. computeParticleVertex: boolean;
  78554. /**
  78555. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  78556. */
  78557. /**
  78558. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  78559. */
  78560. computeBoundingBox: boolean;
  78561. /**
  78562. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  78563. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78564. * Default : `true`
  78565. */
  78566. /**
  78567. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  78568. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  78569. * Default : `true`
  78570. */
  78571. depthSortParticles: boolean;
  78572. /**
  78573. * This function does nothing. It may be overwritten to set all the particle first values.
  78574. * The SPS doesn't call this function, you may have to call it by your own.
  78575. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78576. */
  78577. initParticles(): void;
  78578. /**
  78579. * This function does nothing. It may be overwritten to recycle a particle.
  78580. * The SPS doesn't call this function, you may have to call it by your own.
  78581. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78582. * @param particle The particle to recycle
  78583. * @returns the recycled particle
  78584. */
  78585. recycleParticle(particle: SolidParticle): SolidParticle;
  78586. /**
  78587. * Updates a particle : this function should be overwritten by the user.
  78588. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  78589. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  78590. * @example : just set a particle position or velocity and recycle conditions
  78591. * @param particle The particle to update
  78592. * @returns the updated particle
  78593. */
  78594. updateParticle(particle: SolidParticle): SolidParticle;
  78595. /**
  78596. * Updates a vertex of a particle : it can be overwritten by the user.
  78597. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  78598. * @param particle the current particle
  78599. * @param vertex the current index of the current particle
  78600. * @param pt the index of the current vertex in the particle shape
  78601. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  78602. * @example : just set a vertex particle position
  78603. * @returns the updated vertex
  78604. */
  78605. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  78606. /**
  78607. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  78608. * This does nothing and may be overwritten by the user.
  78609. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78610. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78611. * @param update the boolean update value actually passed to setParticles()
  78612. */
  78613. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78614. /**
  78615. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  78616. * This will be passed three parameters.
  78617. * This does nothing and may be overwritten by the user.
  78618. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78619. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  78620. * @param update the boolean update value actually passed to setParticles()
  78621. */
  78622. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  78623. }
  78624. }
  78625. declare module BABYLON {
  78626. /**
  78627. * Represents one particle of a solid particle system.
  78628. */
  78629. export class SolidParticle {
  78630. /**
  78631. * particle global index
  78632. */
  78633. idx: number;
  78634. /**
  78635. * The color of the particle
  78636. */
  78637. color: Nullable<Color4>;
  78638. /**
  78639. * The world space position of the particle.
  78640. */
  78641. position: Vector3;
  78642. /**
  78643. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  78644. */
  78645. rotation: Vector3;
  78646. /**
  78647. * The world space rotation quaternion of the particle.
  78648. */
  78649. rotationQuaternion: Nullable<Quaternion>;
  78650. /**
  78651. * The scaling of the particle.
  78652. */
  78653. scaling: Vector3;
  78654. /**
  78655. * The uvs of the particle.
  78656. */
  78657. uvs: Vector4;
  78658. /**
  78659. * The current speed of the particle.
  78660. */
  78661. velocity: Vector3;
  78662. /**
  78663. * The pivot point in the particle local space.
  78664. */
  78665. pivot: Vector3;
  78666. /**
  78667. * Must the particle be translated from its pivot point in its local space ?
  78668. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  78669. * Default : false
  78670. */
  78671. translateFromPivot: boolean;
  78672. /**
  78673. * Is the particle active or not ?
  78674. */
  78675. alive: boolean;
  78676. /**
  78677. * Is the particle visible or not ?
  78678. */
  78679. isVisible: boolean;
  78680. /**
  78681. * Index of this particle in the global "positions" array (Internal use)
  78682. * @hidden
  78683. */
  78684. _pos: number;
  78685. /**
  78686. * @hidden Index of this particle in the global "indices" array (Internal use)
  78687. */
  78688. _ind: number;
  78689. /**
  78690. * @hidden ModelShape of this particle (Internal use)
  78691. */
  78692. _model: ModelShape;
  78693. /**
  78694. * ModelShape id of this particle
  78695. */
  78696. shapeId: number;
  78697. /**
  78698. * Index of the particle in its shape id (Internal use)
  78699. */
  78700. idxInShape: number;
  78701. /**
  78702. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  78703. */
  78704. _modelBoundingInfo: BoundingInfo;
  78705. /**
  78706. * @hidden Particle BoundingInfo object (Internal use)
  78707. */
  78708. _boundingInfo: BoundingInfo;
  78709. /**
  78710. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  78711. */
  78712. _sps: SolidParticleSystem;
  78713. /**
  78714. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  78715. */
  78716. _stillInvisible: boolean;
  78717. /**
  78718. * @hidden Last computed particle rotation matrix
  78719. */
  78720. _rotationMatrix: number[];
  78721. /**
  78722. * Parent particle Id, if any.
  78723. * Default null.
  78724. */
  78725. parentId: Nullable<number>;
  78726. /**
  78727. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  78728. * The possible values are :
  78729. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78730. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78731. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78732. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78733. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78734. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  78735. * */
  78736. cullingStrategy: number;
  78737. /**
  78738. * @hidden Internal global position in the SPS.
  78739. */
  78740. _globalPosition: Vector3;
  78741. /**
  78742. * Creates a Solid Particle object.
  78743. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  78744. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  78745. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  78746. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  78747. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  78748. * @param shapeId (integer) is the model shape identifier in the SPS.
  78749. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  78750. * @param sps defines the sps it is associated to
  78751. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  78752. */
  78753. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  78754. /**
  78755. * Legacy support, changed scale to scaling
  78756. */
  78757. /**
  78758. * Legacy support, changed scale to scaling
  78759. */
  78760. scale: Vector3;
  78761. /**
  78762. * Legacy support, changed quaternion to rotationQuaternion
  78763. */
  78764. /**
  78765. * Legacy support, changed quaternion to rotationQuaternion
  78766. */
  78767. quaternion: Nullable<Quaternion>;
  78768. /**
  78769. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  78770. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  78771. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  78772. * @returns true if it intersects
  78773. */
  78774. intersectsMesh(target: Mesh | SolidParticle): boolean;
  78775. /**
  78776. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  78777. * A particle is in the frustum if its bounding box intersects the frustum
  78778. * @param frustumPlanes defines the frustum to test
  78779. * @returns true if the particle is in the frustum planes
  78780. */
  78781. isInFrustum(frustumPlanes: Plane[]): boolean;
  78782. /**
  78783. * get the rotation matrix of the particle
  78784. * @hidden
  78785. */
  78786. getRotationMatrix(m: Matrix): void;
  78787. }
  78788. /**
  78789. * Represents the shape of the model used by one particle of a solid particle system.
  78790. * SPS internal tool, don't use it manually.
  78791. */
  78792. export class ModelShape {
  78793. /**
  78794. * The shape id
  78795. * @hidden
  78796. */
  78797. shapeID: number;
  78798. /**
  78799. * flat array of model positions (internal use)
  78800. * @hidden
  78801. */
  78802. _shape: Vector3[];
  78803. /**
  78804. * flat array of model UVs (internal use)
  78805. * @hidden
  78806. */
  78807. _shapeUV: number[];
  78808. /**
  78809. * length of the shape in the model indices array (internal use)
  78810. * @hidden
  78811. */
  78812. _indicesLength: number;
  78813. /**
  78814. * Custom position function (internal use)
  78815. * @hidden
  78816. */
  78817. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  78818. /**
  78819. * Custom vertex function (internal use)
  78820. * @hidden
  78821. */
  78822. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  78823. /**
  78824. * 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.
  78825. * SPS internal tool, don't use it manually.
  78826. * @hidden
  78827. */
  78828. 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>);
  78829. }
  78830. /**
  78831. * Represents a Depth Sorted Particle in the solid particle system.
  78832. */
  78833. export class DepthSortedParticle {
  78834. /**
  78835. * Index of the particle in the "indices" array
  78836. */
  78837. ind: number;
  78838. /**
  78839. * Length of the particle shape in the "indices" array
  78840. */
  78841. indicesLength: number;
  78842. /**
  78843. * Squared distance from the particle to the camera
  78844. */
  78845. sqDistance: number;
  78846. }
  78847. }
  78848. declare module BABYLON {
  78849. /**
  78850. * Class used to store all common mesh properties
  78851. */
  78852. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  78853. /** No occlusion */
  78854. static OCCLUSION_TYPE_NONE: number;
  78855. /** Occlusion set to optimisitic */
  78856. static OCCLUSION_TYPE_OPTIMISTIC: number;
  78857. /** Occlusion set to strict */
  78858. static OCCLUSION_TYPE_STRICT: number;
  78859. /** Use an accurante occlusion algorithm */
  78860. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  78861. /** Use a conservative occlusion algorithm */
  78862. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  78863. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  78864. * Test order :
  78865. * Is the bounding sphere outside the frustum ?
  78866. * If not, are the bounding box vertices outside the frustum ?
  78867. * It not, then the cullable object is in the frustum.
  78868. */
  78869. static readonly CULLINGSTRATEGY_STANDARD: number;
  78870. /** Culling strategy : Bounding Sphere Only.
  78871. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  78872. * It's also less accurate than the standard because some not visible objects can still be selected.
  78873. * Test : is the bounding sphere outside the frustum ?
  78874. * If not, then the cullable object is in the frustum.
  78875. */
  78876. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  78877. /** Culling strategy : Optimistic Inclusion.
  78878. * This in an inclusion test first, then the standard exclusion test.
  78879. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  78880. * 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.
  78881. * Anyway, it's as accurate as the standard strategy.
  78882. * Test :
  78883. * Is the cullable object bounding sphere center in the frustum ?
  78884. * If not, apply the default culling strategy.
  78885. */
  78886. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  78887. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  78888. * This in an inclusion test first, then the bounding sphere only exclusion test.
  78889. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  78890. * 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.
  78891. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  78892. * Test :
  78893. * Is the cullable object bounding sphere center in the frustum ?
  78894. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  78895. */
  78896. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  78897. /**
  78898. * No billboard
  78899. */
  78900. static readonly BILLBOARDMODE_NONE: number;
  78901. /** Billboard on X axis */
  78902. static readonly BILLBOARDMODE_X: number;
  78903. /** Billboard on Y axis */
  78904. static readonly BILLBOARDMODE_Y: number;
  78905. /** Billboard on Z axis */
  78906. static readonly BILLBOARDMODE_Z: number;
  78907. /** Billboard on all axes */
  78908. static readonly BILLBOARDMODE_ALL: number;
  78909. private _facetData;
  78910. /**
  78911. * The culling strategy to use to check whether the mesh must be rendered or not.
  78912. * This value can be changed at any time and will be used on the next render mesh selection.
  78913. * The possible values are :
  78914. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78915. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78916. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78917. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78918. * Please read each static variable documentation to get details about the culling process.
  78919. * */
  78920. cullingStrategy: number;
  78921. /**
  78922. * Gets the number of facets in the mesh
  78923. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78924. */
  78925. readonly facetNb: number;
  78926. /**
  78927. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  78928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78929. */
  78930. partitioningSubdivisions: number;
  78931. /**
  78932. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  78933. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  78934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  78935. */
  78936. partitioningBBoxRatio: number;
  78937. /**
  78938. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  78939. * Works only for updatable meshes.
  78940. * Doesn't work with multi-materials
  78941. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78942. */
  78943. mustDepthSortFacets: boolean;
  78944. /**
  78945. * The location (Vector3) where the facet depth sort must be computed from.
  78946. * By default, the active camera position.
  78947. * Used only when facet depth sort is enabled
  78948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  78949. */
  78950. facetDepthSortFrom: Vector3;
  78951. /**
  78952. * gets a boolean indicating if facetData is enabled
  78953. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  78954. */
  78955. readonly isFacetDataEnabled: boolean;
  78956. /** @hidden */
  78957. _updateNonUniformScalingState(value: boolean): boolean;
  78958. /**
  78959. * An event triggered when this mesh collides with another one
  78960. */
  78961. onCollideObservable: Observable<AbstractMesh>;
  78962. private _onCollideObserver;
  78963. /** Set a function to call when this mesh collides with another one */
  78964. onCollide: () => void;
  78965. /**
  78966. * An event triggered when the collision's position changes
  78967. */
  78968. onCollisionPositionChangeObservable: Observable<Vector3>;
  78969. private _onCollisionPositionChangeObserver;
  78970. /** Set a function to call when the collision's position changes */
  78971. onCollisionPositionChange: () => void;
  78972. /**
  78973. * An event triggered when material is changed
  78974. */
  78975. onMaterialChangedObservable: Observable<AbstractMesh>;
  78976. /**
  78977. * Gets or sets the orientation for POV movement & rotation
  78978. */
  78979. definedFacingForward: boolean;
  78980. /** @hidden */
  78981. _occlusionQuery: Nullable<WebGLQuery>;
  78982. private _visibility;
  78983. /**
  78984. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78985. */
  78986. /**
  78987. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  78988. */
  78989. visibility: number;
  78990. /** Gets or sets the alpha index used to sort transparent meshes
  78991. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  78992. */
  78993. alphaIndex: number;
  78994. /**
  78995. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  78996. */
  78997. isVisible: boolean;
  78998. /**
  78999. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  79000. */
  79001. isPickable: boolean;
  79002. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  79003. showSubMeshesBoundingBox: boolean;
  79004. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  79005. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  79006. */
  79007. isBlocker: boolean;
  79008. /**
  79009. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  79010. */
  79011. enablePointerMoveEvents: boolean;
  79012. /**
  79013. * Specifies the rendering group id for this mesh (0 by default)
  79014. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  79015. */
  79016. renderingGroupId: number;
  79017. private _material;
  79018. /** Gets or sets current material */
  79019. material: Nullable<Material>;
  79020. private _receiveShadows;
  79021. /**
  79022. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  79023. * @see http://doc.babylonjs.com/babylon101/shadows
  79024. */
  79025. receiveShadows: boolean;
  79026. /** Defines color to use when rendering outline */
  79027. outlineColor: Color3;
  79028. /** Define width to use when rendering outline */
  79029. outlineWidth: number;
  79030. /** Defines color to use when rendering overlay */
  79031. overlayColor: Color3;
  79032. /** Defines alpha to use when rendering overlay */
  79033. overlayAlpha: number;
  79034. private _hasVertexAlpha;
  79035. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  79036. hasVertexAlpha: boolean;
  79037. private _useVertexColors;
  79038. /** 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) */
  79039. useVertexColors: boolean;
  79040. private _computeBonesUsingShaders;
  79041. /**
  79042. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  79043. */
  79044. computeBonesUsingShaders: boolean;
  79045. private _numBoneInfluencers;
  79046. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  79047. numBoneInfluencers: number;
  79048. private _applyFog;
  79049. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  79050. applyFog: boolean;
  79051. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  79052. useOctreeForRenderingSelection: boolean;
  79053. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  79054. useOctreeForPicking: boolean;
  79055. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  79056. useOctreeForCollisions: boolean;
  79057. private _layerMask;
  79058. /**
  79059. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  79060. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  79061. */
  79062. layerMask: number;
  79063. /**
  79064. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  79065. */
  79066. alwaysSelectAsActiveMesh: boolean;
  79067. /**
  79068. * Gets or sets the current action manager
  79069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  79070. */
  79071. actionManager: Nullable<AbstractActionManager>;
  79072. private _checkCollisions;
  79073. private _collisionMask;
  79074. private _collisionGroup;
  79075. /**
  79076. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  79077. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79078. */
  79079. ellipsoid: Vector3;
  79080. /**
  79081. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  79082. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79083. */
  79084. ellipsoidOffset: Vector3;
  79085. private _collider;
  79086. private _oldPositionForCollisions;
  79087. private _diffPositionForCollisions;
  79088. /**
  79089. * Gets or sets a collision mask used to mask collisions (default is -1).
  79090. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79091. */
  79092. collisionMask: number;
  79093. /**
  79094. * Gets or sets the current collision group mask (-1 by default).
  79095. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79096. */
  79097. collisionGroup: number;
  79098. /**
  79099. * Defines edge width used when edgesRenderer is enabled
  79100. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79101. */
  79102. edgesWidth: number;
  79103. /**
  79104. * Defines edge color used when edgesRenderer is enabled
  79105. * @see https://www.babylonjs-playground.com/#10OJSG#13
  79106. */
  79107. edgesColor: Color4;
  79108. /** @hidden */
  79109. _edgesRenderer: Nullable<IEdgesRenderer>;
  79110. /** @hidden */
  79111. _masterMesh: Nullable<AbstractMesh>;
  79112. /** @hidden */
  79113. _boundingInfo: Nullable<BoundingInfo>;
  79114. /** @hidden */
  79115. _renderId: number;
  79116. /**
  79117. * Gets or sets the list of subMeshes
  79118. * @see http://doc.babylonjs.com/how_to/multi_materials
  79119. */
  79120. subMeshes: SubMesh[];
  79121. /** @hidden */
  79122. _intersectionsInProgress: AbstractMesh[];
  79123. /** @hidden */
  79124. _unIndexed: boolean;
  79125. /** @hidden */
  79126. _lightSources: Light[];
  79127. /** @hidden */
  79128. readonly _positions: Nullable<Vector3[]>;
  79129. /** @hidden */
  79130. _waitingActions: any;
  79131. /** @hidden */
  79132. _waitingFreezeWorldMatrix: Nullable<boolean>;
  79133. private _skeleton;
  79134. /** @hidden */
  79135. _bonesTransformMatrices: Nullable<Float32Array>;
  79136. /**
  79137. * Gets or sets a skeleton to apply skining transformations
  79138. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79139. */
  79140. skeleton: Nullable<Skeleton>;
  79141. /**
  79142. * An event triggered when the mesh is rebuilt.
  79143. */
  79144. onRebuildObservable: Observable<AbstractMesh>;
  79145. /**
  79146. * Creates a new AbstractMesh
  79147. * @param name defines the name of the mesh
  79148. * @param scene defines the hosting scene
  79149. */
  79150. constructor(name: string, scene?: Nullable<Scene>);
  79151. /**
  79152. * Returns the string "AbstractMesh"
  79153. * @returns "AbstractMesh"
  79154. */
  79155. getClassName(): string;
  79156. /**
  79157. * Gets a string representation of the current mesh
  79158. * @param fullDetails defines a boolean indicating if full details must be included
  79159. * @returns a string representation of the current mesh
  79160. */
  79161. toString(fullDetails?: boolean): string;
  79162. /** @hidden */
  79163. _rebuild(): void;
  79164. /** @hidden */
  79165. _resyncLightSources(): void;
  79166. /** @hidden */
  79167. _resyncLighSource(light: Light): void;
  79168. /** @hidden */
  79169. _unBindEffect(): void;
  79170. /** @hidden */
  79171. _removeLightSource(light: Light): void;
  79172. private _markSubMeshesAsDirty;
  79173. /** @hidden */
  79174. _markSubMeshesAsLightDirty(): void;
  79175. /** @hidden */
  79176. _markSubMeshesAsAttributesDirty(): void;
  79177. /** @hidden */
  79178. _markSubMeshesAsMiscDirty(): void;
  79179. /**
  79180. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79181. */
  79182. scaling: Vector3;
  79183. /**
  79184. * Returns true if the mesh is blocked. Implemented by child classes
  79185. */
  79186. readonly isBlocked: boolean;
  79187. /**
  79188. * Returns the mesh itself by default. Implemented by child classes
  79189. * @param camera defines the camera to use to pick the right LOD level
  79190. * @returns the currentAbstractMesh
  79191. */
  79192. getLOD(camera: Camera): Nullable<AbstractMesh>;
  79193. /**
  79194. * Returns 0 by default. Implemented by child classes
  79195. * @returns an integer
  79196. */
  79197. getTotalVertices(): number;
  79198. /**
  79199. * Returns a positive integer : the total number of indices in this mesh geometry.
  79200. * @returns the numner of indices or zero if the mesh has no geometry.
  79201. */
  79202. getTotalIndices(): number;
  79203. /**
  79204. * Returns null by default. Implemented by child classes
  79205. * @returns null
  79206. */
  79207. getIndices(): Nullable<IndicesArray>;
  79208. /**
  79209. * Returns the array of the requested vertex data kind. Implemented by child classes
  79210. * @param kind defines the vertex data kind to use
  79211. * @returns null
  79212. */
  79213. getVerticesData(kind: string): Nullable<FloatArray>;
  79214. /**
  79215. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79216. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79217. * Note that a new underlying VertexBuffer object is created each call.
  79218. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79219. * @param kind defines vertex data kind:
  79220. * * VertexBuffer.PositionKind
  79221. * * VertexBuffer.UVKind
  79222. * * VertexBuffer.UV2Kind
  79223. * * VertexBuffer.UV3Kind
  79224. * * VertexBuffer.UV4Kind
  79225. * * VertexBuffer.UV5Kind
  79226. * * VertexBuffer.UV6Kind
  79227. * * VertexBuffer.ColorKind
  79228. * * VertexBuffer.MatricesIndicesKind
  79229. * * VertexBuffer.MatricesIndicesExtraKind
  79230. * * VertexBuffer.MatricesWeightsKind
  79231. * * VertexBuffer.MatricesWeightsExtraKind
  79232. * @param data defines the data source
  79233. * @param updatable defines if the data must be flagged as updatable (or static)
  79234. * @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
  79235. * @returns the current mesh
  79236. */
  79237. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  79238. /**
  79239. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79240. * If the mesh has no geometry, it is simply returned as it is.
  79241. * @param kind defines vertex data kind:
  79242. * * VertexBuffer.PositionKind
  79243. * * VertexBuffer.UVKind
  79244. * * VertexBuffer.UV2Kind
  79245. * * VertexBuffer.UV3Kind
  79246. * * VertexBuffer.UV4Kind
  79247. * * VertexBuffer.UV5Kind
  79248. * * VertexBuffer.UV6Kind
  79249. * * VertexBuffer.ColorKind
  79250. * * VertexBuffer.MatricesIndicesKind
  79251. * * VertexBuffer.MatricesIndicesExtraKind
  79252. * * VertexBuffer.MatricesWeightsKind
  79253. * * VertexBuffer.MatricesWeightsExtraKind
  79254. * @param data defines the data source
  79255. * @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
  79256. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79257. * @returns the current mesh
  79258. */
  79259. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  79260. /**
  79261. * Sets the mesh indices,
  79262. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79263. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79264. * @param totalVertices Defines the total number of vertices
  79265. * @returns the current mesh
  79266. */
  79267. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  79268. /**
  79269. * Gets a boolean indicating if specific vertex data is present
  79270. * @param kind defines the vertex data kind to use
  79271. * @returns true is data kind is present
  79272. */
  79273. isVerticesDataPresent(kind: string): boolean;
  79274. /**
  79275. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79276. * @returns a BoundingInfo
  79277. */
  79278. getBoundingInfo(): BoundingInfo;
  79279. /**
  79280. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79281. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79282. * @returns the current mesh
  79283. */
  79284. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  79285. /**
  79286. * Overwrite the current bounding info
  79287. * @param boundingInfo defines the new bounding info
  79288. * @returns the current mesh
  79289. */
  79290. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  79291. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79292. readonly useBones: boolean;
  79293. /** @hidden */
  79294. _preActivate(): void;
  79295. /** @hidden */
  79296. _preActivateForIntermediateRendering(renderId: number): void;
  79297. /** @hidden */
  79298. _activate(renderId: number): void;
  79299. /**
  79300. * Gets the current world matrix
  79301. * @returns a Matrix
  79302. */
  79303. getWorldMatrix(): Matrix;
  79304. /** @hidden */
  79305. _getWorldMatrixDeterminant(): number;
  79306. /**
  79307. * Perform relative position change from the point of view of behind the front of the mesh.
  79308. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79309. * Supports definition of mesh facing forward or backward
  79310. * @param amountRight defines the distance on the right axis
  79311. * @param amountUp defines the distance on the up axis
  79312. * @param amountForward defines the distance on the forward axis
  79313. * @returns the current mesh
  79314. */
  79315. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  79316. /**
  79317. * Calculate relative position change from the point of view of behind the front of the mesh.
  79318. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79319. * Supports definition of mesh facing forward or backward
  79320. * @param amountRight defines the distance on the right axis
  79321. * @param amountUp defines the distance on the up axis
  79322. * @param amountForward defines the distance on the forward axis
  79323. * @returns the new displacement vector
  79324. */
  79325. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  79326. /**
  79327. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79328. * Supports definition of mesh facing forward or backward
  79329. * @param flipBack defines the flip
  79330. * @param twirlClockwise defines the twirl
  79331. * @param tiltRight defines the tilt
  79332. * @returns the current mesh
  79333. */
  79334. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  79335. /**
  79336. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79337. * Supports definition of mesh facing forward or backward.
  79338. * @param flipBack defines the flip
  79339. * @param twirlClockwise defines the twirl
  79340. * @param tiltRight defines the tilt
  79341. * @returns the new rotation vector
  79342. */
  79343. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  79344. /**
  79345. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79346. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79347. * @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
  79348. * @returns the new bounding vectors
  79349. */
  79350. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  79351. min: Vector3;
  79352. max: Vector3;
  79353. };
  79354. /**
  79355. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79356. * This means the mesh underlying bounding box and sphere are recomputed.
  79357. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79358. * @returns the current mesh
  79359. */
  79360. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  79361. /** @hidden */
  79362. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  79363. /** @hidden */
  79364. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  79365. /** @hidden */
  79366. _updateBoundingInfo(): AbstractMesh;
  79367. /** @hidden */
  79368. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  79369. /** @hidden */
  79370. protected _afterComputeWorldMatrix(): void;
  79371. /**
  79372. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79373. * A mesh is in the frustum if its bounding box intersects the frustum
  79374. * @param frustumPlanes defines the frustum to test
  79375. * @returns true if the mesh is in the frustum planes
  79376. */
  79377. isInFrustum(frustumPlanes: Plane[]): boolean;
  79378. /**
  79379. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79380. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79381. * @param frustumPlanes defines the frustum to test
  79382. * @returns true if the mesh is completely in the frustum planes
  79383. */
  79384. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  79385. /**
  79386. * True if the mesh intersects another mesh or a SolidParticle object
  79387. * @param mesh defines a target mesh or SolidParticle to test
  79388. * @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)
  79389. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79390. * @returns true if there is an intersection
  79391. */
  79392. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  79393. /**
  79394. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79395. * @param point defines the point to test
  79396. * @returns true if there is an intersection
  79397. */
  79398. intersectsPoint(point: Vector3): boolean;
  79399. /**
  79400. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79401. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79402. */
  79403. checkCollisions: boolean;
  79404. /**
  79405. * Gets Collider object used to compute collisions (not physics)
  79406. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79407. */
  79408. readonly collider: Collider;
  79409. /**
  79410. * Move the mesh using collision engine
  79411. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79412. * @param displacement defines the requested displacement vector
  79413. * @returns the current mesh
  79414. */
  79415. moveWithCollisions(displacement: Vector3): AbstractMesh;
  79416. private _onCollisionPositionChange;
  79417. /** @hidden */
  79418. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  79419. /** @hidden */
  79420. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  79421. /** @hidden */
  79422. _checkCollision(collider: Collider): AbstractMesh;
  79423. /** @hidden */
  79424. _generatePointsArray(): boolean;
  79425. /**
  79426. * Checks if the passed Ray intersects with the mesh
  79427. * @param ray defines the ray to use
  79428. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  79429. * @returns the picking info
  79430. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  79431. */
  79432. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  79433. /**
  79434. * Clones the current mesh
  79435. * @param name defines the mesh name
  79436. * @param newParent defines the new mesh parent
  79437. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  79438. * @returns the new mesh
  79439. */
  79440. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  79441. /**
  79442. * Disposes all the submeshes of the current meshnp
  79443. * @returns the current mesh
  79444. */
  79445. releaseSubMeshes(): AbstractMesh;
  79446. /**
  79447. * Releases resources associated with this abstract mesh.
  79448. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  79449. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  79450. */
  79451. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  79452. /**
  79453. * Adds the passed mesh as a child to the current mesh
  79454. * @param mesh defines the child mesh
  79455. * @returns the current mesh
  79456. */
  79457. addChild(mesh: AbstractMesh): AbstractMesh;
  79458. /**
  79459. * Removes the passed mesh from the current mesh children list
  79460. * @param mesh defines the child mesh
  79461. * @returns the current mesh
  79462. */
  79463. removeChild(mesh: AbstractMesh): AbstractMesh;
  79464. /** @hidden */
  79465. private _initFacetData;
  79466. /**
  79467. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  79468. * This method can be called within the render loop.
  79469. * 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
  79470. * @returns the current mesh
  79471. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79472. */
  79473. updateFacetData(): AbstractMesh;
  79474. /**
  79475. * Returns the facetLocalNormals array.
  79476. * The normals are expressed in the mesh local spac
  79477. * @returns an array of Vector3
  79478. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79479. */
  79480. getFacetLocalNormals(): Vector3[];
  79481. /**
  79482. * Returns the facetLocalPositions array.
  79483. * The facet positions are expressed in the mesh local space
  79484. * @returns an array of Vector3
  79485. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79486. */
  79487. getFacetLocalPositions(): Vector3[];
  79488. /**
  79489. * Returns the facetLocalPartioning array
  79490. * @returns an array of array of numbers
  79491. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79492. */
  79493. getFacetLocalPartitioning(): number[][];
  79494. /**
  79495. * Returns the i-th facet position in the world system.
  79496. * This method allocates a new Vector3 per call
  79497. * @param i defines the facet index
  79498. * @returns a new Vector3
  79499. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79500. */
  79501. getFacetPosition(i: number): Vector3;
  79502. /**
  79503. * Sets the reference Vector3 with the i-th facet position in the world system
  79504. * @param i defines the facet index
  79505. * @param ref defines the target vector
  79506. * @returns the current mesh
  79507. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79508. */
  79509. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  79510. /**
  79511. * Returns the i-th facet normal in the world system.
  79512. * This method allocates a new Vector3 per call
  79513. * @param i defines the facet index
  79514. * @returns a new Vector3
  79515. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79516. */
  79517. getFacetNormal(i: number): Vector3;
  79518. /**
  79519. * Sets the reference Vector3 with the i-th facet normal in the world system
  79520. * @param i defines the facet index
  79521. * @param ref defines the target vector
  79522. * @returns the current mesh
  79523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79524. */
  79525. getFacetNormalToRef(i: number, ref: Vector3): this;
  79526. /**
  79527. * 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)
  79528. * @param x defines x coordinate
  79529. * @param y defines y coordinate
  79530. * @param z defines z coordinate
  79531. * @returns the array of facet indexes
  79532. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79533. */
  79534. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  79535. /**
  79536. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  79537. * @param projected sets as the (x,y,z) world projection on the facet
  79538. * @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
  79539. * @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
  79540. * @param x defines x coordinate
  79541. * @param y defines y coordinate
  79542. * @param z defines z coordinate
  79543. * @returns the face index if found (or null instead)
  79544. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79545. */
  79546. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79547. /**
  79548. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  79549. * @param projected sets as the (x,y,z) local projection on the facet
  79550. * @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
  79551. * @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
  79552. * @param x defines x coordinate
  79553. * @param y defines y coordinate
  79554. * @param z defines z coordinate
  79555. * @returns the face index if found (or null instead)
  79556. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79557. */
  79558. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  79559. /**
  79560. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  79561. * @returns the parameters
  79562. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79563. */
  79564. getFacetDataParameters(): any;
  79565. /**
  79566. * Disables the feature FacetData and frees the related memory
  79567. * @returns the current mesh
  79568. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  79569. */
  79570. disableFacetData(): AbstractMesh;
  79571. /**
  79572. * Updates the AbstractMesh indices array
  79573. * @param indices defines the data source
  79574. * @returns the current mesh
  79575. */
  79576. updateIndices(indices: IndicesArray): AbstractMesh;
  79577. /**
  79578. * Creates new normals data for the mesh
  79579. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  79580. * @returns the current mesh
  79581. */
  79582. createNormals(updatable: boolean): AbstractMesh;
  79583. /**
  79584. * Align the mesh with a normal
  79585. * @param normal defines the normal to use
  79586. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  79587. * @returns the current mesh
  79588. */
  79589. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  79590. /** @hidden */
  79591. _checkOcclusionQuery(): boolean;
  79592. }
  79593. }
  79594. declare module BABYLON {
  79595. /**
  79596. * Class used to handle skinning animations
  79597. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79598. */
  79599. export class Skeleton implements IAnimatable {
  79600. /** defines the skeleton name */
  79601. name: string;
  79602. /** defines the skeleton Id */
  79603. id: string;
  79604. /**
  79605. * Defines the list of child bones
  79606. */
  79607. bones: Bone[];
  79608. /**
  79609. * Defines an estimate of the dimension of the skeleton at rest
  79610. */
  79611. dimensionsAtRest: Vector3;
  79612. /**
  79613. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79614. */
  79615. needInitialSkinMatrix: boolean;
  79616. /**
  79617. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79618. */
  79619. overrideMesh: Nullable<AbstractMesh>;
  79620. /**
  79621. * Gets the list of animations attached to this skeleton
  79622. */
  79623. animations: Array<Animation>;
  79624. private _scene;
  79625. private _isDirty;
  79626. private _transformMatrices;
  79627. private _transformMatrixTexture;
  79628. private _meshesWithPoseMatrix;
  79629. private _animatables;
  79630. private _identity;
  79631. private _synchronizedWithMesh;
  79632. private _ranges;
  79633. private _lastAbsoluteTransformsUpdateId;
  79634. private _canUseTextureForBones;
  79635. /** @hidden */
  79636. _numBonesWithLinkedTransformNode: number;
  79637. /**
  79638. * Specifies if the skeleton should be serialized
  79639. */
  79640. doNotSerialize: boolean;
  79641. /**
  79642. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79643. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  79644. */
  79645. useTextureToStoreBoneMatrices: boolean;
  79646. private _animationPropertiesOverride;
  79647. /**
  79648. * Gets or sets the animation properties override
  79649. */
  79650. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79651. /**
  79652. * An observable triggered before computing the skeleton's matrices
  79653. */
  79654. onBeforeComputeObservable: Observable<Skeleton>;
  79655. /**
  79656. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79657. */
  79658. readonly isUsingTextureForMatrices: boolean;
  79659. /**
  79660. * Creates a new skeleton
  79661. * @param name defines the skeleton name
  79662. * @param id defines the skeleton Id
  79663. * @param scene defines the hosting scene
  79664. */
  79665. constructor(
  79666. /** defines the skeleton name */
  79667. name: string,
  79668. /** defines the skeleton Id */
  79669. id: string, scene: Scene);
  79670. /**
  79671. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  79672. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  79673. * @returns a Float32Array containing matrices data
  79674. */
  79675. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  79676. /**
  79677. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  79678. * @returns a raw texture containing the data
  79679. */
  79680. getTransformMatrixTexture(): Nullable<RawTexture>;
  79681. /**
  79682. * Gets the current hosting scene
  79683. * @returns a scene object
  79684. */
  79685. getScene(): Scene;
  79686. /**
  79687. * Gets a string representing the current skeleton data
  79688. * @param fullDetails defines a boolean indicating if we want a verbose version
  79689. * @returns a string representing the current skeleton data
  79690. */
  79691. toString(fullDetails?: boolean): string;
  79692. /**
  79693. * Get bone's index searching by name
  79694. * @param name defines bone's name to search for
  79695. * @return the indice of the bone. Returns -1 if not found
  79696. */
  79697. getBoneIndexByName(name: string): number;
  79698. /**
  79699. * Creater a new animation range
  79700. * @param name defines the name of the range
  79701. * @param from defines the start key
  79702. * @param to defines the end key
  79703. */
  79704. createAnimationRange(name: string, from: number, to: number): void;
  79705. /**
  79706. * Delete a specific animation range
  79707. * @param name defines the name of the range
  79708. * @param deleteFrames defines if frames must be removed as well
  79709. */
  79710. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  79711. /**
  79712. * Gets a specific animation range
  79713. * @param name defines the name of the range to look for
  79714. * @returns the requested animation range or null if not found
  79715. */
  79716. getAnimationRange(name: string): Nullable<AnimationRange>;
  79717. /**
  79718. * Gets the list of all animation ranges defined on this skeleton
  79719. * @returns an array
  79720. */
  79721. getAnimationRanges(): Nullable<AnimationRange>[];
  79722. /**
  79723. * Copy animation range from a source skeleton.
  79724. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  79725. * @param source defines the source skeleton
  79726. * @param name defines the name of the range to copy
  79727. * @param rescaleAsRequired defines if rescaling must be applied if required
  79728. * @returns true if operation was successful
  79729. */
  79730. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  79731. /**
  79732. * Forces the skeleton to go to rest pose
  79733. */
  79734. returnToRest(): void;
  79735. private _getHighestAnimationFrame;
  79736. /**
  79737. * Begin a specific animation range
  79738. * @param name defines the name of the range to start
  79739. * @param loop defines if looping must be turned on (false by default)
  79740. * @param speedRatio defines the speed ratio to apply (1 by default)
  79741. * @param onAnimationEnd defines a callback which will be called when animation will end
  79742. * @returns a new animatable
  79743. */
  79744. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  79745. /** @hidden */
  79746. _markAsDirty(): void;
  79747. /** @hidden */
  79748. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79749. /** @hidden */
  79750. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  79751. private _computeTransformMatrices;
  79752. /**
  79753. * Build all resources required to render a skeleton
  79754. */
  79755. prepare(): void;
  79756. /**
  79757. * Gets the list of animatables currently running for this skeleton
  79758. * @returns an array of animatables
  79759. */
  79760. getAnimatables(): IAnimatable[];
  79761. /**
  79762. * Clone the current skeleton
  79763. * @param name defines the name of the new skeleton
  79764. * @param id defines the id of the enw skeleton
  79765. * @returns the new skeleton
  79766. */
  79767. clone(name: string, id: string): Skeleton;
  79768. /**
  79769. * Enable animation blending for this skeleton
  79770. * @param blendingSpeed defines the blending speed to apply
  79771. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79772. */
  79773. enableBlending(blendingSpeed?: number): void;
  79774. /**
  79775. * Releases all resources associated with the current skeleton
  79776. */
  79777. dispose(): void;
  79778. /**
  79779. * Serialize the skeleton in a JSON object
  79780. * @returns a JSON object
  79781. */
  79782. serialize(): any;
  79783. /**
  79784. * Creates a new skeleton from serialized data
  79785. * @param parsedSkeleton defines the serialized data
  79786. * @param scene defines the hosting scene
  79787. * @returns a new skeleton
  79788. */
  79789. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  79790. /**
  79791. * Compute all node absolute transforms
  79792. * @param forceUpdate defines if computation must be done even if cache is up to date
  79793. */
  79794. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  79795. /**
  79796. * Gets the root pose matrix
  79797. * @returns a matrix
  79798. */
  79799. getPoseMatrix(): Nullable<Matrix>;
  79800. /**
  79801. * Sorts bones per internal index
  79802. */
  79803. sortBones(): void;
  79804. private _sortBones;
  79805. }
  79806. }
  79807. declare module BABYLON {
  79808. /**
  79809. * Class used to store bone information
  79810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79811. */
  79812. export class Bone extends Node {
  79813. /**
  79814. * defines the bone name
  79815. */
  79816. name: string;
  79817. private static _tmpVecs;
  79818. private static _tmpQuat;
  79819. private static _tmpMats;
  79820. /**
  79821. * Gets the list of child bones
  79822. */
  79823. children: Bone[];
  79824. /** Gets the animations associated with this bone */
  79825. animations: Animation[];
  79826. /**
  79827. * Gets or sets bone length
  79828. */
  79829. length: number;
  79830. /**
  79831. * @hidden Internal only
  79832. * Set this value to map this bone to a different index in the transform matrices
  79833. * Set this value to -1 to exclude the bone from the transform matrices
  79834. */
  79835. _index: Nullable<number>;
  79836. private _skeleton;
  79837. private _localMatrix;
  79838. private _restPose;
  79839. private _baseMatrix;
  79840. private _absoluteTransform;
  79841. private _invertedAbsoluteTransform;
  79842. private _parent;
  79843. private _scalingDeterminant;
  79844. private _worldTransform;
  79845. private _localScaling;
  79846. private _localRotation;
  79847. private _localPosition;
  79848. private _needToDecompose;
  79849. private _needToCompose;
  79850. /** @hidden */
  79851. _linkedTransformNode: Nullable<TransformNode>;
  79852. /** @hidden */
  79853. /** @hidden */
  79854. _matrix: Matrix;
  79855. /**
  79856. * Create a new bone
  79857. * @param name defines the bone name
  79858. * @param skeleton defines the parent skeleton
  79859. * @param parentBone defines the parent (can be null if the bone is the root)
  79860. * @param localMatrix defines the local matrix
  79861. * @param restPose defines the rest pose matrix
  79862. * @param baseMatrix defines the base matrix
  79863. * @param index defines index of the bone in the hiearchy
  79864. */
  79865. constructor(
  79866. /**
  79867. * defines the bone name
  79868. */
  79869. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  79870. /**
  79871. * Gets the parent skeleton
  79872. * @returns a skeleton
  79873. */
  79874. getSkeleton(): Skeleton;
  79875. /**
  79876. * Gets parent bone
  79877. * @returns a bone or null if the bone is the root of the bone hierarchy
  79878. */
  79879. getParent(): Nullable<Bone>;
  79880. /**
  79881. * Sets the parent bone
  79882. * @param parent defines the parent (can be null if the bone is the root)
  79883. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79884. */
  79885. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  79886. /**
  79887. * Gets the local matrix
  79888. * @returns a matrix
  79889. */
  79890. getLocalMatrix(): Matrix;
  79891. /**
  79892. * Gets the base matrix (initial matrix which remains unchanged)
  79893. * @returns a matrix
  79894. */
  79895. getBaseMatrix(): Matrix;
  79896. /**
  79897. * Gets the rest pose matrix
  79898. * @returns a matrix
  79899. */
  79900. getRestPose(): Matrix;
  79901. /**
  79902. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  79903. */
  79904. getWorldMatrix(): Matrix;
  79905. /**
  79906. * Sets the local matrix to rest pose matrix
  79907. */
  79908. returnToRest(): void;
  79909. /**
  79910. * Gets the inverse of the absolute transform matrix.
  79911. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  79912. * @returns a matrix
  79913. */
  79914. getInvertedAbsoluteTransform(): Matrix;
  79915. /**
  79916. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  79917. * @returns a matrix
  79918. */
  79919. getAbsoluteTransform(): Matrix;
  79920. /**
  79921. * Links with the given transform node.
  79922. * The local matrix of this bone is copied from the transform node every frame.
  79923. * @param transformNode defines the transform node to link to
  79924. */
  79925. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  79926. /** Gets or sets current position (in local space) */
  79927. position: Vector3;
  79928. /** Gets or sets current rotation (in local space) */
  79929. rotation: Vector3;
  79930. /** Gets or sets current rotation quaternion (in local space) */
  79931. rotationQuaternion: Quaternion;
  79932. /** Gets or sets current scaling (in local space) */
  79933. scaling: Vector3;
  79934. /**
  79935. * Gets the animation properties override
  79936. */
  79937. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79938. private _decompose;
  79939. private _compose;
  79940. /**
  79941. * Update the base and local matrices
  79942. * @param matrix defines the new base or local matrix
  79943. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  79944. * @param updateLocalMatrix defines if the local matrix should be updated
  79945. */
  79946. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  79947. /** @hidden */
  79948. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  79949. /**
  79950. * Flag the bone as dirty (Forcing it to update everything)
  79951. */
  79952. markAsDirty(): void;
  79953. private _markAsDirtyAndCompose;
  79954. private _markAsDirtyAndDecompose;
  79955. /**
  79956. * Translate the bone in local or world space
  79957. * @param vec The amount to translate the bone
  79958. * @param space The space that the translation is in
  79959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79960. */
  79961. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79962. /**
  79963. * Set the postion of the bone in local or world space
  79964. * @param position The position to set the bone
  79965. * @param space The space that the position is in
  79966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  79967. */
  79968. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  79969. /**
  79970. * Set the absolute position of the bone (world space)
  79971. * @param position The position to set the bone
  79972. * @param mesh The mesh that this bone is attached to
  79973. */
  79974. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  79975. /**
  79976. * Scale the bone on the x, y and z axes (in local space)
  79977. * @param x The amount to scale the bone on the x axis
  79978. * @param y The amount to scale the bone on the y axis
  79979. * @param z The amount to scale the bone on the z axis
  79980. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  79981. */
  79982. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  79983. /**
  79984. * Set the bone scaling in local space
  79985. * @param scale defines the scaling vector
  79986. */
  79987. setScale(scale: Vector3): void;
  79988. /**
  79989. * Gets the current scaling in local space
  79990. * @returns the current scaling vector
  79991. */
  79992. getScale(): Vector3;
  79993. /**
  79994. * Gets the current scaling in local space and stores it in a target vector
  79995. * @param result defines the target vector
  79996. */
  79997. getScaleToRef(result: Vector3): void;
  79998. /**
  79999. * Set the yaw, pitch, and roll of the bone in local or world space
  80000. * @param yaw The rotation of the bone on the y axis
  80001. * @param pitch The rotation of the bone on the x axis
  80002. * @param roll The rotation of the bone on the z axis
  80003. * @param space The space that the axes of rotation are in
  80004. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80005. */
  80006. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80007. /**
  80008. * Add a rotation to the bone on an axis in local or world space
  80009. * @param axis The axis to rotate the bone on
  80010. * @param amount The amount to rotate the bone
  80011. * @param space The space that the axis is in
  80012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80013. */
  80014. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80015. /**
  80016. * Set the rotation of the bone to a particular axis angle in local or world space
  80017. * @param axis The axis to rotate the bone on
  80018. * @param angle The angle that the bone should be rotated to
  80019. * @param space The space that the axis is in
  80020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80021. */
  80022. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80023. /**
  80024. * Set the euler rotation of the bone in local of world space
  80025. * @param rotation The euler rotation that the bone should be set to
  80026. * @param space The space that the rotation is in
  80027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80028. */
  80029. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80030. /**
  80031. * Set the quaternion rotation of the bone in local of world space
  80032. * @param quat The quaternion rotation that the bone should be set to
  80033. * @param space The space that the rotation is in
  80034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80035. */
  80036. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80037. /**
  80038. * Set the rotation matrix of the bone in local of world space
  80039. * @param rotMat The rotation matrix that the bone should be set to
  80040. * @param space The space that the rotation is in
  80041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80042. */
  80043. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80044. private _rotateWithMatrix;
  80045. private _getNegativeRotationToRef;
  80046. /**
  80047. * Get the position of the bone in local or world space
  80048. * @param space The space that the returned position is in
  80049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80050. * @returns The position of the bone
  80051. */
  80052. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80053. /**
  80054. * Copy the position of the bone to a vector3 in local or world space
  80055. * @param space The space that the returned position is in
  80056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80057. * @param result The vector3 to copy the position to
  80058. */
  80059. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80060. /**
  80061. * Get the absolute position of the bone (world space)
  80062. * @param mesh The mesh that this bone is attached to
  80063. * @returns The absolute position of the bone
  80064. */
  80065. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80066. /**
  80067. * Copy the absolute position of the bone (world space) to the result param
  80068. * @param mesh The mesh that this bone is attached to
  80069. * @param result The vector3 to copy the absolute position to
  80070. */
  80071. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80072. /**
  80073. * Compute the absolute transforms of this bone and its children
  80074. */
  80075. computeAbsoluteTransforms(): void;
  80076. /**
  80077. * Get the world direction from an axis that is in the local space of the bone
  80078. * @param localAxis The local direction that is used to compute the world direction
  80079. * @param mesh The mesh that this bone is attached to
  80080. * @returns The world direction
  80081. */
  80082. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80083. /**
  80084. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80085. * @param localAxis The local direction that is used to compute the world direction
  80086. * @param mesh The mesh that this bone is attached to
  80087. * @param result The vector3 that the world direction will be copied to
  80088. */
  80089. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80090. /**
  80091. * Get the euler rotation of the bone in local or world space
  80092. * @param space The space that the rotation should be in
  80093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80094. * @returns The euler rotation
  80095. */
  80096. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80097. /**
  80098. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80099. * @param space The space that the rotation should be in
  80100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80101. * @param result The vector3 that the rotation should be copied to
  80102. */
  80103. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80104. /**
  80105. * Get the quaternion rotation of the bone in either local or world space
  80106. * @param space The space that the rotation should be in
  80107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80108. * @returns The quaternion rotation
  80109. */
  80110. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80111. /**
  80112. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80113. * @param space The space that the rotation should be in
  80114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80115. * @param result The quaternion that the rotation should be copied to
  80116. */
  80117. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80118. /**
  80119. * Get the rotation matrix of the bone in local or world space
  80120. * @param space The space that the rotation should be in
  80121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80122. * @returns The rotation matrix
  80123. */
  80124. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80125. /**
  80126. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80127. * @param space The space that the rotation should be in
  80128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80129. * @param result The quaternion that the rotation should be copied to
  80130. */
  80131. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80132. /**
  80133. * Get the world position of a point that is in the local space of the bone
  80134. * @param position The local position
  80135. * @param mesh The mesh that this bone is attached to
  80136. * @returns The world position
  80137. */
  80138. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80139. /**
  80140. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80141. * @param position The local position
  80142. * @param mesh The mesh that this bone is attached to
  80143. * @param result The vector3 that the world position should be copied to
  80144. */
  80145. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80146. /**
  80147. * Get the local position of a point that is in world space
  80148. * @param position The world position
  80149. * @param mesh The mesh that this bone is attached to
  80150. * @returns The local position
  80151. */
  80152. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80153. /**
  80154. * Get the local position of a point that is in world space and copy it to the result param
  80155. * @param position The world position
  80156. * @param mesh The mesh that this bone is attached to
  80157. * @param result The vector3 that the local position should be copied to
  80158. */
  80159. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80160. }
  80161. }
  80162. declare module BABYLON {
  80163. /**
  80164. * Class used to store an actual running animation
  80165. */
  80166. export class Animatable {
  80167. /** defines the target object */
  80168. target: any;
  80169. /** defines the starting frame number (default is 0) */
  80170. fromFrame: number;
  80171. /** defines the ending frame number (default is 100) */
  80172. toFrame: number;
  80173. /** defines if the animation must loop (default is false) */
  80174. loopAnimation: boolean;
  80175. /** defines a callback to call when animation ends if it is not looping */
  80176. onAnimationEnd?: (() => void) | null | undefined;
  80177. /** defines a callback to call when animation loops */
  80178. onAnimationLoop?: (() => void) | null | undefined;
  80179. private _localDelayOffset;
  80180. private _pausedDelay;
  80181. private _runtimeAnimations;
  80182. private _paused;
  80183. private _scene;
  80184. private _speedRatio;
  80185. private _weight;
  80186. private _syncRoot;
  80187. /**
  80188. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80189. * This will only apply for non looping animation (default is true)
  80190. */
  80191. disposeOnEnd: boolean;
  80192. /**
  80193. * Gets a boolean indicating if the animation has started
  80194. */
  80195. animationStarted: boolean;
  80196. /**
  80197. * Observer raised when the animation ends
  80198. */
  80199. onAnimationEndObservable: Observable<Animatable>;
  80200. /**
  80201. * Observer raised when the animation loops
  80202. */
  80203. onAnimationLoopObservable: Observable<Animatable>;
  80204. /**
  80205. * Gets the root Animatable used to synchronize and normalize animations
  80206. */
  80207. readonly syncRoot: Animatable;
  80208. /**
  80209. * Gets the current frame of the first RuntimeAnimation
  80210. * Used to synchronize Animatables
  80211. */
  80212. readonly masterFrame: number;
  80213. /**
  80214. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80215. */
  80216. weight: number;
  80217. /**
  80218. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80219. */
  80220. speedRatio: number;
  80221. /**
  80222. * Creates a new Animatable
  80223. * @param scene defines the hosting scene
  80224. * @param target defines the target object
  80225. * @param fromFrame defines the starting frame number (default is 0)
  80226. * @param toFrame defines the ending frame number (default is 100)
  80227. * @param loopAnimation defines if the animation must loop (default is false)
  80228. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80229. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80230. * @param animations defines a group of animation to add to the new Animatable
  80231. * @param onAnimationLoop defines a callback to call when animation loops
  80232. */
  80233. constructor(scene: Scene,
  80234. /** defines the target object */
  80235. target: any,
  80236. /** defines the starting frame number (default is 0) */
  80237. fromFrame?: number,
  80238. /** defines the ending frame number (default is 100) */
  80239. toFrame?: number,
  80240. /** defines if the animation must loop (default is false) */
  80241. loopAnimation?: boolean, speedRatio?: number,
  80242. /** defines a callback to call when animation ends if it is not looping */
  80243. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80244. /** defines a callback to call when animation loops */
  80245. onAnimationLoop?: (() => void) | null | undefined);
  80246. /**
  80247. * Synchronize and normalize current Animatable with a source Animatable
  80248. * This is useful when using animation weights and when animations are not of the same length
  80249. * @param root defines the root Animatable to synchronize with
  80250. * @returns the current Animatable
  80251. */
  80252. syncWith(root: Animatable): Animatable;
  80253. /**
  80254. * Gets the list of runtime animations
  80255. * @returns an array of RuntimeAnimation
  80256. */
  80257. getAnimations(): RuntimeAnimation[];
  80258. /**
  80259. * Adds more animations to the current animatable
  80260. * @param target defines the target of the animations
  80261. * @param animations defines the new animations to add
  80262. */
  80263. appendAnimations(target: any, animations: Animation[]): void;
  80264. /**
  80265. * Gets the source animation for a specific property
  80266. * @param property defines the propertyu to look for
  80267. * @returns null or the source animation for the given property
  80268. */
  80269. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80270. /**
  80271. * Gets the runtime animation for a specific property
  80272. * @param property defines the propertyu to look for
  80273. * @returns null or the runtime animation for the given property
  80274. */
  80275. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80276. /**
  80277. * Resets the animatable to its original state
  80278. */
  80279. reset(): void;
  80280. /**
  80281. * Allows the animatable to blend with current running animations
  80282. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80283. * @param blendingSpeed defines the blending speed to use
  80284. */
  80285. enableBlending(blendingSpeed: number): void;
  80286. /**
  80287. * Disable animation blending
  80288. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80289. */
  80290. disableBlending(): void;
  80291. /**
  80292. * Jump directly to a given frame
  80293. * @param frame defines the frame to jump to
  80294. */
  80295. goToFrame(frame: number): void;
  80296. /**
  80297. * Pause the animation
  80298. */
  80299. pause(): void;
  80300. /**
  80301. * Restart the animation
  80302. */
  80303. restart(): void;
  80304. private _raiseOnAnimationEnd;
  80305. /**
  80306. * Stop and delete the current animation
  80307. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80308. * @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)
  80309. */
  80310. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80311. /**
  80312. * Wait asynchronously for the animation to end
  80313. * @returns a promise which will be fullfilled when the animation ends
  80314. */
  80315. waitAsync(): Promise<Animatable>;
  80316. /** @hidden */
  80317. _animate(delay: number): boolean;
  80318. }
  80319. interface Scene {
  80320. /** @hidden */
  80321. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  80322. /** @hidden */
  80323. _processLateAnimationBindingsForMatrices(holder: {
  80324. totalWeight: number;
  80325. animations: RuntimeAnimation[];
  80326. originalValue: Matrix;
  80327. }): any;
  80328. /** @hidden */
  80329. _processLateAnimationBindingsForQuaternions(holder: {
  80330. totalWeight: number;
  80331. animations: RuntimeAnimation[];
  80332. originalValue: Quaternion;
  80333. }, refQuaternion: Quaternion): Quaternion;
  80334. /** @hidden */
  80335. _processLateAnimationBindings(): void;
  80336. /** @hidden */
  80337. _animate(): void;
  80338. /**
  80339. * Will start the animation sequence of a given target
  80340. * @param target defines the target
  80341. * @param from defines from which frame should animation start
  80342. * @param to defines until which frame should animation run.
  80343. * @param weight defines the weight to apply to the animation (1.0 by default)
  80344. * @param loop defines if the animation loops
  80345. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80346. * @param onAnimationEnd defines the function to be executed when the animation ends
  80347. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80348. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80349. * @param onAnimationLoop defines the callback to call when an animation loops
  80350. * @returns the animatable object created for this animation
  80351. */
  80352. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80353. /**
  80354. * Will start the animation sequence of a given target
  80355. * @param target defines the target
  80356. * @param from defines from which frame should animation start
  80357. * @param to defines until which frame should animation run.
  80358. * @param loop defines if the animation loops
  80359. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80360. * @param onAnimationEnd defines the function to be executed when the animation ends
  80361. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80362. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80363. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  80364. * @param onAnimationLoop defines the callback to call when an animation loops
  80365. * @returns the animatable object created for this animation
  80366. */
  80367. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  80368. /**
  80369. * Will start the animation sequence of a given target and its hierarchy
  80370. * @param target defines the target
  80371. * @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.
  80372. * @param from defines from which frame should animation start
  80373. * @param to defines until which frame should animation run.
  80374. * @param loop defines if the animation loops
  80375. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  80376. * @param onAnimationEnd defines the function to be executed when the animation ends
  80377. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  80378. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  80379. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  80380. * @param onAnimationLoop defines the callback to call when an animation loops
  80381. * @returns the list of created animatables
  80382. */
  80383. 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[];
  80384. /**
  80385. * Begin a new animation on a given node
  80386. * @param target defines the target where the animation will take place
  80387. * @param animations defines the list of animations to start
  80388. * @param from defines the initial value
  80389. * @param to defines the final value
  80390. * @param loop defines if you want animation to loop (off by default)
  80391. * @param speedRatio defines the speed ratio to apply to all animations
  80392. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80393. * @param onAnimationLoop defines the callback to call when an animation loops
  80394. * @returns the list of created animatables
  80395. */
  80396. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  80397. /**
  80398. * Begin a new animation on a given node and its hierarchy
  80399. * @param target defines the root node where the animation will take place
  80400. * @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.
  80401. * @param animations defines the list of animations to start
  80402. * @param from defines the initial value
  80403. * @param to defines the final value
  80404. * @param loop defines if you want animation to loop (off by default)
  80405. * @param speedRatio defines the speed ratio to apply to all animations
  80406. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80407. * @param onAnimationLoop defines the callback to call when an animation loops
  80408. * @returns the list of animatables created for all nodes
  80409. */
  80410. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  80411. /**
  80412. * Gets the animatable associated with a specific target
  80413. * @param target defines the target of the animatable
  80414. * @returns the required animatable if found
  80415. */
  80416. getAnimatableByTarget(target: any): Nullable<Animatable>;
  80417. /**
  80418. * Gets all animatables associated with a given target
  80419. * @param target defines the target to look animatables for
  80420. * @returns an array of Animatables
  80421. */
  80422. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  80423. /**
  80424. * Will stop the animation of the given target
  80425. * @param target - the target
  80426. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  80427. * @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)
  80428. */
  80429. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  80430. /**
  80431. * Stops and removes all animations that have been applied to the scene
  80432. */
  80433. stopAllAnimations(): void;
  80434. }
  80435. interface Bone {
  80436. /**
  80437. * Copy an animation range from another bone
  80438. * @param source defines the source bone
  80439. * @param rangeName defines the range name to copy
  80440. * @param frameOffset defines the frame offset
  80441. * @param rescaleAsRequired defines if rescaling must be applied if required
  80442. * @param skelDimensionsRatio defines the scaling ratio
  80443. * @returns true if operation was successful
  80444. */
  80445. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80446. }
  80447. }
  80448. declare module BABYLON {
  80449. /**
  80450. * Defines how a node can be built from a string name.
  80451. */
  80452. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  80453. /**
  80454. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  80455. */
  80456. export class Node implements IBehaviorAware<Node> {
  80457. /** @hidden */
  80458. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  80459. private static _NodeConstructors;
  80460. /**
  80461. * Add a new node constructor
  80462. * @param type defines the type name of the node to construct
  80463. * @param constructorFunc defines the constructor function
  80464. */
  80465. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  80466. /**
  80467. * Returns a node constructor based on type name
  80468. * @param type defines the type name
  80469. * @param name defines the new node name
  80470. * @param scene defines the hosting scene
  80471. * @param options defines optional options to transmit to constructors
  80472. * @returns the new constructor or null
  80473. */
  80474. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  80475. /**
  80476. * Gets or sets the name of the node
  80477. */
  80478. name: string;
  80479. /**
  80480. * Gets or sets the id of the node
  80481. */
  80482. id: string;
  80483. /**
  80484. * Gets or sets the unique id of the node
  80485. */
  80486. uniqueId: number;
  80487. /**
  80488. * Gets or sets a string used to store user defined state for the node
  80489. */
  80490. state: string;
  80491. /**
  80492. * Gets or sets an object used to store user defined information for the node
  80493. */
  80494. metadata: any;
  80495. /**
  80496. * For internal use only. Please do not use.
  80497. */
  80498. reservedDataStore: any;
  80499. /**
  80500. * Gets or sets a boolean used to define if the node must be serialized
  80501. */
  80502. doNotSerialize: boolean;
  80503. /** @hidden */
  80504. _isDisposed: boolean;
  80505. /**
  80506. * Gets a list of Animations associated with the node
  80507. */
  80508. animations: Animation[];
  80509. protected _ranges: {
  80510. [name: string]: Nullable<AnimationRange>;
  80511. };
  80512. /**
  80513. * Callback raised when the node is ready to be used
  80514. */
  80515. onReady: (node: Node) => void;
  80516. private _isEnabled;
  80517. private _isParentEnabled;
  80518. private _isReady;
  80519. /** @hidden */
  80520. _currentRenderId: number;
  80521. private _parentRenderId;
  80522. protected _childRenderId: number;
  80523. /** @hidden */
  80524. _waitingParentId: Nullable<string>;
  80525. /** @hidden */
  80526. _scene: Scene;
  80527. /** @hidden */
  80528. _cache: any;
  80529. private _parentNode;
  80530. private _children;
  80531. /** @hidden */
  80532. _worldMatrix: Matrix;
  80533. /** @hidden */
  80534. _worldMatrixDeterminant: number;
  80535. /** @hidden */
  80536. private _sceneRootNodesIndex;
  80537. /**
  80538. * Gets a boolean indicating if the node has been disposed
  80539. * @returns true if the node was disposed
  80540. */
  80541. isDisposed(): boolean;
  80542. /**
  80543. * Gets or sets the parent of the node
  80544. */
  80545. parent: Nullable<Node>;
  80546. private addToSceneRootNodes;
  80547. private removeFromSceneRootNodes;
  80548. private _animationPropertiesOverride;
  80549. /**
  80550. * Gets or sets the animation properties override
  80551. */
  80552. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80553. /**
  80554. * Gets a string idenfifying the name of the class
  80555. * @returns "Node" string
  80556. */
  80557. getClassName(): string;
  80558. /** @hidden */
  80559. readonly _isNode: boolean;
  80560. /**
  80561. * An event triggered when the mesh is disposed
  80562. */
  80563. onDisposeObservable: Observable<Node>;
  80564. private _onDisposeObserver;
  80565. /**
  80566. * Sets a callback that will be raised when the node will be disposed
  80567. */
  80568. onDispose: () => void;
  80569. /**
  80570. * Creates a new Node
  80571. * @param name the name and id to be given to this node
  80572. * @param scene the scene this node will be added to
  80573. * @param addToRootNodes the node will be added to scene.rootNodes
  80574. */
  80575. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  80576. /**
  80577. * Gets the scene of the node
  80578. * @returns a scene
  80579. */
  80580. getScene(): Scene;
  80581. /**
  80582. * Gets the engine of the node
  80583. * @returns a Engine
  80584. */
  80585. getEngine(): Engine;
  80586. private _behaviors;
  80587. /**
  80588. * Attach a behavior to the node
  80589. * @see http://doc.babylonjs.com/features/behaviour
  80590. * @param behavior defines the behavior to attach
  80591. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  80592. * @returns the current Node
  80593. */
  80594. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  80595. /**
  80596. * Remove an attached behavior
  80597. * @see http://doc.babylonjs.com/features/behaviour
  80598. * @param behavior defines the behavior to attach
  80599. * @returns the current Node
  80600. */
  80601. removeBehavior(behavior: Behavior<Node>): Node;
  80602. /**
  80603. * Gets the list of attached behaviors
  80604. * @see http://doc.babylonjs.com/features/behaviour
  80605. */
  80606. readonly behaviors: Behavior<Node>[];
  80607. /**
  80608. * Gets an attached behavior by name
  80609. * @param name defines the name of the behavior to look for
  80610. * @see http://doc.babylonjs.com/features/behaviour
  80611. * @returns null if behavior was not found else the requested behavior
  80612. */
  80613. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  80614. /**
  80615. * Returns the latest update of the World matrix
  80616. * @returns a Matrix
  80617. */
  80618. getWorldMatrix(): Matrix;
  80619. /** @hidden */
  80620. _getWorldMatrixDeterminant(): number;
  80621. /**
  80622. * Returns directly the latest state of the mesh World matrix.
  80623. * A Matrix is returned.
  80624. */
  80625. readonly worldMatrixFromCache: Matrix;
  80626. /** @hidden */
  80627. _initCache(): void;
  80628. /** @hidden */
  80629. updateCache(force?: boolean): void;
  80630. /** @hidden */
  80631. _updateCache(ignoreParentClass?: boolean): void;
  80632. /** @hidden */
  80633. _isSynchronized(): boolean;
  80634. /** @hidden */
  80635. _markSyncedWithParent(): void;
  80636. /** @hidden */
  80637. isSynchronizedWithParent(): boolean;
  80638. /** @hidden */
  80639. isSynchronized(): boolean;
  80640. /**
  80641. * Is this node ready to be used/rendered
  80642. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80643. * @return true if the node is ready
  80644. */
  80645. isReady(completeCheck?: boolean): boolean;
  80646. /**
  80647. * Is this node enabled?
  80648. * 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
  80649. * @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
  80650. * @return whether this node (and its parent) is enabled
  80651. */
  80652. isEnabled(checkAncestors?: boolean): boolean;
  80653. /** @hidden */
  80654. protected _syncParentEnabledState(): void;
  80655. /**
  80656. * Set the enabled state of this node
  80657. * @param value defines the new enabled state
  80658. */
  80659. setEnabled(value: boolean): void;
  80660. /**
  80661. * Is this node a descendant of the given node?
  80662. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  80663. * @param ancestor defines the parent node to inspect
  80664. * @returns a boolean indicating if this node is a descendant of the given node
  80665. */
  80666. isDescendantOf(ancestor: Node): boolean;
  80667. /** @hidden */
  80668. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  80669. /**
  80670. * Will return all nodes that have this node as ascendant
  80671. * @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
  80672. * @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
  80673. * @return all children nodes of all types
  80674. */
  80675. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  80676. /**
  80677. * Get all child-meshes of this node
  80678. * @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
  80679. * @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
  80680. * @returns an array of AbstractMesh
  80681. */
  80682. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  80683. /**
  80684. * Get all direct children of this node
  80685. * @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
  80686. * @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)
  80687. * @returns an array of Node
  80688. */
  80689. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  80690. /** @hidden */
  80691. _setReady(state: boolean): void;
  80692. /**
  80693. * Get an animation by name
  80694. * @param name defines the name of the animation to look for
  80695. * @returns null if not found else the requested animation
  80696. */
  80697. getAnimationByName(name: string): Nullable<Animation>;
  80698. /**
  80699. * Creates an animation range for this node
  80700. * @param name defines the name of the range
  80701. * @param from defines the starting key
  80702. * @param to defines the end key
  80703. */
  80704. createAnimationRange(name: string, from: number, to: number): void;
  80705. /**
  80706. * Delete a specific animation range
  80707. * @param name defines the name of the range to delete
  80708. * @param deleteFrames defines if animation frames from the range must be deleted as well
  80709. */
  80710. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80711. /**
  80712. * Get an animation range by name
  80713. * @param name defines the name of the animation range to look for
  80714. * @returns null if not found else the requested animation range
  80715. */
  80716. getAnimationRange(name: string): Nullable<AnimationRange>;
  80717. /**
  80718. * Will start the animation sequence
  80719. * @param name defines the range frames for animation sequence
  80720. * @param loop defines if the animation should loop (false by default)
  80721. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  80722. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  80723. * @returns the object created for this animation. If range does not exist, it will return null
  80724. */
  80725. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80726. /**
  80727. * Serialize animation ranges into a JSON compatible object
  80728. * @returns serialization object
  80729. */
  80730. serializeAnimationRanges(): any;
  80731. /**
  80732. * Computes the world matrix of the node
  80733. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80734. * @returns the world matrix
  80735. */
  80736. computeWorldMatrix(force?: boolean): Matrix;
  80737. /**
  80738. * Releases resources associated with this node.
  80739. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80740. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80741. */
  80742. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80743. /**
  80744. * Parse animation range data from a serialization object and store them into a given node
  80745. * @param node defines where to store the animation ranges
  80746. * @param parsedNode defines the serialization object to read data from
  80747. * @param scene defines the hosting scene
  80748. */
  80749. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  80750. }
  80751. }
  80752. declare module BABYLON {
  80753. /**
  80754. * Class used to store any kind of animation
  80755. */
  80756. export class Animation {
  80757. /**Name of the animation */
  80758. name: string;
  80759. /**Property to animate */
  80760. targetProperty: string;
  80761. /**The frames per second of the animation */
  80762. framePerSecond: number;
  80763. /**The data type of the animation */
  80764. dataType: number;
  80765. /**The loop mode of the animation */
  80766. loopMode?: number | undefined;
  80767. /**Specifies if blending should be enabled */
  80768. enableBlending?: boolean | undefined;
  80769. /**
  80770. * Use matrix interpolation instead of using direct key value when animating matrices
  80771. */
  80772. static AllowMatricesInterpolation: boolean;
  80773. /**
  80774. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  80775. */
  80776. static AllowMatrixDecomposeForInterpolation: boolean;
  80777. /**
  80778. * Stores the key frames of the animation
  80779. */
  80780. private _keys;
  80781. /**
  80782. * Stores the easing function of the animation
  80783. */
  80784. private _easingFunction;
  80785. /**
  80786. * @hidden Internal use only
  80787. */
  80788. _runtimeAnimations: RuntimeAnimation[];
  80789. /**
  80790. * The set of event that will be linked to this animation
  80791. */
  80792. private _events;
  80793. /**
  80794. * Stores an array of target property paths
  80795. */
  80796. targetPropertyPath: string[];
  80797. /**
  80798. * Stores the blending speed of the animation
  80799. */
  80800. blendingSpeed: number;
  80801. /**
  80802. * Stores the animation ranges for the animation
  80803. */
  80804. private _ranges;
  80805. /**
  80806. * @hidden Internal use
  80807. */
  80808. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  80809. /**
  80810. * Sets up an animation
  80811. * @param property The property to animate
  80812. * @param animationType The animation type to apply
  80813. * @param framePerSecond The frames per second of the animation
  80814. * @param easingFunction The easing function used in the animation
  80815. * @returns The created animation
  80816. */
  80817. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  80818. /**
  80819. * Create and start an animation on a node
  80820. * @param name defines the name of the global animation that will be run on all nodes
  80821. * @param node defines the root node where the animation will take place
  80822. * @param targetProperty defines property to animate
  80823. * @param framePerSecond defines the number of frame per second yo use
  80824. * @param totalFrame defines the number of frames in total
  80825. * @param from defines the initial value
  80826. * @param to defines the final value
  80827. * @param loopMode defines which loop mode you want to use (off by default)
  80828. * @param easingFunction defines the easing function to use (linear by default)
  80829. * @param onAnimationEnd defines the callback to call when animation end
  80830. * @returns the animatable created for this animation
  80831. */
  80832. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80833. /**
  80834. * Create and start an animation on a node and its descendants
  80835. * @param name defines the name of the global animation that will be run on all nodes
  80836. * @param node defines the root node where the animation will take place
  80837. * @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
  80838. * @param targetProperty defines property to animate
  80839. * @param framePerSecond defines the number of frame per second to use
  80840. * @param totalFrame defines the number of frames in total
  80841. * @param from defines the initial value
  80842. * @param to defines the final value
  80843. * @param loopMode defines which loop mode you want to use (off by default)
  80844. * @param easingFunction defines the easing function to use (linear by default)
  80845. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  80846. * @returns the list of animatables created for all nodes
  80847. * @example https://www.babylonjs-playground.com/#MH0VLI
  80848. */
  80849. 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[]>;
  80850. /**
  80851. * Creates a new animation, merges it with the existing animations and starts it
  80852. * @param name Name of the animation
  80853. * @param node Node which contains the scene that begins the animations
  80854. * @param targetProperty Specifies which property to animate
  80855. * @param framePerSecond The frames per second of the animation
  80856. * @param totalFrame The total number of frames
  80857. * @param from The frame at the beginning of the animation
  80858. * @param to The frame at the end of the animation
  80859. * @param loopMode Specifies the loop mode of the animation
  80860. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  80861. * @param onAnimationEnd Callback to run once the animation is complete
  80862. * @returns Nullable animation
  80863. */
  80864. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  80865. /**
  80866. * Transition property of an host to the target Value
  80867. * @param property The property to transition
  80868. * @param targetValue The target Value of the property
  80869. * @param host The object where the property to animate belongs
  80870. * @param scene Scene used to run the animation
  80871. * @param frameRate Framerate (in frame/s) to use
  80872. * @param transition The transition type we want to use
  80873. * @param duration The duration of the animation, in milliseconds
  80874. * @param onAnimationEnd Callback trigger at the end of the animation
  80875. * @returns Nullable animation
  80876. */
  80877. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  80878. /**
  80879. * Return the array of runtime animations currently using this animation
  80880. */
  80881. readonly runtimeAnimations: RuntimeAnimation[];
  80882. /**
  80883. * Specifies if any of the runtime animations are currently running
  80884. */
  80885. readonly hasRunningRuntimeAnimations: boolean;
  80886. /**
  80887. * Initializes the animation
  80888. * @param name Name of the animation
  80889. * @param targetProperty Property to animate
  80890. * @param framePerSecond The frames per second of the animation
  80891. * @param dataType The data type of the animation
  80892. * @param loopMode The loop mode of the animation
  80893. * @param enableBlending Specifies if blending should be enabled
  80894. */
  80895. constructor(
  80896. /**Name of the animation */
  80897. name: string,
  80898. /**Property to animate */
  80899. targetProperty: string,
  80900. /**The frames per second of the animation */
  80901. framePerSecond: number,
  80902. /**The data type of the animation */
  80903. dataType: number,
  80904. /**The loop mode of the animation */
  80905. loopMode?: number | undefined,
  80906. /**Specifies if blending should be enabled */
  80907. enableBlending?: boolean | undefined);
  80908. /**
  80909. * Converts the animation to a string
  80910. * @param fullDetails support for multiple levels of logging within scene loading
  80911. * @returns String form of the animation
  80912. */
  80913. toString(fullDetails?: boolean): string;
  80914. /**
  80915. * Add an event to this animation
  80916. * @param event Event to add
  80917. */
  80918. addEvent(event: AnimationEvent): void;
  80919. /**
  80920. * Remove all events found at the given frame
  80921. * @param frame The frame to remove events from
  80922. */
  80923. removeEvents(frame: number): void;
  80924. /**
  80925. * Retrieves all the events from the animation
  80926. * @returns Events from the animation
  80927. */
  80928. getEvents(): AnimationEvent[];
  80929. /**
  80930. * Creates an animation range
  80931. * @param name Name of the animation range
  80932. * @param from Starting frame of the animation range
  80933. * @param to Ending frame of the animation
  80934. */
  80935. createRange(name: string, from: number, to: number): void;
  80936. /**
  80937. * Deletes an animation range by name
  80938. * @param name Name of the animation range to delete
  80939. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  80940. */
  80941. deleteRange(name: string, deleteFrames?: boolean): void;
  80942. /**
  80943. * Gets the animation range by name, or null if not defined
  80944. * @param name Name of the animation range
  80945. * @returns Nullable animation range
  80946. */
  80947. getRange(name: string): Nullable<AnimationRange>;
  80948. /**
  80949. * Gets the key frames from the animation
  80950. * @returns The key frames of the animation
  80951. */
  80952. getKeys(): Array<IAnimationKey>;
  80953. /**
  80954. * Gets the highest frame rate of the animation
  80955. * @returns Highest frame rate of the animation
  80956. */
  80957. getHighestFrame(): number;
  80958. /**
  80959. * Gets the easing function of the animation
  80960. * @returns Easing function of the animation
  80961. */
  80962. getEasingFunction(): IEasingFunction;
  80963. /**
  80964. * Sets the easing function of the animation
  80965. * @param easingFunction A custom mathematical formula for animation
  80966. */
  80967. setEasingFunction(easingFunction: EasingFunction): void;
  80968. /**
  80969. * Interpolates a scalar linearly
  80970. * @param startValue Start value of the animation curve
  80971. * @param endValue End value of the animation curve
  80972. * @param gradient Scalar amount to interpolate
  80973. * @returns Interpolated scalar value
  80974. */
  80975. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  80976. /**
  80977. * Interpolates a scalar cubically
  80978. * @param startValue Start value of the animation curve
  80979. * @param outTangent End tangent of the animation
  80980. * @param endValue End value of the animation curve
  80981. * @param inTangent Start tangent of the animation curve
  80982. * @param gradient Scalar amount to interpolate
  80983. * @returns Interpolated scalar value
  80984. */
  80985. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  80986. /**
  80987. * Interpolates a quaternion using a spherical linear interpolation
  80988. * @param startValue Start value of the animation curve
  80989. * @param endValue End value of the animation curve
  80990. * @param gradient Scalar amount to interpolate
  80991. * @returns Interpolated quaternion value
  80992. */
  80993. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  80994. /**
  80995. * Interpolates a quaternion cubically
  80996. * @param startValue Start value of the animation curve
  80997. * @param outTangent End tangent of the animation curve
  80998. * @param endValue End value of the animation curve
  80999. * @param inTangent Start tangent of the animation curve
  81000. * @param gradient Scalar amount to interpolate
  81001. * @returns Interpolated quaternion value
  81002. */
  81003. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  81004. /**
  81005. * Interpolates a Vector3 linearl
  81006. * @param startValue Start value of the animation curve
  81007. * @param endValue End value of the animation curve
  81008. * @param gradient Scalar amount to interpolate
  81009. * @returns Interpolated scalar value
  81010. */
  81011. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  81012. /**
  81013. * Interpolates a Vector3 cubically
  81014. * @param startValue Start value of the animation curve
  81015. * @param outTangent End tangent of the animation
  81016. * @param endValue End value of the animation curve
  81017. * @param inTangent Start tangent of the animation curve
  81018. * @param gradient Scalar amount to interpolate
  81019. * @returns InterpolatedVector3 value
  81020. */
  81021. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  81022. /**
  81023. * Interpolates a Vector2 linearly
  81024. * @param startValue Start value of the animation curve
  81025. * @param endValue End value of the animation curve
  81026. * @param gradient Scalar amount to interpolate
  81027. * @returns Interpolated Vector2 value
  81028. */
  81029. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  81030. /**
  81031. * Interpolates a Vector2 cubically
  81032. * @param startValue Start value of the animation curve
  81033. * @param outTangent End tangent of the animation
  81034. * @param endValue End value of the animation curve
  81035. * @param inTangent Start tangent of the animation curve
  81036. * @param gradient Scalar amount to interpolate
  81037. * @returns Interpolated Vector2 value
  81038. */
  81039. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  81040. /**
  81041. * Interpolates a size linearly
  81042. * @param startValue Start value of the animation curve
  81043. * @param endValue End value of the animation curve
  81044. * @param gradient Scalar amount to interpolate
  81045. * @returns Interpolated Size value
  81046. */
  81047. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  81048. /**
  81049. * Interpolates a Color3 linearly
  81050. * @param startValue Start value of the animation curve
  81051. * @param endValue End value of the animation curve
  81052. * @param gradient Scalar amount to interpolate
  81053. * @returns Interpolated Color3 value
  81054. */
  81055. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  81056. /**
  81057. * @hidden Internal use only
  81058. */
  81059. _getKeyValue(value: any): any;
  81060. /**
  81061. * @hidden Internal use only
  81062. */
  81063. _interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  81064. /**
  81065. * Defines the function to use to interpolate matrices
  81066. * @param startValue defines the start matrix
  81067. * @param endValue defines the end matrix
  81068. * @param gradient defines the gradient between both matrices
  81069. * @param result defines an optional target matrix where to store the interpolation
  81070. * @returns the interpolated matrix
  81071. */
  81072. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  81073. /**
  81074. * Makes a copy of the animation
  81075. * @returns Cloned animation
  81076. */
  81077. clone(): Animation;
  81078. /**
  81079. * Sets the key frames of the animation
  81080. * @param values The animation key frames to set
  81081. */
  81082. setKeys(values: Array<IAnimationKey>): void;
  81083. /**
  81084. * Serializes the animation to an object
  81085. * @returns Serialized object
  81086. */
  81087. serialize(): any;
  81088. /**
  81089. * Float animation type
  81090. */
  81091. private static _ANIMATIONTYPE_FLOAT;
  81092. /**
  81093. * Vector3 animation type
  81094. */
  81095. private static _ANIMATIONTYPE_VECTOR3;
  81096. /**
  81097. * Quaternion animation type
  81098. */
  81099. private static _ANIMATIONTYPE_QUATERNION;
  81100. /**
  81101. * Matrix animation type
  81102. */
  81103. private static _ANIMATIONTYPE_MATRIX;
  81104. /**
  81105. * Color3 animation type
  81106. */
  81107. private static _ANIMATIONTYPE_COLOR3;
  81108. /**
  81109. * Vector2 animation type
  81110. */
  81111. private static _ANIMATIONTYPE_VECTOR2;
  81112. /**
  81113. * Size animation type
  81114. */
  81115. private static _ANIMATIONTYPE_SIZE;
  81116. /**
  81117. * Relative Loop Mode
  81118. */
  81119. private static _ANIMATIONLOOPMODE_RELATIVE;
  81120. /**
  81121. * Cycle Loop Mode
  81122. */
  81123. private static _ANIMATIONLOOPMODE_CYCLE;
  81124. /**
  81125. * Constant Loop Mode
  81126. */
  81127. private static _ANIMATIONLOOPMODE_CONSTANT;
  81128. /**
  81129. * Get the float animation type
  81130. */
  81131. static readonly ANIMATIONTYPE_FLOAT: number;
  81132. /**
  81133. * Get the Vector3 animation type
  81134. */
  81135. static readonly ANIMATIONTYPE_VECTOR3: number;
  81136. /**
  81137. * Get the Vector2 animation type
  81138. */
  81139. static readonly ANIMATIONTYPE_VECTOR2: number;
  81140. /**
  81141. * Get the Size animation type
  81142. */
  81143. static readonly ANIMATIONTYPE_SIZE: number;
  81144. /**
  81145. * Get the Quaternion animation type
  81146. */
  81147. static readonly ANIMATIONTYPE_QUATERNION: number;
  81148. /**
  81149. * Get the Matrix animation type
  81150. */
  81151. static readonly ANIMATIONTYPE_MATRIX: number;
  81152. /**
  81153. * Get the Color3 animation type
  81154. */
  81155. static readonly ANIMATIONTYPE_COLOR3: number;
  81156. /**
  81157. * Get the Relative Loop Mode
  81158. */
  81159. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  81160. /**
  81161. * Get the Cycle Loop Mode
  81162. */
  81163. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  81164. /**
  81165. * Get the Constant Loop Mode
  81166. */
  81167. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  81168. /** @hidden */
  81169. static _UniversalLerp(left: any, right: any, amount: number): any;
  81170. /**
  81171. * Parses an animation object and creates an animation
  81172. * @param parsedAnimation Parsed animation object
  81173. * @returns Animation object
  81174. */
  81175. static Parse(parsedAnimation: any): Animation;
  81176. /**
  81177. * Appends the serialized animations from the source animations
  81178. * @param source Source containing the animations
  81179. * @param destination Target to store the animations
  81180. */
  81181. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  81182. }
  81183. }
  81184. declare module BABYLON {
  81185. /**
  81186. * Base class of all the textures in babylon.
  81187. * It groups all the common properties the materials, post process, lights... might need
  81188. * in order to make a correct use of the texture.
  81189. */
  81190. export class BaseTexture implements IAnimatable {
  81191. /**
  81192. * Default anisotropic filtering level for the application.
  81193. * It is set to 4 as a good tradeoff between perf and quality.
  81194. */
  81195. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  81196. /**
  81197. * Gets or sets the unique id of the texture
  81198. */
  81199. uniqueId: number;
  81200. /**
  81201. * Define the name of the texture.
  81202. */
  81203. name: string;
  81204. /**
  81205. * Gets or sets an object used to store user defined information.
  81206. */
  81207. metadata: any;
  81208. /**
  81209. * For internal use only. Please do not use.
  81210. */
  81211. reservedDataStore: any;
  81212. private _hasAlpha;
  81213. /**
  81214. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  81215. */
  81216. hasAlpha: boolean;
  81217. /**
  81218. * Defines if the alpha value should be determined via the rgb values.
  81219. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  81220. */
  81221. getAlphaFromRGB: boolean;
  81222. /**
  81223. * Intensity or strength of the texture.
  81224. * It is commonly used by materials to fine tune the intensity of the texture
  81225. */
  81226. level: number;
  81227. /**
  81228. * Define the UV chanel to use starting from 0 and defaulting to 0.
  81229. * This is part of the texture as textures usually maps to one uv set.
  81230. */
  81231. coordinatesIndex: number;
  81232. private _coordinatesMode;
  81233. /**
  81234. * How a texture is mapped.
  81235. *
  81236. * | Value | Type | Description |
  81237. * | ----- | ----------------------------------- | ----------- |
  81238. * | 0 | EXPLICIT_MODE | |
  81239. * | 1 | SPHERICAL_MODE | |
  81240. * | 2 | PLANAR_MODE | |
  81241. * | 3 | CUBIC_MODE | |
  81242. * | 4 | PROJECTION_MODE | |
  81243. * | 5 | SKYBOX_MODE | |
  81244. * | 6 | INVCUBIC_MODE | |
  81245. * | 7 | EQUIRECTANGULAR_MODE | |
  81246. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  81247. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  81248. */
  81249. coordinatesMode: number;
  81250. /**
  81251. * | Value | Type | Description |
  81252. * | ----- | ------------------ | ----------- |
  81253. * | 0 | CLAMP_ADDRESSMODE | |
  81254. * | 1 | WRAP_ADDRESSMODE | |
  81255. * | 2 | MIRROR_ADDRESSMODE | |
  81256. */
  81257. wrapU: number;
  81258. /**
  81259. * | Value | Type | Description |
  81260. * | ----- | ------------------ | ----------- |
  81261. * | 0 | CLAMP_ADDRESSMODE | |
  81262. * | 1 | WRAP_ADDRESSMODE | |
  81263. * | 2 | MIRROR_ADDRESSMODE | |
  81264. */
  81265. wrapV: number;
  81266. /**
  81267. * | Value | Type | Description |
  81268. * | ----- | ------------------ | ----------- |
  81269. * | 0 | CLAMP_ADDRESSMODE | |
  81270. * | 1 | WRAP_ADDRESSMODE | |
  81271. * | 2 | MIRROR_ADDRESSMODE | |
  81272. */
  81273. wrapR: number;
  81274. /**
  81275. * With compliant hardware and browser (supporting anisotropic filtering)
  81276. * this defines the level of anisotropic filtering in the texture.
  81277. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  81278. */
  81279. anisotropicFilteringLevel: number;
  81280. /**
  81281. * Define if the texture is a cube texture or if false a 2d texture.
  81282. */
  81283. isCube: boolean;
  81284. /**
  81285. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  81286. */
  81287. is3D: boolean;
  81288. /**
  81289. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  81290. * HDR texture are usually stored in linear space.
  81291. * This only impacts the PBR and Background materials
  81292. */
  81293. gammaSpace: boolean;
  81294. /**
  81295. * Gets whether or not the texture contains RGBD data.
  81296. */
  81297. readonly isRGBD: boolean;
  81298. /**
  81299. * Is Z inverted in the texture (useful in a cube texture).
  81300. */
  81301. invertZ: boolean;
  81302. /**
  81303. * Are mip maps generated for this texture or not.
  81304. */
  81305. readonly noMipmap: boolean;
  81306. /**
  81307. * @hidden
  81308. */
  81309. lodLevelInAlpha: boolean;
  81310. /**
  81311. * With prefiltered texture, defined the offset used during the prefiltering steps.
  81312. */
  81313. lodGenerationOffset: number;
  81314. /**
  81315. * With prefiltered texture, defined the scale used during the prefiltering steps.
  81316. */
  81317. lodGenerationScale: number;
  81318. /**
  81319. * Define if the texture is a render target.
  81320. */
  81321. isRenderTarget: boolean;
  81322. /**
  81323. * Define the unique id of the texture in the scene.
  81324. */
  81325. readonly uid: string;
  81326. /**
  81327. * Return a string representation of the texture.
  81328. * @returns the texture as a string
  81329. */
  81330. toString(): string;
  81331. /**
  81332. * Get the class name of the texture.
  81333. * @returns "BaseTexture"
  81334. */
  81335. getClassName(): string;
  81336. /**
  81337. * Define the list of animation attached to the texture.
  81338. */
  81339. animations: Animation[];
  81340. /**
  81341. * An event triggered when the texture is disposed.
  81342. */
  81343. onDisposeObservable: Observable<BaseTexture>;
  81344. private _onDisposeObserver;
  81345. /**
  81346. * Callback triggered when the texture has been disposed.
  81347. * Kept for back compatibility, you can use the onDisposeObservable instead.
  81348. */
  81349. onDispose: () => void;
  81350. /**
  81351. * Define the current state of the loading sequence when in delayed load mode.
  81352. */
  81353. delayLoadState: number;
  81354. private _scene;
  81355. /** @hidden */
  81356. _texture: Nullable<InternalTexture>;
  81357. private _uid;
  81358. /**
  81359. * Define if the texture is preventinga material to render or not.
  81360. * If not and the texture is not ready, the engine will use a default black texture instead.
  81361. */
  81362. readonly isBlocking: boolean;
  81363. /**
  81364. * Instantiates a new BaseTexture.
  81365. * Base class of all the textures in babylon.
  81366. * It groups all the common properties the materials, post process, lights... might need
  81367. * in order to make a correct use of the texture.
  81368. * @param scene Define the scene the texture blongs to
  81369. */
  81370. constructor(scene: Nullable<Scene>);
  81371. /**
  81372. * Get the scene the texture belongs to.
  81373. * @returns the scene or null if undefined
  81374. */
  81375. getScene(): Nullable<Scene>;
  81376. /**
  81377. * Get the texture transform matrix used to offset tile the texture for istance.
  81378. * @returns the transformation matrix
  81379. */
  81380. getTextureMatrix(): Matrix;
  81381. /**
  81382. * Get the texture reflection matrix used to rotate/transform the reflection.
  81383. * @returns the reflection matrix
  81384. */
  81385. getReflectionTextureMatrix(): Matrix;
  81386. /**
  81387. * Get the underlying lower level texture from Babylon.
  81388. * @returns the insternal texture
  81389. */
  81390. getInternalTexture(): Nullable<InternalTexture>;
  81391. /**
  81392. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  81393. * @returns true if ready or not blocking
  81394. */
  81395. isReadyOrNotBlocking(): boolean;
  81396. /**
  81397. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  81398. * @returns true if fully ready
  81399. */
  81400. isReady(): boolean;
  81401. private _cachedSize;
  81402. /**
  81403. * Get the size of the texture.
  81404. * @returns the texture size.
  81405. */
  81406. getSize(): ISize;
  81407. /**
  81408. * Get the base size of the texture.
  81409. * It can be different from the size if the texture has been resized for POT for instance
  81410. * @returns the base size
  81411. */
  81412. getBaseSize(): ISize;
  81413. /**
  81414. * Update the sampling mode of the texture.
  81415. * Default is Trilinear mode.
  81416. *
  81417. * | Value | Type | Description |
  81418. * | ----- | ------------------ | ----------- |
  81419. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  81420. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  81421. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  81422. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  81423. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  81424. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  81425. * | 7 | NEAREST_LINEAR | |
  81426. * | 8 | NEAREST_NEAREST | |
  81427. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  81428. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  81429. * | 11 | LINEAR_LINEAR | |
  81430. * | 12 | LINEAR_NEAREST | |
  81431. *
  81432. * > _mag_: magnification filter (close to the viewer)
  81433. * > _min_: minification filter (far from the viewer)
  81434. * > _mip_: filter used between mip map levels
  81435. *@param samplingMode Define the new sampling mode of the texture
  81436. */
  81437. updateSamplingMode(samplingMode: number): void;
  81438. /**
  81439. * Scales the texture if is `canRescale()`
  81440. * @param ratio the resize factor we want to use to rescale
  81441. */
  81442. scale(ratio: number): void;
  81443. /**
  81444. * Get if the texture can rescale.
  81445. */
  81446. readonly canRescale: boolean;
  81447. /** @hidden */
  81448. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  81449. /** @hidden */
  81450. _rebuild(): void;
  81451. /**
  81452. * Triggers the load sequence in delayed load mode.
  81453. */
  81454. delayLoad(): void;
  81455. /**
  81456. * Clones the texture.
  81457. * @returns the cloned texture
  81458. */
  81459. clone(): Nullable<BaseTexture>;
  81460. /**
  81461. * Get the texture underlying type (INT, FLOAT...)
  81462. */
  81463. readonly textureType: number;
  81464. /**
  81465. * Get the texture underlying format (RGB, RGBA...)
  81466. */
  81467. readonly textureFormat: number;
  81468. /**
  81469. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  81470. * This will returns an RGBA array buffer containing either in values (0-255) or
  81471. * float values (0-1) depending of the underlying buffer type.
  81472. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  81473. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  81474. * @param buffer defines a user defined buffer to fill with data (can be null)
  81475. * @returns The Array buffer containing the pixels data.
  81476. */
  81477. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  81478. /**
  81479. * Release and destroy the underlying lower level texture aka internalTexture.
  81480. */
  81481. releaseInternalTexture(): void;
  81482. /**
  81483. * Get the polynomial representation of the texture data.
  81484. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  81485. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  81486. */
  81487. sphericalPolynomial: Nullable<SphericalPolynomial>;
  81488. /** @hidden */
  81489. readonly _lodTextureHigh: Nullable<BaseTexture>;
  81490. /** @hidden */
  81491. readonly _lodTextureMid: Nullable<BaseTexture>;
  81492. /** @hidden */
  81493. readonly _lodTextureLow: Nullable<BaseTexture>;
  81494. /**
  81495. * Dispose the texture and release its associated resources.
  81496. */
  81497. dispose(): void;
  81498. /**
  81499. * Serialize the texture into a JSON representation that can be parsed later on.
  81500. * @returns the JSON representation of the texture
  81501. */
  81502. serialize(): any;
  81503. /**
  81504. * Helper function to be called back once a list of texture contains only ready textures.
  81505. * @param textures Define the list of textures to wait for
  81506. * @param callback Define the callback triggered once the entire list will be ready
  81507. */
  81508. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  81509. }
  81510. }
  81511. declare module BABYLON {
  81512. /**
  81513. * Uniform buffer objects.
  81514. *
  81515. * Handles blocks of uniform on the GPU.
  81516. *
  81517. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81518. *
  81519. * For more information, please refer to :
  81520. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81521. */
  81522. export class UniformBuffer {
  81523. private _engine;
  81524. private _buffer;
  81525. private _data;
  81526. private _bufferData;
  81527. private _dynamic?;
  81528. private _uniformLocations;
  81529. private _uniformSizes;
  81530. private _uniformLocationPointer;
  81531. private _needSync;
  81532. private _noUBO;
  81533. private _currentEffect;
  81534. private static _MAX_UNIFORM_SIZE;
  81535. private static _tempBuffer;
  81536. /**
  81537. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81538. * This is dynamic to allow compat with webgl 1 and 2.
  81539. * You will need to pass the name of the uniform as well as the value.
  81540. */
  81541. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81542. /**
  81543. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81544. * This is dynamic to allow compat with webgl 1 and 2.
  81545. * You will need to pass the name of the uniform as well as the value.
  81546. */
  81547. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81548. /**
  81549. * Lambda to Update a single float in a uniform buffer.
  81550. * This is dynamic to allow compat with webgl 1 and 2.
  81551. * You will need to pass the name of the uniform as well as the value.
  81552. */
  81553. updateFloat: (name: string, x: number) => void;
  81554. /**
  81555. * Lambda to Update a vec2 of float in a uniform buffer.
  81556. * This is dynamic to allow compat with webgl 1 and 2.
  81557. * You will need to pass the name of the uniform as well as the value.
  81558. */
  81559. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81560. /**
  81561. * Lambda to Update a vec3 of float in a uniform buffer.
  81562. * This is dynamic to allow compat with webgl 1 and 2.
  81563. * You will need to pass the name of the uniform as well as the value.
  81564. */
  81565. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81566. /**
  81567. * Lambda to Update a vec4 of float in a uniform buffer.
  81568. * This is dynamic to allow compat with webgl 1 and 2.
  81569. * You will need to pass the name of the uniform as well as the value.
  81570. */
  81571. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81572. /**
  81573. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81574. * This is dynamic to allow compat with webgl 1 and 2.
  81575. * You will need to pass the name of the uniform as well as the value.
  81576. */
  81577. updateMatrix: (name: string, mat: Matrix) => void;
  81578. /**
  81579. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81580. * This is dynamic to allow compat with webgl 1 and 2.
  81581. * You will need to pass the name of the uniform as well as the value.
  81582. */
  81583. updateVector3: (name: string, vector: Vector3) => void;
  81584. /**
  81585. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81586. * This is dynamic to allow compat with webgl 1 and 2.
  81587. * You will need to pass the name of the uniform as well as the value.
  81588. */
  81589. updateVector4: (name: string, vector: Vector4) => void;
  81590. /**
  81591. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81592. * This is dynamic to allow compat with webgl 1 and 2.
  81593. * You will need to pass the name of the uniform as well as the value.
  81594. */
  81595. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81596. /**
  81597. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81598. * This is dynamic to allow compat with webgl 1 and 2.
  81599. * You will need to pass the name of the uniform as well as the value.
  81600. */
  81601. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81602. /**
  81603. * Instantiates a new Uniform buffer objects.
  81604. *
  81605. * Handles blocks of uniform on the GPU.
  81606. *
  81607. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81608. *
  81609. * For more information, please refer to :
  81610. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81611. * @param engine Define the engine the buffer is associated with
  81612. * @param data Define the data contained in the buffer
  81613. * @param dynamic Define if the buffer is updatable
  81614. */
  81615. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81616. /**
  81617. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81618. * or just falling back on setUniformXXX calls.
  81619. */
  81620. readonly useUbo: boolean;
  81621. /**
  81622. * Indicates if the WebGL underlying uniform buffer is in sync
  81623. * with the javascript cache data.
  81624. */
  81625. readonly isSync: boolean;
  81626. /**
  81627. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81628. * Also, a dynamic UniformBuffer will disable cache verification and always
  81629. * update the underlying WebGL uniform buffer to the GPU.
  81630. * @returns if Dynamic, otherwise false
  81631. */
  81632. isDynamic(): boolean;
  81633. /**
  81634. * The data cache on JS side.
  81635. * @returns the underlying data as a float array
  81636. */
  81637. getData(): Float32Array;
  81638. /**
  81639. * The underlying WebGL Uniform buffer.
  81640. * @returns the webgl buffer
  81641. */
  81642. getBuffer(): Nullable<WebGLBuffer>;
  81643. /**
  81644. * std140 layout specifies how to align data within an UBO structure.
  81645. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81646. * for specs.
  81647. */
  81648. private _fillAlignment;
  81649. /**
  81650. * Adds an uniform in the buffer.
  81651. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81652. * for the layout to be correct !
  81653. * @param name Name of the uniform, as used in the uniform block in the shader.
  81654. * @param size Data size, or data directly.
  81655. */
  81656. addUniform(name: string, size: number | number[]): void;
  81657. /**
  81658. * Adds a Matrix 4x4 to the uniform buffer.
  81659. * @param name Name of the uniform, as used in the uniform block in the shader.
  81660. * @param mat A 4x4 matrix.
  81661. */
  81662. addMatrix(name: string, mat: Matrix): void;
  81663. /**
  81664. * Adds a vec2 to the uniform buffer.
  81665. * @param name Name of the uniform, as used in the uniform block in the shader.
  81666. * @param x Define the x component value of the vec2
  81667. * @param y Define the y component value of the vec2
  81668. */
  81669. addFloat2(name: string, x: number, y: number): void;
  81670. /**
  81671. * Adds a vec3 to the uniform buffer.
  81672. * @param name Name of the uniform, as used in the uniform block in the shader.
  81673. * @param x Define the x component value of the vec3
  81674. * @param y Define the y component value of the vec3
  81675. * @param z Define the z component value of the vec3
  81676. */
  81677. addFloat3(name: string, x: number, y: number, z: number): void;
  81678. /**
  81679. * Adds a vec3 to the uniform buffer.
  81680. * @param name Name of the uniform, as used in the uniform block in the shader.
  81681. * @param color Define the vec3 from a Color
  81682. */
  81683. addColor3(name: string, color: Color3): void;
  81684. /**
  81685. * Adds a vec4 to the uniform buffer.
  81686. * @param name Name of the uniform, as used in the uniform block in the shader.
  81687. * @param color Define the rgb components from a Color
  81688. * @param alpha Define the a component of the vec4
  81689. */
  81690. addColor4(name: string, color: Color3, alpha: number): void;
  81691. /**
  81692. * Adds a vec3 to the uniform buffer.
  81693. * @param name Name of the uniform, as used in the uniform block in the shader.
  81694. * @param vector Define the vec3 components from a Vector
  81695. */
  81696. addVector3(name: string, vector: Vector3): void;
  81697. /**
  81698. * Adds a Matrix 3x3 to the uniform buffer.
  81699. * @param name Name of the uniform, as used in the uniform block in the shader.
  81700. */
  81701. addMatrix3x3(name: string): void;
  81702. /**
  81703. * Adds a Matrix 2x2 to the uniform buffer.
  81704. * @param name Name of the uniform, as used in the uniform block in the shader.
  81705. */
  81706. addMatrix2x2(name: string): void;
  81707. /**
  81708. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81709. */
  81710. create(): void;
  81711. /** @hidden */
  81712. _rebuild(): void;
  81713. /**
  81714. * Updates the WebGL Uniform Buffer on the GPU.
  81715. * If the `dynamic` flag is set to true, no cache comparison is done.
  81716. * Otherwise, the buffer will be updated only if the cache differs.
  81717. */
  81718. update(): void;
  81719. /**
  81720. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81721. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81722. * @param data Define the flattened data
  81723. * @param size Define the size of the data.
  81724. */
  81725. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81726. private _updateMatrix3x3ForUniform;
  81727. private _updateMatrix3x3ForEffect;
  81728. private _updateMatrix2x2ForEffect;
  81729. private _updateMatrix2x2ForUniform;
  81730. private _updateFloatForEffect;
  81731. private _updateFloatForUniform;
  81732. private _updateFloat2ForEffect;
  81733. private _updateFloat2ForUniform;
  81734. private _updateFloat3ForEffect;
  81735. private _updateFloat3ForUniform;
  81736. private _updateFloat4ForEffect;
  81737. private _updateFloat4ForUniform;
  81738. private _updateMatrixForEffect;
  81739. private _updateMatrixForUniform;
  81740. private _updateVector3ForEffect;
  81741. private _updateVector3ForUniform;
  81742. private _updateVector4ForEffect;
  81743. private _updateVector4ForUniform;
  81744. private _updateColor3ForEffect;
  81745. private _updateColor3ForUniform;
  81746. private _updateColor4ForEffect;
  81747. private _updateColor4ForUniform;
  81748. /**
  81749. * Sets a sampler uniform on the effect.
  81750. * @param name Define the name of the sampler.
  81751. * @param texture Define the texture to set in the sampler
  81752. */
  81753. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81754. /**
  81755. * Directly updates the value of the uniform in the cache AND on the GPU.
  81756. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81757. * @param data Define the flattened data
  81758. */
  81759. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81760. /**
  81761. * Binds this uniform buffer to an effect.
  81762. * @param effect Define the effect to bind the buffer to
  81763. * @param name Name of the uniform block in the shader.
  81764. */
  81765. bindToEffect(effect: Effect, name: string): void;
  81766. /**
  81767. * Disposes the uniform buffer.
  81768. */
  81769. dispose(): void;
  81770. }
  81771. }
  81772. declare module BABYLON {
  81773. /**
  81774. * This represents the required contract to create a new type of texture loader.
  81775. */
  81776. export interface IInternalTextureLoader {
  81777. /**
  81778. * Defines wether the loader supports cascade loading the different faces.
  81779. */
  81780. supportCascades: boolean;
  81781. /**
  81782. * This returns if the loader support the current file information.
  81783. * @param extension defines the file extension of the file being loaded
  81784. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81785. * @param fallback defines the fallback internal texture if any
  81786. * @param isBase64 defines whether the texture is encoded as a base64
  81787. * @param isBuffer defines whether the texture data are stored as a buffer
  81788. * @returns true if the loader can load the specified file
  81789. */
  81790. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  81791. /**
  81792. * Transform the url before loading if required.
  81793. * @param rootUrl the url of the texture
  81794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81795. * @returns the transformed texture
  81796. */
  81797. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  81798. /**
  81799. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  81800. * @param rootUrl the url of the texture
  81801. * @param textureFormatInUse defines the current compressed format in use iun the engine
  81802. * @returns the fallback texture
  81803. */
  81804. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  81805. /**
  81806. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  81807. * @param data contains the texture data
  81808. * @param texture defines the BabylonJS internal texture
  81809. * @param createPolynomials will be true if polynomials have been requested
  81810. * @param onLoad defines the callback to trigger once the texture is ready
  81811. * @param onError defines the callback to trigger in case of error
  81812. */
  81813. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81814. /**
  81815. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  81816. * @param data contains the texture data
  81817. * @param texture defines the BabylonJS internal texture
  81818. * @param callback defines the method to call once ready to upload
  81819. */
  81820. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81821. }
  81822. }
  81823. declare module BABYLON {
  81824. /**
  81825. * Creation options of the multi render target texture.
  81826. */
  81827. export interface IMultiRenderTargetOptions {
  81828. /**
  81829. * Define if the texture needs to create mip maps after render.
  81830. */
  81831. generateMipMaps?: boolean;
  81832. /**
  81833. * Define the types of all the draw buffers we want to create
  81834. */
  81835. types?: number[];
  81836. /**
  81837. * Define the sampling modes of all the draw buffers we want to create
  81838. */
  81839. samplingModes?: number[];
  81840. /**
  81841. * Define if a depth buffer is required
  81842. */
  81843. generateDepthBuffer?: boolean;
  81844. /**
  81845. * Define if a stencil buffer is required
  81846. */
  81847. generateStencilBuffer?: boolean;
  81848. /**
  81849. * Define if a depth texture is required instead of a depth buffer
  81850. */
  81851. generateDepthTexture?: boolean;
  81852. /**
  81853. * Define the number of desired draw buffers
  81854. */
  81855. textureCount?: number;
  81856. /**
  81857. * Define if aspect ratio should be adapted to the texture or stay the scene one
  81858. */
  81859. doNotChangeAspectRatio?: boolean;
  81860. /**
  81861. * Define the default type of the buffers we are creating
  81862. */
  81863. defaultType?: number;
  81864. }
  81865. /**
  81866. * A multi render target, like a render target provides the ability to render to a texture.
  81867. * Unlike the render target, it can render to several draw buffers in one draw.
  81868. * This is specially interesting in deferred rendering or for any effects requiring more than
  81869. * just one color from a single pass.
  81870. */
  81871. export class MultiRenderTarget extends RenderTargetTexture {
  81872. private _internalTextures;
  81873. private _textures;
  81874. private _multiRenderTargetOptions;
  81875. /**
  81876. * Get if draw buffers are currently supported by the used hardware and browser.
  81877. */
  81878. readonly isSupported: boolean;
  81879. /**
  81880. * Get the list of textures generated by the multi render target.
  81881. */
  81882. readonly textures: Texture[];
  81883. /**
  81884. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  81885. */
  81886. readonly depthTexture: Texture;
  81887. /**
  81888. * Set the wrapping mode on U of all the textures we are rendering to.
  81889. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81890. */
  81891. wrapU: number;
  81892. /**
  81893. * Set the wrapping mode on V of all the textures we are rendering to.
  81894. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  81895. */
  81896. wrapV: number;
  81897. /**
  81898. * Instantiate a new multi render target texture.
  81899. * A multi render target, like a render target provides the ability to render to a texture.
  81900. * Unlike the render target, it can render to several draw buffers in one draw.
  81901. * This is specially interesting in deferred rendering or for any effects requiring more than
  81902. * just one color from a single pass.
  81903. * @param name Define the name of the texture
  81904. * @param size Define the size of the buffers to render to
  81905. * @param count Define the number of target we are rendering into
  81906. * @param scene Define the scene the texture belongs to
  81907. * @param options Define the options used to create the multi render target
  81908. */
  81909. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  81910. /** @hidden */
  81911. _rebuild(): void;
  81912. private _createInternalTextures;
  81913. private _createTextures;
  81914. /**
  81915. * Define the number of samples used if MSAA is enabled.
  81916. */
  81917. samples: number;
  81918. /**
  81919. * Resize all the textures in the multi render target.
  81920. * Be carrefull as it will recreate all the data in the new texture.
  81921. * @param size Define the new size
  81922. */
  81923. resize(size: any): void;
  81924. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  81925. /**
  81926. * Dispose the render targets and their associated resources
  81927. */
  81928. dispose(): void;
  81929. /**
  81930. * Release all the underlying texture used as draw buffers.
  81931. */
  81932. releaseInternalTextures(): void;
  81933. }
  81934. }
  81935. declare module BABYLON {
  81936. /**
  81937. * Class used to work with sound analyzer using fast fourier transform (FFT)
  81938. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  81939. */
  81940. export class Analyser {
  81941. /**
  81942. * Gets or sets the smoothing
  81943. * @ignorenaming
  81944. */
  81945. SMOOTHING: number;
  81946. /**
  81947. * Gets or sets the FFT table size
  81948. * @ignorenaming
  81949. */
  81950. FFT_SIZE: number;
  81951. /**
  81952. * Gets or sets the bar graph amplitude
  81953. * @ignorenaming
  81954. */
  81955. BARGRAPHAMPLITUDE: number;
  81956. /**
  81957. * Gets or sets the position of the debug canvas
  81958. * @ignorenaming
  81959. */
  81960. DEBUGCANVASPOS: {
  81961. x: number;
  81962. y: number;
  81963. };
  81964. /**
  81965. * Gets or sets the debug canvas size
  81966. * @ignorenaming
  81967. */
  81968. DEBUGCANVASSIZE: {
  81969. width: number;
  81970. height: number;
  81971. };
  81972. private _byteFreqs;
  81973. private _byteTime;
  81974. private _floatFreqs;
  81975. private _webAudioAnalyser;
  81976. private _debugCanvas;
  81977. private _debugCanvasContext;
  81978. private _scene;
  81979. private _registerFunc;
  81980. private _audioEngine;
  81981. /**
  81982. * Creates a new analyser
  81983. * @param scene defines hosting scene
  81984. */
  81985. constructor(scene: Scene);
  81986. /**
  81987. * Get the number of data values you will have to play with for the visualization
  81988. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  81989. * @returns a number
  81990. */
  81991. getFrequencyBinCount(): number;
  81992. /**
  81993. * Gets the current frequency data as a byte array
  81994. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  81995. * @returns a Uint8Array
  81996. */
  81997. getByteFrequencyData(): Uint8Array;
  81998. /**
  81999. * Gets the current waveform as a byte array
  82000. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  82001. * @returns a Uint8Array
  82002. */
  82003. getByteTimeDomainData(): Uint8Array;
  82004. /**
  82005. * Gets the current frequency data as a float array
  82006. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  82007. * @returns a Float32Array
  82008. */
  82009. getFloatFrequencyData(): Float32Array;
  82010. /**
  82011. * Renders the debug canvas
  82012. */
  82013. drawDebugCanvas(): void;
  82014. /**
  82015. * Stops rendering the debug canvas and removes it
  82016. */
  82017. stopDebugCanvas(): void;
  82018. /**
  82019. * Connects two audio nodes
  82020. * @param inputAudioNode defines first node to connect
  82021. * @param outputAudioNode defines second node to connect
  82022. */
  82023. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  82024. /**
  82025. * Releases all associated resources
  82026. */
  82027. dispose(): void;
  82028. }
  82029. }
  82030. declare module BABYLON {
  82031. /**
  82032. * This represents an audio engine and it is responsible
  82033. * to play, synchronize and analyse sounds throughout the application.
  82034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82035. */
  82036. export interface IAudioEngine extends IDisposable {
  82037. /**
  82038. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82039. */
  82040. readonly canUseWebAudio: boolean;
  82041. /**
  82042. * Gets the current AudioContext if available.
  82043. */
  82044. readonly audioContext: Nullable<AudioContext>;
  82045. /**
  82046. * The master gain node defines the global audio volume of your audio engine.
  82047. */
  82048. readonly masterGain: GainNode;
  82049. /**
  82050. * Gets whether or not mp3 are supported by your browser.
  82051. */
  82052. readonly isMP3supported: boolean;
  82053. /**
  82054. * Gets whether or not ogg are supported by your browser.
  82055. */
  82056. readonly isOGGsupported: boolean;
  82057. /**
  82058. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82059. * @ignoreNaming
  82060. */
  82061. WarnedWebAudioUnsupported: boolean;
  82062. /**
  82063. * Defines if the audio engine relies on a custom unlocked button.
  82064. * In this case, the embedded button will not be displayed.
  82065. */
  82066. useCustomUnlockedButton: boolean;
  82067. /**
  82068. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  82069. */
  82070. readonly unlocked: boolean;
  82071. /**
  82072. * Event raised when audio has been unlocked on the browser.
  82073. */
  82074. onAudioUnlockedObservable: Observable<AudioEngine>;
  82075. /**
  82076. * Event raised when audio has been locked on the browser.
  82077. */
  82078. onAudioLockedObservable: Observable<AudioEngine>;
  82079. /**
  82080. * Flags the audio engine in Locked state.
  82081. * This happens due to new browser policies preventing audio to autoplay.
  82082. */
  82083. lock(): void;
  82084. /**
  82085. * Unlocks the audio engine once a user action has been done on the dom.
  82086. * This is helpful to resume play once browser policies have been satisfied.
  82087. */
  82088. unlock(): void;
  82089. }
  82090. /**
  82091. * This represents the default audio engine used in babylon.
  82092. * It is responsible to play, synchronize and analyse sounds throughout the application.
  82093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82094. */
  82095. export class AudioEngine implements IAudioEngine {
  82096. private _audioContext;
  82097. private _audioContextInitialized;
  82098. private _muteButton;
  82099. private _hostElement;
  82100. /**
  82101. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  82102. */
  82103. canUseWebAudio: boolean;
  82104. /**
  82105. * The master gain node defines the global audio volume of your audio engine.
  82106. */
  82107. masterGain: GainNode;
  82108. /**
  82109. * Defines if Babylon should emit a warning if WebAudio is not supported.
  82110. * @ignoreNaming
  82111. */
  82112. WarnedWebAudioUnsupported: boolean;
  82113. /**
  82114. * Gets whether or not mp3 are supported by your browser.
  82115. */
  82116. isMP3supported: boolean;
  82117. /**
  82118. * Gets whether or not ogg are supported by your browser.
  82119. */
  82120. isOGGsupported: boolean;
  82121. /**
  82122. * Gets whether audio has been unlocked on the device.
  82123. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  82124. * a user interaction has happened.
  82125. */
  82126. unlocked: boolean;
  82127. /**
  82128. * Defines if the audio engine relies on a custom unlocked button.
  82129. * In this case, the embedded button will not be displayed.
  82130. */
  82131. useCustomUnlockedButton: boolean;
  82132. /**
  82133. * Event raised when audio has been unlocked on the browser.
  82134. */
  82135. onAudioUnlockedObservable: Observable<AudioEngine>;
  82136. /**
  82137. * Event raised when audio has been locked on the browser.
  82138. */
  82139. onAudioLockedObservable: Observable<AudioEngine>;
  82140. /**
  82141. * Gets the current AudioContext if available.
  82142. */
  82143. readonly audioContext: Nullable<AudioContext>;
  82144. private _connectedAnalyser;
  82145. /**
  82146. * Instantiates a new audio engine.
  82147. *
  82148. * There should be only one per page as some browsers restrict the number
  82149. * of audio contexts you can create.
  82150. * @param hostElement defines the host element where to display the mute icon if necessary
  82151. */
  82152. constructor(hostElement?: Nullable<HTMLElement>);
  82153. /**
  82154. * Flags the audio engine in Locked state.
  82155. * This happens due to new browser policies preventing audio to autoplay.
  82156. */
  82157. lock(): void;
  82158. /**
  82159. * Unlocks the audio engine once a user action has been done on the dom.
  82160. * This is helpful to resume play once browser policies have been satisfied.
  82161. */
  82162. unlock(): void;
  82163. private _resumeAudioContext;
  82164. private _initializeAudioContext;
  82165. private _tryToRun;
  82166. private _triggerRunningState;
  82167. private _triggerSuspendedState;
  82168. private _displayMuteButton;
  82169. private _moveButtonToTopLeft;
  82170. private _onResize;
  82171. private _hideMuteButton;
  82172. /**
  82173. * Destroy and release the resources associated with the audio ccontext.
  82174. */
  82175. dispose(): void;
  82176. /**
  82177. * Gets the global volume sets on the master gain.
  82178. * @returns the global volume if set or -1 otherwise
  82179. */
  82180. getGlobalVolume(): number;
  82181. /**
  82182. * Sets the global volume of your experience (sets on the master gain).
  82183. * @param newVolume Defines the new global volume of the application
  82184. */
  82185. setGlobalVolume(newVolume: number): void;
  82186. /**
  82187. * Connect the audio engine to an audio analyser allowing some amazing
  82188. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  82189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  82190. * @param analyser The analyser to connect to the engine
  82191. */
  82192. connectToAnalyser(analyser: Analyser): void;
  82193. }
  82194. }
  82195. declare module BABYLON {
  82196. /**
  82197. * Interface used to present a loading screen while loading a scene
  82198. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82199. */
  82200. export interface ILoadingScreen {
  82201. /**
  82202. * Function called to display the loading screen
  82203. */
  82204. displayLoadingUI: () => void;
  82205. /**
  82206. * Function called to hide the loading screen
  82207. */
  82208. hideLoadingUI: () => void;
  82209. /**
  82210. * Gets or sets the color to use for the background
  82211. */
  82212. loadingUIBackgroundColor: string;
  82213. /**
  82214. * Gets or sets the text to display while loading
  82215. */
  82216. loadingUIText: string;
  82217. }
  82218. /**
  82219. * Class used for the default loading screen
  82220. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  82221. */
  82222. export class DefaultLoadingScreen implements ILoadingScreen {
  82223. private _renderingCanvas;
  82224. private _loadingText;
  82225. private _loadingDivBackgroundColor;
  82226. private _loadingDiv;
  82227. private _loadingTextDiv;
  82228. /**
  82229. * Creates a new default loading screen
  82230. * @param _renderingCanvas defines the canvas used to render the scene
  82231. * @param _loadingText defines the default text to display
  82232. * @param _loadingDivBackgroundColor defines the default background color
  82233. */
  82234. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  82235. /**
  82236. * Function called to display the loading screen
  82237. */
  82238. displayLoadingUI(): void;
  82239. /**
  82240. * Function called to hide the loading screen
  82241. */
  82242. hideLoadingUI(): void;
  82243. /**
  82244. * Gets or sets the text to display while loading
  82245. */
  82246. loadingUIText: string;
  82247. /**
  82248. * Gets or sets the color to use for the background
  82249. */
  82250. loadingUIBackgroundColor: string;
  82251. private _resizeLoadingUI;
  82252. }
  82253. }
  82254. declare module BABYLON {
  82255. /**
  82256. * Settings for finer control over video usage
  82257. */
  82258. export interface VideoTextureSettings {
  82259. /**
  82260. * Applies `autoplay` to video, if specified
  82261. */
  82262. autoPlay?: boolean;
  82263. /**
  82264. * Applies `loop` to video, if specified
  82265. */
  82266. loop?: boolean;
  82267. /**
  82268. * Automatically updates internal texture from video at every frame in the render loop
  82269. */
  82270. autoUpdateTexture: boolean;
  82271. /**
  82272. * Image src displayed during the video loading or until the user interacts with the video.
  82273. */
  82274. poster?: string;
  82275. }
  82276. /**
  82277. * If you want to display a video in your scene, this is the special texture for that.
  82278. * This special texture works similar to other textures, with the exception of a few parameters.
  82279. * @see https://doc.babylonjs.com/how_to/video_texture
  82280. */
  82281. export class VideoTexture extends Texture {
  82282. /**
  82283. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  82284. */
  82285. readonly autoUpdateTexture: boolean;
  82286. /**
  82287. * The video instance used by the texture internally
  82288. */
  82289. readonly video: HTMLVideoElement;
  82290. private _onUserActionRequestedObservable;
  82291. /**
  82292. * Event triggerd when a dom action is required by the user to play the video.
  82293. * This happens due to recent changes in browser policies preventing video to auto start.
  82294. */
  82295. readonly onUserActionRequestedObservable: Observable<Texture>;
  82296. private _generateMipMaps;
  82297. private _engine;
  82298. private _stillImageCaptured;
  82299. private _displayingPosterTexture;
  82300. private _settings;
  82301. private _createInternalTextureOnEvent;
  82302. /**
  82303. * Creates a video texture.
  82304. * If you want to display a video in your scene, this is the special texture for that.
  82305. * This special texture works similar to other textures, with the exception of a few parameters.
  82306. * @see https://doc.babylonjs.com/how_to/video_texture
  82307. * @param name optional name, will detect from video source, if not defined
  82308. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  82309. * @param scene is obviously the current scene.
  82310. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  82311. * @param invertY is false by default but can be used to invert video on Y axis
  82312. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  82313. * @param settings allows finer control over video usage
  82314. */
  82315. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  82316. private _getName;
  82317. private _getVideo;
  82318. private _createInternalTexture;
  82319. private reset;
  82320. /**
  82321. * @hidden Internal method to initiate `update`.
  82322. */
  82323. _rebuild(): void;
  82324. /**
  82325. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  82326. */
  82327. update(): void;
  82328. /**
  82329. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  82330. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  82331. */
  82332. updateTexture(isVisible: boolean): void;
  82333. protected _updateInternalTexture: () => void;
  82334. /**
  82335. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  82336. * @param url New url.
  82337. */
  82338. updateURL(url: string): void;
  82339. /**
  82340. * Dispose the texture and release its associated resources.
  82341. */
  82342. dispose(): void;
  82343. /**
  82344. * Creates a video texture straight from your WebCam video feed.
  82345. * @param scene Define the scene the texture should be created in
  82346. * @param onReady Define a callback to triggered once the texture will be ready
  82347. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  82348. */
  82349. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  82350. minWidth: number;
  82351. maxWidth: number;
  82352. minHeight: number;
  82353. maxHeight: number;
  82354. deviceId: string;
  82355. }): void;
  82356. }
  82357. }
  82358. declare module BABYLON {
  82359. /**
  82360. * Interface for attribute information associated with buffer instanciation
  82361. */
  82362. export class InstancingAttributeInfo {
  82363. /**
  82364. * Index/offset of the attribute in the vertex shader
  82365. */
  82366. index: number;
  82367. /**
  82368. * size of the attribute, 1, 2, 3 or 4
  82369. */
  82370. attributeSize: number;
  82371. /**
  82372. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  82373. * default is FLOAT
  82374. */
  82375. attribyteType: number;
  82376. /**
  82377. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  82378. */
  82379. normalized: boolean;
  82380. /**
  82381. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  82382. */
  82383. offset: number;
  82384. /**
  82385. * Name of the GLSL attribute, for debugging purpose only
  82386. */
  82387. attributeName: string;
  82388. }
  82389. /**
  82390. * Define options used to create a depth texture
  82391. */
  82392. export class DepthTextureCreationOptions {
  82393. /** Specifies whether or not a stencil should be allocated in the texture */
  82394. generateStencil?: boolean;
  82395. /** Specifies whether or not bilinear filtering is enable on the texture */
  82396. bilinearFiltering?: boolean;
  82397. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  82398. comparisonFunction?: number;
  82399. /** Specifies if the created texture is a cube texture */
  82400. isCube?: boolean;
  82401. }
  82402. /**
  82403. * Class used to describe the capabilities of the engine relatively to the current browser
  82404. */
  82405. export class EngineCapabilities {
  82406. /** Maximum textures units per fragment shader */
  82407. maxTexturesImageUnits: number;
  82408. /** Maximum texture units per vertex shader */
  82409. maxVertexTextureImageUnits: number;
  82410. /** Maximum textures units in the entire pipeline */
  82411. maxCombinedTexturesImageUnits: number;
  82412. /** Maximum texture size */
  82413. maxTextureSize: number;
  82414. /** Maximum cube texture size */
  82415. maxCubemapTextureSize: number;
  82416. /** Maximum render texture size */
  82417. maxRenderTextureSize: number;
  82418. /** Maximum number of vertex attributes */
  82419. maxVertexAttribs: number;
  82420. /** Maximum number of varyings */
  82421. maxVaryingVectors: number;
  82422. /** Maximum number of uniforms per vertex shader */
  82423. maxVertexUniformVectors: number;
  82424. /** Maximum number of uniforms per fragment shader */
  82425. maxFragmentUniformVectors: number;
  82426. /** Defines if standard derivates (dx/dy) are supported */
  82427. standardDerivatives: boolean;
  82428. /** Defines if s3tc texture compression is supported */
  82429. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  82430. /** Defines if pvrtc texture compression is supported */
  82431. pvrtc: any;
  82432. /** Defines if etc1 texture compression is supported */
  82433. etc1: any;
  82434. /** Defines if etc2 texture compression is supported */
  82435. etc2: any;
  82436. /** Defines if astc texture compression is supported */
  82437. astc: any;
  82438. /** Defines if float textures are supported */
  82439. textureFloat: boolean;
  82440. /** Defines if vertex array objects are supported */
  82441. vertexArrayObject: boolean;
  82442. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  82443. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  82444. /** Gets the maximum level of anisotropy supported */
  82445. maxAnisotropy: number;
  82446. /** Defines if instancing is supported */
  82447. instancedArrays: boolean;
  82448. /** Defines if 32 bits indices are supported */
  82449. uintIndices: boolean;
  82450. /** Defines if high precision shaders are supported */
  82451. highPrecisionShaderSupported: boolean;
  82452. /** Defines if depth reading in the fragment shader is supported */
  82453. fragmentDepthSupported: boolean;
  82454. /** Defines if float texture linear filtering is supported*/
  82455. textureFloatLinearFiltering: boolean;
  82456. /** Defines if rendering to float textures is supported */
  82457. textureFloatRender: boolean;
  82458. /** Defines if half float textures are supported*/
  82459. textureHalfFloat: boolean;
  82460. /** Defines if half float texture linear filtering is supported*/
  82461. textureHalfFloatLinearFiltering: boolean;
  82462. /** Defines if rendering to half float textures is supported */
  82463. textureHalfFloatRender: boolean;
  82464. /** Defines if textureLOD shader command is supported */
  82465. textureLOD: boolean;
  82466. /** Defines if draw buffers extension is supported */
  82467. drawBuffersExtension: boolean;
  82468. /** Defines if depth textures are supported */
  82469. depthTextureExtension: boolean;
  82470. /** Defines if float color buffer are supported */
  82471. colorBufferFloat: boolean;
  82472. /** Gets disjoint timer query extension (null if not supported) */
  82473. timerQuery: EXT_disjoint_timer_query;
  82474. /** Defines if timestamp can be used with timer query */
  82475. canUseTimestampForTimerQuery: boolean;
  82476. /** Function used to let the system compiles shaders in background */
  82477. parallelShaderCompile: {
  82478. MAX_SHADER_COMPILER_THREADS_KHR: number;
  82479. maxShaderCompilerThreadsKHR: (thread: number) => void;
  82480. COMPLETION_STATUS_KHR: number;
  82481. };
  82482. }
  82483. /** Interface defining initialization parameters for Engine class */
  82484. export interface EngineOptions extends WebGLContextAttributes {
  82485. /**
  82486. * Defines if the engine should no exceed a specified device ratio
  82487. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  82488. */
  82489. limitDeviceRatio?: number;
  82490. /**
  82491. * Defines if webvr should be enabled automatically
  82492. * @see http://doc.babylonjs.com/how_to/webvr_camera
  82493. */
  82494. autoEnableWebVR?: boolean;
  82495. /**
  82496. * Defines if webgl2 should be turned off even if supported
  82497. * @see http://doc.babylonjs.com/features/webgl2
  82498. */
  82499. disableWebGL2Support?: boolean;
  82500. /**
  82501. * Defines if webaudio should be initialized as well
  82502. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82503. */
  82504. audioEngine?: boolean;
  82505. /**
  82506. * Defines if animations should run using a deterministic lock step
  82507. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  82508. */
  82509. deterministicLockstep?: boolean;
  82510. /** Defines the maximum steps to use with deterministic lock step mode */
  82511. lockstepMaxSteps?: number;
  82512. /**
  82513. * Defines that engine should ignore context lost events
  82514. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  82515. */
  82516. doNotHandleContextLost?: boolean;
  82517. /**
  82518. * Defines that engine should ignore modifying touch action attribute and style
  82519. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  82520. */
  82521. doNotHandleTouchAction?: boolean;
  82522. }
  82523. /**
  82524. * Defines the interface used by display changed events
  82525. */
  82526. export interface IDisplayChangedEventArgs {
  82527. /** Gets the vrDisplay object (if any) */
  82528. vrDisplay: Nullable<any>;
  82529. /** Gets a boolean indicating if webVR is supported */
  82530. vrSupported: boolean;
  82531. }
  82532. /**
  82533. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  82534. */
  82535. export class Engine {
  82536. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  82537. static ExceptionList: ({
  82538. key: string;
  82539. capture: string;
  82540. captureConstraint: number;
  82541. targets: string[];
  82542. } | {
  82543. key: string;
  82544. capture: null;
  82545. captureConstraint: null;
  82546. targets: string[];
  82547. })[];
  82548. /** Gets the list of created engines */
  82549. static readonly Instances: Engine[];
  82550. /**
  82551. * Gets the latest created engine
  82552. */
  82553. static readonly LastCreatedEngine: Nullable<Engine>;
  82554. /**
  82555. * Gets the latest created scene
  82556. */
  82557. static readonly LastCreatedScene: Nullable<Scene>;
  82558. /**
  82559. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  82560. * @param flag defines which part of the materials must be marked as dirty
  82561. * @param predicate defines a predicate used to filter which materials should be affected
  82562. */
  82563. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  82564. /**
  82565. * Hidden
  82566. */
  82567. static _TextureLoaders: IInternalTextureLoader[];
  82568. /** Defines that alpha blending is disabled */
  82569. static readonly ALPHA_DISABLE: number;
  82570. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  82571. static readonly ALPHA_ADD: number;
  82572. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  82573. static readonly ALPHA_COMBINE: number;
  82574. /** Defines that alpha blending to DEST - SRC * DEST */
  82575. static readonly ALPHA_SUBTRACT: number;
  82576. /** Defines that alpha blending to SRC * DEST */
  82577. static readonly ALPHA_MULTIPLY: number;
  82578. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  82579. static readonly ALPHA_MAXIMIZED: number;
  82580. /** Defines that alpha blending to SRC + DEST */
  82581. static readonly ALPHA_ONEONE: number;
  82582. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  82583. static readonly ALPHA_PREMULTIPLIED: number;
  82584. /**
  82585. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  82586. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  82587. */
  82588. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  82589. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  82590. static readonly ALPHA_INTERPOLATE: number;
  82591. /**
  82592. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  82593. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  82594. */
  82595. static readonly ALPHA_SCREENMODE: number;
  82596. /** Defines that the ressource is not delayed*/
  82597. static readonly DELAYLOADSTATE_NONE: number;
  82598. /** Defines that the ressource was successfully delay loaded */
  82599. static readonly DELAYLOADSTATE_LOADED: number;
  82600. /** Defines that the ressource is currently delay loading */
  82601. static readonly DELAYLOADSTATE_LOADING: number;
  82602. /** Defines that the ressource is delayed and has not started loading */
  82603. static readonly DELAYLOADSTATE_NOTLOADED: number;
  82604. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  82605. static readonly NEVER: number;
  82606. /** 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 */
  82607. static readonly ALWAYS: number;
  82608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  82609. static readonly LESS: number;
  82610. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  82611. static readonly EQUAL: number;
  82612. /** 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 */
  82613. static readonly LEQUAL: number;
  82614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  82615. static readonly GREATER: number;
  82616. /** 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 */
  82617. static readonly GEQUAL: number;
  82618. /** 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 */
  82619. static readonly NOTEQUAL: number;
  82620. /** Passed to stencilOperation to specify that stencil value must be kept */
  82621. static readonly KEEP: number;
  82622. /** Passed to stencilOperation to specify that stencil value must be replaced */
  82623. static readonly REPLACE: number;
  82624. /** Passed to stencilOperation to specify that stencil value must be incremented */
  82625. static readonly INCR: number;
  82626. /** Passed to stencilOperation to specify that stencil value must be decremented */
  82627. static readonly DECR: number;
  82628. /** Passed to stencilOperation to specify that stencil value must be inverted */
  82629. static readonly INVERT: number;
  82630. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  82631. static readonly INCR_WRAP: number;
  82632. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  82633. static readonly DECR_WRAP: number;
  82634. /** Texture is not repeating outside of 0..1 UVs */
  82635. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  82636. /** Texture is repeating outside of 0..1 UVs */
  82637. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  82638. /** Texture is repeating and mirrored */
  82639. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  82640. /** ALPHA */
  82641. static readonly TEXTUREFORMAT_ALPHA: number;
  82642. /** LUMINANCE */
  82643. static readonly TEXTUREFORMAT_LUMINANCE: number;
  82644. /** LUMINANCE_ALPHA */
  82645. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  82646. /** RGB */
  82647. static readonly TEXTUREFORMAT_RGB: number;
  82648. /** RGBA */
  82649. static readonly TEXTUREFORMAT_RGBA: number;
  82650. /** RED */
  82651. static readonly TEXTUREFORMAT_RED: number;
  82652. /** RED (2nd reference) */
  82653. static readonly TEXTUREFORMAT_R: number;
  82654. /** RG */
  82655. static readonly TEXTUREFORMAT_RG: number;
  82656. /** RED_INTEGER */
  82657. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  82658. /** RED_INTEGER (2nd reference) */
  82659. static readonly TEXTUREFORMAT_R_INTEGER: number;
  82660. /** RG_INTEGER */
  82661. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  82662. /** RGB_INTEGER */
  82663. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  82664. /** RGBA_INTEGER */
  82665. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  82666. /** UNSIGNED_BYTE */
  82667. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  82668. /** UNSIGNED_BYTE (2nd reference) */
  82669. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  82670. /** FLOAT */
  82671. static readonly TEXTURETYPE_FLOAT: number;
  82672. /** HALF_FLOAT */
  82673. static readonly TEXTURETYPE_HALF_FLOAT: number;
  82674. /** BYTE */
  82675. static readonly TEXTURETYPE_BYTE: number;
  82676. /** SHORT */
  82677. static readonly TEXTURETYPE_SHORT: number;
  82678. /** UNSIGNED_SHORT */
  82679. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  82680. /** INT */
  82681. static readonly TEXTURETYPE_INT: number;
  82682. /** UNSIGNED_INT */
  82683. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  82684. /** UNSIGNED_SHORT_4_4_4_4 */
  82685. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  82686. /** UNSIGNED_SHORT_5_5_5_1 */
  82687. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  82688. /** UNSIGNED_SHORT_5_6_5 */
  82689. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  82690. /** UNSIGNED_INT_2_10_10_10_REV */
  82691. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  82692. /** UNSIGNED_INT_24_8 */
  82693. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  82694. /** UNSIGNED_INT_10F_11F_11F_REV */
  82695. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  82696. /** UNSIGNED_INT_5_9_9_9_REV */
  82697. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  82698. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  82699. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  82700. /** nearest is mag = nearest and min = nearest and mip = linear */
  82701. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  82702. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82703. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  82704. /** Trilinear is mag = linear and min = linear and mip = linear */
  82705. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  82706. /** nearest is mag = nearest and min = nearest and mip = linear */
  82707. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  82708. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82709. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  82710. /** Trilinear is mag = linear and min = linear and mip = linear */
  82711. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  82712. /** mag = nearest and min = nearest and mip = nearest */
  82713. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  82714. /** mag = nearest and min = linear and mip = nearest */
  82715. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  82716. /** mag = nearest and min = linear and mip = linear */
  82717. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  82718. /** mag = nearest and min = linear and mip = none */
  82719. static readonly TEXTURE_NEAREST_LINEAR: number;
  82720. /** mag = nearest and min = nearest and mip = none */
  82721. static readonly TEXTURE_NEAREST_NEAREST: number;
  82722. /** mag = linear and min = nearest and mip = nearest */
  82723. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  82724. /** mag = linear and min = nearest and mip = linear */
  82725. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  82726. /** mag = linear and min = linear and mip = none */
  82727. static readonly TEXTURE_LINEAR_LINEAR: number;
  82728. /** mag = linear and min = nearest and mip = none */
  82729. static readonly TEXTURE_LINEAR_NEAREST: number;
  82730. /** Explicit coordinates mode */
  82731. static readonly TEXTURE_EXPLICIT_MODE: number;
  82732. /** Spherical coordinates mode */
  82733. static readonly TEXTURE_SPHERICAL_MODE: number;
  82734. /** Planar coordinates mode */
  82735. static readonly TEXTURE_PLANAR_MODE: number;
  82736. /** Cubic coordinates mode */
  82737. static readonly TEXTURE_CUBIC_MODE: number;
  82738. /** Projection coordinates mode */
  82739. static readonly TEXTURE_PROJECTION_MODE: number;
  82740. /** Skybox coordinates mode */
  82741. static readonly TEXTURE_SKYBOX_MODE: number;
  82742. /** Inverse Cubic coordinates mode */
  82743. static readonly TEXTURE_INVCUBIC_MODE: number;
  82744. /** Equirectangular coordinates mode */
  82745. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  82746. /** Equirectangular Fixed coordinates mode */
  82747. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  82748. /** Equirectangular Fixed Mirrored coordinates mode */
  82749. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82750. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  82751. static readonly SCALEMODE_FLOOR: number;
  82752. /** Defines that texture rescaling will look for the nearest power of 2 size */
  82753. static readonly SCALEMODE_NEAREST: number;
  82754. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  82755. static readonly SCALEMODE_CEILING: number;
  82756. /**
  82757. * Returns the current version of the framework
  82758. */
  82759. static readonly Version: string;
  82760. /**
  82761. * Returns a string describing the current engine
  82762. */
  82763. readonly description: string;
  82764. /**
  82765. * Gets or sets the epsilon value used by collision engine
  82766. */
  82767. static CollisionsEpsilon: number;
  82768. /**
  82769. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  82770. */
  82771. static ShadersRepository: string;
  82772. /**
  82773. * Method called to create the default loading screen.
  82774. * This can be overriden in your own app.
  82775. * @param canvas The rendering canvas element
  82776. * @returns The loading screen
  82777. */
  82778. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  82779. /**
  82780. * Method called to create the default rescale post process on each engine.
  82781. */
  82782. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  82783. /**
  82784. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  82785. */
  82786. forcePOTTextures: boolean;
  82787. /**
  82788. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  82789. */
  82790. isFullscreen: boolean;
  82791. /**
  82792. * Gets a boolean indicating if the pointer is currently locked
  82793. */
  82794. isPointerLock: boolean;
  82795. /**
  82796. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  82797. */
  82798. cullBackFaces: boolean;
  82799. /**
  82800. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  82801. */
  82802. renderEvenInBackground: boolean;
  82803. /**
  82804. * Gets or sets a boolean indicating that cache can be kept between frames
  82805. */
  82806. preventCacheWipeBetweenFrames: boolean;
  82807. /**
  82808. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  82809. **/
  82810. enableOfflineSupport: boolean;
  82811. /**
  82812. * 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)
  82813. **/
  82814. disableManifestCheck: boolean;
  82815. /**
  82816. * Gets the list of created scenes
  82817. */
  82818. scenes: Scene[];
  82819. /**
  82820. * Event raised when a new scene is created
  82821. */
  82822. onNewSceneAddedObservable: Observable<Scene>;
  82823. /**
  82824. * Gets the list of created postprocesses
  82825. */
  82826. postProcesses: PostProcess[];
  82827. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  82828. validateShaderPrograms: boolean;
  82829. /**
  82830. * Observable event triggered each time the rendering canvas is resized
  82831. */
  82832. onResizeObservable: Observable<Engine>;
  82833. /**
  82834. * Observable event triggered each time the canvas loses focus
  82835. */
  82836. onCanvasBlurObservable: Observable<Engine>;
  82837. /**
  82838. * Observable event triggered each time the canvas gains focus
  82839. */
  82840. onCanvasFocusObservable: Observable<Engine>;
  82841. /**
  82842. * Observable event triggered each time the canvas receives pointerout event
  82843. */
  82844. onCanvasPointerOutObservable: Observable<PointerEvent>;
  82845. /**
  82846. * Observable event triggered before each texture is initialized
  82847. */
  82848. onBeforeTextureInitObservable: Observable<Texture>;
  82849. private _vrDisplay;
  82850. private _vrSupported;
  82851. private _oldSize;
  82852. private _oldHardwareScaleFactor;
  82853. private _vrExclusivePointerMode;
  82854. private _webVRInitPromise;
  82855. /**
  82856. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  82857. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  82858. */
  82859. readonly isInVRExclusivePointerMode: boolean;
  82860. /**
  82861. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  82862. */
  82863. disableUniformBuffers: boolean;
  82864. /** @hidden */
  82865. _uniformBuffers: UniformBuffer[];
  82866. /**
  82867. * Gets a boolean indicating that the engine supports uniform buffers
  82868. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  82869. */
  82870. readonly supportsUniformBuffers: boolean;
  82871. /**
  82872. * Observable raised when the engine begins a new frame
  82873. */
  82874. onBeginFrameObservable: Observable<Engine>;
  82875. /**
  82876. * If set, will be used to request the next animation frame for the render loop
  82877. */
  82878. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  82879. /**
  82880. * Observable raised when the engine ends the current frame
  82881. */
  82882. onEndFrameObservable: Observable<Engine>;
  82883. /**
  82884. * Observable raised when the engine is about to compile a shader
  82885. */
  82886. onBeforeShaderCompilationObservable: Observable<Engine>;
  82887. /**
  82888. * Observable raised when the engine has jsut compiled a shader
  82889. */
  82890. onAfterShaderCompilationObservable: Observable<Engine>;
  82891. /** @hidden */
  82892. _gl: WebGLRenderingContext;
  82893. private _renderingCanvas;
  82894. private _windowIsBackground;
  82895. private _webGLVersion;
  82896. /**
  82897. * Gets a boolean indicating that only power of 2 textures are supported
  82898. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  82899. */
  82900. readonly needPOTTextures: boolean;
  82901. /** @hidden */
  82902. _badOS: boolean;
  82903. /** @hidden */
  82904. _badDesktopOS: boolean;
  82905. /**
  82906. * Gets or sets a value indicating if we want to disable texture binding optimization.
  82907. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  82908. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  82909. */
  82910. disableTextureBindingOptimization: boolean;
  82911. /**
  82912. * Gets the audio engine
  82913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  82914. * @ignorenaming
  82915. */
  82916. static audioEngine: IAudioEngine;
  82917. /**
  82918. * Default AudioEngine factory responsible of creating the Audio Engine.
  82919. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  82920. */
  82921. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  82922. /**
  82923. * Default offline support factory responsible of creating a tool used to store data locally.
  82924. * By default, this will create a Database object if the workload has been embedded.
  82925. */
  82926. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  82927. private _onFocus;
  82928. private _onBlur;
  82929. private _onCanvasPointerOut;
  82930. private _onCanvasBlur;
  82931. private _onCanvasFocus;
  82932. private _onFullscreenChange;
  82933. private _onPointerLockChange;
  82934. private _onVRDisplayPointerRestricted;
  82935. private _onVRDisplayPointerUnrestricted;
  82936. private _onVrDisplayConnect;
  82937. private _onVrDisplayDisconnect;
  82938. private _onVrDisplayPresentChange;
  82939. /**
  82940. * Observable signaled when VR display mode changes
  82941. */
  82942. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  82943. /**
  82944. * Observable signaled when VR request present is complete
  82945. */
  82946. onVRRequestPresentComplete: Observable<boolean>;
  82947. /**
  82948. * Observable signaled when VR request present starts
  82949. */
  82950. onVRRequestPresentStart: Observable<Engine>;
  82951. private _hardwareScalingLevel;
  82952. /** @hidden */
  82953. protected _caps: EngineCapabilities;
  82954. private _pointerLockRequested;
  82955. private _isStencilEnable;
  82956. private _colorWrite;
  82957. private _loadingScreen;
  82958. /** @hidden */
  82959. _drawCalls: PerfCounter;
  82960. /** @hidden */
  82961. _textureCollisions: PerfCounter;
  82962. private _glVersion;
  82963. private _glRenderer;
  82964. private _glVendor;
  82965. private _videoTextureSupported;
  82966. private _renderingQueueLaunched;
  82967. private _activeRenderLoops;
  82968. private _deterministicLockstep;
  82969. private _lockstepMaxSteps;
  82970. /**
  82971. * Observable signaled when a context lost event is raised
  82972. */
  82973. onContextLostObservable: Observable<Engine>;
  82974. /**
  82975. * Observable signaled when a context restored event is raised
  82976. */
  82977. onContextRestoredObservable: Observable<Engine>;
  82978. private _onContextLost;
  82979. private _onContextRestored;
  82980. private _contextWasLost;
  82981. private _doNotHandleContextLost;
  82982. /**
  82983. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  82984. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  82985. */
  82986. doNotHandleContextLost: boolean;
  82987. private _performanceMonitor;
  82988. private _fps;
  82989. private _deltaTime;
  82990. /**
  82991. * Turn this value on if you want to pause FPS computation when in background
  82992. */
  82993. disablePerformanceMonitorInBackground: boolean;
  82994. /**
  82995. * Gets the performance monitor attached to this engine
  82996. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  82997. */
  82998. readonly performanceMonitor: PerformanceMonitor;
  82999. /** @hidden */
  83000. protected _depthCullingState: _DepthCullingState;
  83001. /** @hidden */
  83002. protected _stencilState: _StencilState;
  83003. /** @hidden */
  83004. protected _alphaState: _AlphaState;
  83005. /** @hidden */
  83006. protected _alphaMode: number;
  83007. protected _internalTexturesCache: InternalTexture[];
  83008. /** @hidden */
  83009. protected _activeChannel: number;
  83010. private _currentTextureChannel;
  83011. /** @hidden */
  83012. protected _boundTexturesCache: {
  83013. [key: string]: Nullable<InternalTexture>;
  83014. };
  83015. /** @hidden */
  83016. protected _currentEffect: Nullable<Effect>;
  83017. /** @hidden */
  83018. protected _currentProgram: Nullable<WebGLProgram>;
  83019. private _compiledEffects;
  83020. private _vertexAttribArraysEnabled;
  83021. /** @hidden */
  83022. protected _cachedViewport: Nullable<Viewport>;
  83023. private _cachedVertexArrayObject;
  83024. /** @hidden */
  83025. protected _cachedVertexBuffers: any;
  83026. /** @hidden */
  83027. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  83028. /** @hidden */
  83029. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  83030. /** @hidden */
  83031. protected _currentRenderTarget: Nullable<InternalTexture>;
  83032. private _uintIndicesCurrentlySet;
  83033. private _currentBoundBuffer;
  83034. /** @hidden */
  83035. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  83036. private _currentBufferPointers;
  83037. private _currentInstanceLocations;
  83038. private _currentInstanceBuffers;
  83039. private _textureUnits;
  83040. private _firstBoundInternalTextureTracker;
  83041. private _lastBoundInternalTextureTracker;
  83042. private _workingCanvas;
  83043. private _workingContext;
  83044. private _rescalePostProcess;
  83045. private _dummyFramebuffer;
  83046. private _externalData;
  83047. private _bindedRenderFunction;
  83048. private _vaoRecordInProgress;
  83049. private _mustWipeVertexAttributes;
  83050. private _emptyTexture;
  83051. private _emptyCubeTexture;
  83052. private _emptyTexture3D;
  83053. /** @hidden */
  83054. _frameHandler: number;
  83055. private _nextFreeTextureSlots;
  83056. private _maxSimultaneousTextures;
  83057. private _activeRequests;
  83058. private _texturesSupported;
  83059. private _textureFormatInUse;
  83060. /**
  83061. * Gets the list of texture formats supported
  83062. */
  83063. readonly texturesSupported: Array<string>;
  83064. /**
  83065. * Gets the list of texture formats in use
  83066. */
  83067. readonly textureFormatInUse: Nullable<string>;
  83068. /**
  83069. * Gets the current viewport
  83070. */
  83071. readonly currentViewport: Nullable<Viewport>;
  83072. /**
  83073. * Gets the default empty texture
  83074. */
  83075. readonly emptyTexture: InternalTexture;
  83076. /**
  83077. * Gets the default empty 3D texture
  83078. */
  83079. readonly emptyTexture3D: InternalTexture;
  83080. /**
  83081. * Gets the default empty cube texture
  83082. */
  83083. readonly emptyCubeTexture: InternalTexture;
  83084. /**
  83085. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  83086. */
  83087. readonly premultipliedAlpha: boolean;
  83088. /**
  83089. * Creates a new engine
  83090. * @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
  83091. * @param antialias defines enable antialiasing (default: false)
  83092. * @param options defines further options to be sent to the getContext() function
  83093. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  83094. */
  83095. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  83096. private _disableTouchAction;
  83097. private _rebuildInternalTextures;
  83098. private _rebuildEffects;
  83099. /**
  83100. * Gets a boolean indicating if all created effects are ready
  83101. * @returns true if all effects are ready
  83102. */
  83103. areAllEffectsReady(): boolean;
  83104. private _rebuildBuffers;
  83105. private _initGLContext;
  83106. /**
  83107. * Gets version of the current webGL context
  83108. */
  83109. readonly webGLVersion: number;
  83110. /**
  83111. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  83112. */
  83113. readonly isStencilEnable: boolean;
  83114. private _prepareWorkingCanvas;
  83115. /**
  83116. * Reset the texture cache to empty state
  83117. */
  83118. resetTextureCache(): void;
  83119. /**
  83120. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  83121. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83122. * @returns true if engine is in deterministic lock step mode
  83123. */
  83124. isDeterministicLockStep(): boolean;
  83125. /**
  83126. * Gets the max steps when engine is running in deterministic lock step
  83127. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  83128. * @returns the max steps
  83129. */
  83130. getLockstepMaxSteps(): number;
  83131. /**
  83132. * Gets an object containing information about the current webGL context
  83133. * @returns an object containing the vender, the renderer and the version of the current webGL context
  83134. */
  83135. getGlInfo(): {
  83136. vendor: string;
  83137. renderer: string;
  83138. version: string;
  83139. };
  83140. /**
  83141. * Gets current aspect ratio
  83142. * @param camera defines the camera to use to get the aspect ratio
  83143. * @param useScreen defines if screen size must be used (or the current render target if any)
  83144. * @returns a number defining the aspect ratio
  83145. */
  83146. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  83147. /**
  83148. * Gets current screen aspect ratio
  83149. * @returns a number defining the aspect ratio
  83150. */
  83151. getScreenAspectRatio(): number;
  83152. /**
  83153. * Gets the current render width
  83154. * @param useScreen defines if screen size must be used (or the current render target if any)
  83155. * @returns a number defining the current render width
  83156. */
  83157. getRenderWidth(useScreen?: boolean): number;
  83158. /**
  83159. * Gets the current render height
  83160. * @param useScreen defines if screen size must be used (or the current render target if any)
  83161. * @returns a number defining the current render height
  83162. */
  83163. getRenderHeight(useScreen?: boolean): number;
  83164. /**
  83165. * Gets the HTML canvas attached with the current webGL context
  83166. * @returns a HTML canvas
  83167. */
  83168. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  83169. /**
  83170. * Gets the client rect of the HTML canvas attached with the current webGL context
  83171. * @returns a client rectanglee
  83172. */
  83173. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  83174. /**
  83175. * Defines the hardware scaling level.
  83176. * By default the hardware scaling level is computed from the window device ratio.
  83177. * 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.
  83178. * @param level defines the level to use
  83179. */
  83180. setHardwareScalingLevel(level: number): void;
  83181. /**
  83182. * Gets the current hardware scaling level.
  83183. * By default the hardware scaling level is computed from the window device ratio.
  83184. * 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.
  83185. * @returns a number indicating the current hardware scaling level
  83186. */
  83187. getHardwareScalingLevel(): number;
  83188. /**
  83189. * Gets the list of loaded textures
  83190. * @returns an array containing all loaded textures
  83191. */
  83192. getLoadedTexturesCache(): InternalTexture[];
  83193. /**
  83194. * Gets the object containing all engine capabilities
  83195. * @returns the EngineCapabilities object
  83196. */
  83197. getCaps(): EngineCapabilities;
  83198. /**
  83199. * Gets the current depth function
  83200. * @returns a number defining the depth function
  83201. */
  83202. getDepthFunction(): Nullable<number>;
  83203. /**
  83204. * Sets the current depth function
  83205. * @param depthFunc defines the function to use
  83206. */
  83207. setDepthFunction(depthFunc: number): void;
  83208. /**
  83209. * Sets the current depth function to GREATER
  83210. */
  83211. setDepthFunctionToGreater(): void;
  83212. /**
  83213. * Sets the current depth function to GEQUAL
  83214. */
  83215. setDepthFunctionToGreaterOrEqual(): void;
  83216. /**
  83217. * Sets the current depth function to LESS
  83218. */
  83219. setDepthFunctionToLess(): void;
  83220. /**
  83221. * Sets the current depth function to LEQUAL
  83222. */
  83223. setDepthFunctionToLessOrEqual(): void;
  83224. /**
  83225. * Gets a boolean indicating if stencil buffer is enabled
  83226. * @returns the current stencil buffer state
  83227. */
  83228. getStencilBuffer(): boolean;
  83229. /**
  83230. * Enable or disable the stencil buffer
  83231. * @param enable defines if the stencil buffer must be enabled or disabled
  83232. */
  83233. setStencilBuffer(enable: boolean): void;
  83234. /**
  83235. * Gets the current stencil mask
  83236. * @returns a number defining the new stencil mask to use
  83237. */
  83238. getStencilMask(): number;
  83239. /**
  83240. * Sets the current stencil mask
  83241. * @param mask defines the new stencil mask to use
  83242. */
  83243. setStencilMask(mask: number): void;
  83244. /**
  83245. * Gets the current stencil function
  83246. * @returns a number defining the stencil function to use
  83247. */
  83248. getStencilFunction(): number;
  83249. /**
  83250. * Gets the current stencil reference value
  83251. * @returns a number defining the stencil reference value to use
  83252. */
  83253. getStencilFunctionReference(): number;
  83254. /**
  83255. * Gets the current stencil mask
  83256. * @returns a number defining the stencil mask to use
  83257. */
  83258. getStencilFunctionMask(): number;
  83259. /**
  83260. * Sets the current stencil function
  83261. * @param stencilFunc defines the new stencil function to use
  83262. */
  83263. setStencilFunction(stencilFunc: number): void;
  83264. /**
  83265. * Sets the current stencil reference
  83266. * @param reference defines the new stencil reference to use
  83267. */
  83268. setStencilFunctionReference(reference: number): void;
  83269. /**
  83270. * Sets the current stencil mask
  83271. * @param mask defines the new stencil mask to use
  83272. */
  83273. setStencilFunctionMask(mask: number): void;
  83274. /**
  83275. * Gets the current stencil operation when stencil fails
  83276. * @returns a number defining stencil operation to use when stencil fails
  83277. */
  83278. getStencilOperationFail(): number;
  83279. /**
  83280. * Gets the current stencil operation when depth fails
  83281. * @returns a number defining stencil operation to use when depth fails
  83282. */
  83283. getStencilOperationDepthFail(): number;
  83284. /**
  83285. * Gets the current stencil operation when stencil passes
  83286. * @returns a number defining stencil operation to use when stencil passes
  83287. */
  83288. getStencilOperationPass(): number;
  83289. /**
  83290. * Sets the stencil operation to use when stencil fails
  83291. * @param operation defines the stencil operation to use when stencil fails
  83292. */
  83293. setStencilOperationFail(operation: number): void;
  83294. /**
  83295. * Sets the stencil operation to use when depth fails
  83296. * @param operation defines the stencil operation to use when depth fails
  83297. */
  83298. setStencilOperationDepthFail(operation: number): void;
  83299. /**
  83300. * Sets the stencil operation to use when stencil passes
  83301. * @param operation defines the stencil operation to use when stencil passes
  83302. */
  83303. setStencilOperationPass(operation: number): void;
  83304. /**
  83305. * Sets a boolean indicating if the dithering state is enabled or disabled
  83306. * @param value defines the dithering state
  83307. */
  83308. setDitheringState(value: boolean): void;
  83309. /**
  83310. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  83311. * @param value defines the rasterizer state
  83312. */
  83313. setRasterizerState(value: boolean): void;
  83314. /**
  83315. * stop executing a render loop function and remove it from the execution array
  83316. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  83317. */
  83318. stopRenderLoop(renderFunction?: () => void): void;
  83319. /** @hidden */
  83320. _renderLoop(): void;
  83321. /**
  83322. * Register and execute a render loop. The engine can have more than one render function
  83323. * @param renderFunction defines the function to continuously execute
  83324. */
  83325. runRenderLoop(renderFunction: () => void): void;
  83326. /**
  83327. * Toggle full screen mode
  83328. * @param requestPointerLock defines if a pointer lock should be requested from the user
  83329. */
  83330. switchFullscreen(requestPointerLock: boolean): void;
  83331. /**
  83332. * Clear the current render buffer or the current render target (if any is set up)
  83333. * @param color defines the color to use
  83334. * @param backBuffer defines if the back buffer must be cleared
  83335. * @param depth defines if the depth buffer must be cleared
  83336. * @param stencil defines if the stencil buffer must be cleared
  83337. */
  83338. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  83339. /**
  83340. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  83341. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83342. * @param y defines the y-coordinate of the corner of the clear rectangle
  83343. * @param width defines the width of the clear rectangle
  83344. * @param height defines the height of the clear rectangle
  83345. * @param clearColor defines the clear color
  83346. */
  83347. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  83348. /**
  83349. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  83350. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  83351. * @param y defines the y-coordinate of the corner of the clear rectangle
  83352. * @param width defines the width of the clear rectangle
  83353. * @param height defines the height of the clear rectangle
  83354. */
  83355. enableScissor(x: number, y: number, width: number, height: number): void;
  83356. /**
  83357. * Disable previously set scissor test rectangle
  83358. */
  83359. disableScissor(): void;
  83360. private _viewportCached;
  83361. /** @hidden */
  83362. _viewport(x: number, y: number, width: number, height: number): void;
  83363. /**
  83364. * Set the WebGL's viewport
  83365. * @param viewport defines the viewport element to be used
  83366. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  83367. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  83368. */
  83369. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  83370. /**
  83371. * Directly set the WebGL Viewport
  83372. * @param x defines the x coordinate of the viewport (in screen space)
  83373. * @param y defines the y coordinate of the viewport (in screen space)
  83374. * @param width defines the width of the viewport (in screen space)
  83375. * @param height defines the height of the viewport (in screen space)
  83376. * @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
  83377. */
  83378. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  83379. /**
  83380. * Begin a new frame
  83381. */
  83382. beginFrame(): void;
  83383. /**
  83384. * Enf the current frame
  83385. */
  83386. endFrame(): void;
  83387. /**
  83388. * Resize the view according to the canvas' size
  83389. */
  83390. resize(): void;
  83391. /**
  83392. * Force a specific size of the canvas
  83393. * @param width defines the new canvas' width
  83394. * @param height defines the new canvas' height
  83395. */
  83396. setSize(width: number, height: number): void;
  83397. /**
  83398. * Gets a boolean indicating if a webVR device was detected
  83399. * @returns true if a webVR device was detected
  83400. */
  83401. isVRDevicePresent(): boolean;
  83402. /**
  83403. * Gets the current webVR device
  83404. * @returns the current webVR device (or null)
  83405. */
  83406. getVRDevice(): any;
  83407. /**
  83408. * Initializes a webVR display and starts listening to display change events
  83409. * The onVRDisplayChangedObservable will be notified upon these changes
  83410. * @returns The onVRDisplayChangedObservable
  83411. */
  83412. initWebVR(): Observable<IDisplayChangedEventArgs>;
  83413. /**
  83414. * Initializes a webVR display and starts listening to display change events
  83415. * The onVRDisplayChangedObservable will be notified upon these changes
  83416. * @returns A promise containing a VRDisplay and if vr is supported
  83417. */
  83418. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  83419. /**
  83420. * Call this function to switch to webVR mode
  83421. * Will do nothing if webVR is not supported or if there is no webVR device
  83422. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83423. */
  83424. enableVR(): void;
  83425. /**
  83426. * Call this function to leave webVR mode
  83427. * Will do nothing if webVR is not supported or if there is no webVR device
  83428. * @see http://doc.babylonjs.com/how_to/webvr_camera
  83429. */
  83430. disableVR(): void;
  83431. private _onVRFullScreenTriggered;
  83432. private _getVRDisplaysAsync;
  83433. /**
  83434. * Binds the frame buffer to the specified texture.
  83435. * @param texture The texture to render to or null for the default canvas
  83436. * @param faceIndex The face of the texture to render to in case of cube texture
  83437. * @param requiredWidth The width of the target to render to
  83438. * @param requiredHeight The height of the target to render to
  83439. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  83440. * @param depthStencilTexture The depth stencil texture to use to render
  83441. * @param lodLevel defines le lod level to bind to the frame buffer
  83442. */
  83443. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  83444. private bindUnboundFramebuffer;
  83445. /**
  83446. * Unbind the current render target texture from the webGL context
  83447. * @param texture defines the render target texture to unbind
  83448. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83449. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83450. */
  83451. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83452. /**
  83453. * Unbind a list of render target textures from the webGL context
  83454. * This is used only when drawBuffer extension or webGL2 are active
  83455. * @param textures defines the render target textures to unbind
  83456. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  83457. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  83458. */
  83459. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  83460. /**
  83461. * Force the mipmap generation for the given render target texture
  83462. * @param texture defines the render target texture to use
  83463. */
  83464. generateMipMapsForCubemap(texture: InternalTexture): void;
  83465. /**
  83466. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  83467. */
  83468. flushFramebuffer(): void;
  83469. /**
  83470. * Unbind the current render target and bind the default framebuffer
  83471. */
  83472. restoreDefaultFramebuffer(): void;
  83473. /**
  83474. * Create an uniform buffer
  83475. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83476. * @param elements defines the content of the uniform buffer
  83477. * @returns the webGL uniform buffer
  83478. */
  83479. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  83480. /**
  83481. * Create a dynamic uniform buffer
  83482. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83483. * @param elements defines the content of the uniform buffer
  83484. * @returns the webGL uniform buffer
  83485. */
  83486. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  83487. /**
  83488. * Update an existing uniform buffer
  83489. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  83490. * @param uniformBuffer defines the target uniform buffer
  83491. * @param elements defines the content to update
  83492. * @param offset defines the offset in the uniform buffer where update should start
  83493. * @param count defines the size of the data to update
  83494. */
  83495. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  83496. private _resetVertexBufferBinding;
  83497. /**
  83498. * Creates a vertex buffer
  83499. * @param data the data for the vertex buffer
  83500. * @returns the new WebGL static buffer
  83501. */
  83502. createVertexBuffer(data: DataArray): WebGLBuffer;
  83503. /**
  83504. * Creates a dynamic vertex buffer
  83505. * @param data the data for the dynamic vertex buffer
  83506. * @returns the new WebGL dynamic buffer
  83507. */
  83508. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  83509. /**
  83510. * Update a dynamic index buffer
  83511. * @param indexBuffer defines the target index buffer
  83512. * @param indices defines the data to update
  83513. * @param offset defines the offset in the target index buffer where update should start
  83514. */
  83515. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  83516. /**
  83517. * Updates a dynamic vertex buffer.
  83518. * @param vertexBuffer the vertex buffer to update
  83519. * @param data the data used to update the vertex buffer
  83520. * @param byteOffset the byte offset of the data
  83521. * @param byteLength the byte length of the data
  83522. */
  83523. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  83524. private _resetIndexBufferBinding;
  83525. /**
  83526. * Creates a new index buffer
  83527. * @param indices defines the content of the index buffer
  83528. * @param updatable defines if the index buffer must be updatable
  83529. * @returns a new webGL buffer
  83530. */
  83531. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  83532. /**
  83533. * Bind a webGL buffer to the webGL context
  83534. * @param buffer defines the buffer to bind
  83535. */
  83536. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  83537. /**
  83538. * Bind an uniform buffer to the current webGL context
  83539. * @param buffer defines the buffer to bind
  83540. */
  83541. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  83542. /**
  83543. * Bind a buffer to the current webGL context at a given location
  83544. * @param buffer defines the buffer to bind
  83545. * @param location defines the index where to bind the buffer
  83546. */
  83547. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  83548. /**
  83549. * Bind a specific block at a given index in a specific shader program
  83550. * @param shaderProgram defines the shader program
  83551. * @param blockName defines the block name
  83552. * @param index defines the index where to bind the block
  83553. */
  83554. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  83555. private bindIndexBuffer;
  83556. private bindBuffer;
  83557. /**
  83558. * update the bound buffer with the given data
  83559. * @param data defines the data to update
  83560. */
  83561. updateArrayBuffer(data: Float32Array): void;
  83562. private _vertexAttribPointer;
  83563. private _bindIndexBufferWithCache;
  83564. private _bindVertexBuffersAttributes;
  83565. /**
  83566. * Records a vertex array object
  83567. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83568. * @param vertexBuffers defines the list of vertex buffers to store
  83569. * @param indexBuffer defines the index buffer to store
  83570. * @param effect defines the effect to store
  83571. * @returns the new vertex array object
  83572. */
  83573. recordVertexArrayObject(vertexBuffers: {
  83574. [key: string]: VertexBuffer;
  83575. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  83576. /**
  83577. * Bind a specific vertex array object
  83578. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  83579. * @param vertexArrayObject defines the vertex array object to bind
  83580. * @param indexBuffer defines the index buffer to bind
  83581. */
  83582. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  83583. /**
  83584. * Bind webGl buffers directly to the webGL context
  83585. * @param vertexBuffer defines the vertex buffer to bind
  83586. * @param indexBuffer defines the index buffer to bind
  83587. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  83588. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  83589. * @param effect defines the effect associated with the vertex buffer
  83590. */
  83591. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  83592. private _unbindVertexArrayObject;
  83593. /**
  83594. * Bind a list of vertex buffers to the webGL context
  83595. * @param vertexBuffers defines the list of vertex buffers to bind
  83596. * @param indexBuffer defines the index buffer to bind
  83597. * @param effect defines the effect associated with the vertex buffers
  83598. */
  83599. bindBuffers(vertexBuffers: {
  83600. [key: string]: Nullable<VertexBuffer>;
  83601. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  83602. /**
  83603. * Unbind all instance attributes
  83604. */
  83605. unbindInstanceAttributes(): void;
  83606. /**
  83607. * Release and free the memory of a vertex array object
  83608. * @param vao defines the vertex array object to delete
  83609. */
  83610. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  83611. /** @hidden */
  83612. _releaseBuffer(buffer: WebGLBuffer): boolean;
  83613. /**
  83614. * Creates a webGL buffer to use with instanciation
  83615. * @param capacity defines the size of the buffer
  83616. * @returns the webGL buffer
  83617. */
  83618. createInstancesBuffer(capacity: number): WebGLBuffer;
  83619. /**
  83620. * Delete a webGL buffer used with instanciation
  83621. * @param buffer defines the webGL buffer to delete
  83622. */
  83623. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  83624. /**
  83625. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  83626. * @param instancesBuffer defines the webGL buffer to update and bind
  83627. * @param data defines the data to store in the buffer
  83628. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  83629. */
  83630. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  83631. /**
  83632. * Apply all cached states (depth, culling, stencil and alpha)
  83633. */
  83634. applyStates(): void;
  83635. /**
  83636. * Send a draw order
  83637. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83638. * @param indexStart defines the starting index
  83639. * @param indexCount defines the number of index to draw
  83640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83641. */
  83642. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  83643. /**
  83644. * Draw a list of points
  83645. * @param verticesStart defines the index of first vertex to draw
  83646. * @param verticesCount defines the count of vertices to draw
  83647. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83648. */
  83649. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83650. /**
  83651. * Draw a list of unindexed primitives
  83652. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  83653. * @param verticesStart defines the index of first vertex to draw
  83654. * @param verticesCount defines the count of vertices to draw
  83655. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83656. */
  83657. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83658. /**
  83659. * Draw a list of indexed primitives
  83660. * @param fillMode defines the primitive to use
  83661. * @param indexStart defines the starting index
  83662. * @param indexCount defines the number of index to draw
  83663. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83664. */
  83665. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  83666. /**
  83667. * Draw a list of unindexed primitives
  83668. * @param fillMode defines the primitive to use
  83669. * @param verticesStart defines the index of first vertex to draw
  83670. * @param verticesCount defines the count of vertices to draw
  83671. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  83672. */
  83673. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  83674. private _drawMode;
  83675. /** @hidden */
  83676. _releaseEffect(effect: Effect): void;
  83677. /** @hidden */
  83678. _deleteProgram(program: WebGLProgram): void;
  83679. /**
  83680. * Create a new effect (used to store vertex/fragment shaders)
  83681. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  83682. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  83683. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  83684. * @param samplers defines an array of string used to represent textures
  83685. * @param defines defines the string containing the defines to use to compile the shaders
  83686. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  83687. * @param onCompiled defines a function to call when the effect creation is successful
  83688. * @param onError defines a function to call when the effect creation has failed
  83689. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  83690. * @returns the new Effect
  83691. */
  83692. 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;
  83693. private _compileShader;
  83694. private _compileRawShader;
  83695. /**
  83696. * Directly creates a webGL program
  83697. * @param vertexCode defines the vertex shader code to use
  83698. * @param fragmentCode defines the fragment shader code to use
  83699. * @param context defines the webGL context to use (if not set, the current one will be used)
  83700. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83701. * @returns the new webGL program
  83702. */
  83703. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83704. /**
  83705. * Creates a webGL program
  83706. * @param vertexCode defines the vertex shader code to use
  83707. * @param fragmentCode defines the fragment shader code to use
  83708. * @param defines defines the string containing the defines to use to compile the shaders
  83709. * @param context defines the webGL context to use (if not set, the current one will be used)
  83710. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  83711. * @returns the new webGL program
  83712. */
  83713. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  83714. private _createShaderProgram;
  83715. private _finalizeProgram;
  83716. /** @hidden */
  83717. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  83718. /** @hidden */
  83719. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  83720. /**
  83721. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  83722. * @param shaderProgram defines the webGL program to use
  83723. * @param uniformsNames defines the list of uniform names
  83724. * @returns an array of webGL uniform locations
  83725. */
  83726. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  83727. /**
  83728. * Gets the lsit of active attributes for a given webGL program
  83729. * @param shaderProgram defines the webGL program to use
  83730. * @param attributesNames defines the list of attribute names to get
  83731. * @returns an array of indices indicating the offset of each attribute
  83732. */
  83733. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  83734. /**
  83735. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  83736. * @param effect defines the effect to activate
  83737. */
  83738. enableEffect(effect: Nullable<Effect>): void;
  83739. /**
  83740. * Set the value of an uniform to an array of int32
  83741. * @param uniform defines the webGL uniform location where to store the value
  83742. * @param array defines the array of int32 to store
  83743. */
  83744. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83745. /**
  83746. * Set the value of an uniform to an array of int32 (stored as vec2)
  83747. * @param uniform defines the webGL uniform location where to store the value
  83748. * @param array defines the array of int32 to store
  83749. */
  83750. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83751. /**
  83752. * Set the value of an uniform to an array of int32 (stored as vec3)
  83753. * @param uniform defines the webGL uniform location where to store the value
  83754. * @param array defines the array of int32 to store
  83755. */
  83756. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83757. /**
  83758. * Set the value of an uniform to an array of int32 (stored as vec4)
  83759. * @param uniform defines the webGL uniform location where to store the value
  83760. * @param array defines the array of int32 to store
  83761. */
  83762. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  83763. /**
  83764. * Set the value of an uniform to an array of float32
  83765. * @param uniform defines the webGL uniform location where to store the value
  83766. * @param array defines the array of float32 to store
  83767. */
  83768. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83769. /**
  83770. * Set the value of an uniform to an array of float32 (stored as vec2)
  83771. * @param uniform defines the webGL uniform location where to store the value
  83772. * @param array defines the array of float32 to store
  83773. */
  83774. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83775. /**
  83776. * Set the value of an uniform to an array of float32 (stored as vec3)
  83777. * @param uniform defines the webGL uniform location where to store the value
  83778. * @param array defines the array of float32 to store
  83779. */
  83780. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83781. /**
  83782. * Set the value of an uniform to an array of float32 (stored as vec4)
  83783. * @param uniform defines the webGL uniform location where to store the value
  83784. * @param array defines the array of float32 to store
  83785. */
  83786. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  83787. /**
  83788. * Set the value of an uniform to an array of number
  83789. * @param uniform defines the webGL uniform location where to store the value
  83790. * @param array defines the array of number to store
  83791. */
  83792. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83793. /**
  83794. * Set the value of an uniform to an array of number (stored as vec2)
  83795. * @param uniform defines the webGL uniform location where to store the value
  83796. * @param array defines the array of number to store
  83797. */
  83798. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83799. /**
  83800. * Set the value of an uniform to an array of number (stored as vec3)
  83801. * @param uniform defines the webGL uniform location where to store the value
  83802. * @param array defines the array of number to store
  83803. */
  83804. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83805. /**
  83806. * Set the value of an uniform to an array of number (stored as vec4)
  83807. * @param uniform defines the webGL uniform location where to store the value
  83808. * @param array defines the array of number to store
  83809. */
  83810. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  83811. /**
  83812. * Set the value of an uniform to an array of float32 (stored as matrices)
  83813. * @param uniform defines the webGL uniform location where to store the value
  83814. * @param matrices defines the array of float32 to store
  83815. */
  83816. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  83817. /**
  83818. * Set the value of an uniform to a matrix
  83819. * @param uniform defines the webGL uniform location where to store the value
  83820. * @param matrix defines the matrix to store
  83821. */
  83822. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  83823. /**
  83824. * Set the value of an uniform to a matrix (3x3)
  83825. * @param uniform defines the webGL uniform location where to store the value
  83826. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  83827. */
  83828. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83829. /**
  83830. * Set the value of an uniform to a matrix (2x2)
  83831. * @param uniform defines the webGL uniform location where to store the value
  83832. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  83833. */
  83834. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  83835. /**
  83836. * Set the value of an uniform to a number (int)
  83837. * @param uniform defines the webGL uniform location where to store the value
  83838. * @param value defines the int number to store
  83839. */
  83840. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83841. /**
  83842. * Set the value of an uniform to a number (float)
  83843. * @param uniform defines the webGL uniform location where to store the value
  83844. * @param value defines the float number to store
  83845. */
  83846. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  83847. /**
  83848. * Set the value of an uniform to a vec2
  83849. * @param uniform defines the webGL uniform location where to store the value
  83850. * @param x defines the 1st component of the value
  83851. * @param y defines the 2nd component of the value
  83852. */
  83853. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  83854. /**
  83855. * Set the value of an uniform to a vec3
  83856. * @param uniform defines the webGL uniform location where to store the value
  83857. * @param x defines the 1st component of the value
  83858. * @param y defines the 2nd component of the value
  83859. * @param z defines the 3rd component of the value
  83860. */
  83861. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  83862. /**
  83863. * Set the value of an uniform to a boolean
  83864. * @param uniform defines the webGL uniform location where to store the value
  83865. * @param bool defines the boolean to store
  83866. */
  83867. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  83868. /**
  83869. * Set the value of an uniform to a vec4
  83870. * @param uniform defines the webGL uniform location where to store the value
  83871. * @param x defines the 1st component of the value
  83872. * @param y defines the 2nd component of the value
  83873. * @param z defines the 3rd component of the value
  83874. * @param w defines the 4th component of the value
  83875. */
  83876. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  83877. /**
  83878. * Set the value of an uniform to a Color3
  83879. * @param uniform defines the webGL uniform location where to store the value
  83880. * @param color3 defines the color to store
  83881. */
  83882. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  83883. /**
  83884. * Set the value of an uniform to a Color3 and an alpha value
  83885. * @param uniform defines the webGL uniform location where to store the value
  83886. * @param color3 defines the color to store
  83887. * @param alpha defines the alpha component to store
  83888. */
  83889. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  83890. /**
  83891. * Sets a Color4 on a uniform variable
  83892. * @param uniform defines the uniform location
  83893. * @param color4 defines the value to be set
  83894. */
  83895. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  83896. /**
  83897. * Set various states to the webGL context
  83898. * @param culling defines backface culling state
  83899. * @param zOffset defines the value to apply to zOffset (0 by default)
  83900. * @param force defines if states must be applied even if cache is up to date
  83901. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  83902. */
  83903. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  83904. /**
  83905. * Set the z offset to apply to current rendering
  83906. * @param value defines the offset to apply
  83907. */
  83908. setZOffset(value: number): void;
  83909. /**
  83910. * Gets the current value of the zOffset
  83911. * @returns the current zOffset state
  83912. */
  83913. getZOffset(): number;
  83914. /**
  83915. * Enable or disable depth buffering
  83916. * @param enable defines the state to set
  83917. */
  83918. setDepthBuffer(enable: boolean): void;
  83919. /**
  83920. * Gets a boolean indicating if depth writing is enabled
  83921. * @returns the current depth writing state
  83922. */
  83923. getDepthWrite(): boolean;
  83924. /**
  83925. * Enable or disable depth writing
  83926. * @param enable defines the state to set
  83927. */
  83928. setDepthWrite(enable: boolean): void;
  83929. /**
  83930. * Enable or disable color writing
  83931. * @param enable defines the state to set
  83932. */
  83933. setColorWrite(enable: boolean): void;
  83934. /**
  83935. * Gets a boolean indicating if color writing is enabled
  83936. * @returns the current color writing state
  83937. */
  83938. getColorWrite(): boolean;
  83939. /**
  83940. * Sets alpha constants used by some alpha blending modes
  83941. * @param r defines the red component
  83942. * @param g defines the green component
  83943. * @param b defines the blue component
  83944. * @param a defines the alpha component
  83945. */
  83946. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  83947. /**
  83948. * Sets the current alpha mode
  83949. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  83950. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  83951. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  83952. */
  83953. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  83954. /**
  83955. * Gets the current alpha mode
  83956. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  83957. * @returns the current alpha mode
  83958. */
  83959. getAlphaMode(): number;
  83960. /**
  83961. * Clears the list of texture accessible through engine.
  83962. * This can help preventing texture load conflict due to name collision.
  83963. */
  83964. clearInternalTexturesCache(): void;
  83965. /**
  83966. * Force the entire cache to be cleared
  83967. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  83968. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  83969. */
  83970. wipeCaches(bruteForce?: boolean): void;
  83971. /**
  83972. * Set the compressed texture format to use, based on the formats you have, and the formats
  83973. * supported by the hardware / browser.
  83974. *
  83975. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  83976. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  83977. * to API arguments needed to compressed textures. This puts the burden on the container
  83978. * generator to house the arcane code for determining these for current & future formats.
  83979. *
  83980. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  83981. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  83982. *
  83983. * Note: The result of this call is not taken into account when a texture is base64.
  83984. *
  83985. * @param formatsAvailable defines the list of those format families you have created
  83986. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  83987. *
  83988. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  83989. * @returns The extension selected.
  83990. */
  83991. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  83992. private _getSamplingParameters;
  83993. private _partialLoadImg;
  83994. private _cascadeLoadImgs;
  83995. /** @hidden */
  83996. _createTexture(): WebGLTexture;
  83997. /**
  83998. * Usually called from Texture.ts.
  83999. * Passed information to create a WebGLTexture
  84000. * @param urlArg defines a value which contains one of the following:
  84001. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  84002. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  84003. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  84004. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  84005. * @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)
  84006. * @param scene needed for loading to the correct scene
  84007. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  84008. * @param onLoad optional callback to be called upon successful completion
  84009. * @param onError optional callback to be called upon failure
  84010. * @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
  84011. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  84012. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  84013. * @param forcedExtension defines the extension to use to pick the right loader
  84014. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  84015. * @returns a InternalTexture for assignment back into BABYLON.Texture
  84016. */
  84017. 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;
  84018. private _rescaleTexture;
  84019. /**
  84020. * Update a raw texture
  84021. * @param texture defines the texture to update
  84022. * @param data defines the data to store in the texture
  84023. * @param format defines the format of the data
  84024. * @param invertY defines if data must be stored with Y axis inverted
  84025. * @param compression defines the compression used (null by default)
  84026. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84027. */
  84028. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  84029. /**
  84030. * Creates a raw texture
  84031. * @param data defines the data to store in the texture
  84032. * @param width defines the width of the texture
  84033. * @param height defines the height of the texture
  84034. * @param format defines the format of the data
  84035. * @param generateMipMaps defines if the engine should generate the mip levels
  84036. * @param invertY defines if data must be stored with Y axis inverted
  84037. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84038. * @param compression defines the compression used (null by default)
  84039. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84040. * @returns the raw texture inside an InternalTexture
  84041. */
  84042. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  84043. private _unpackFlipYCached;
  84044. /**
  84045. * In case you are sharing the context with other applications, it might
  84046. * be interested to not cache the unpack flip y state to ensure a consistent
  84047. * value would be set.
  84048. */
  84049. enableUnpackFlipYCached: boolean;
  84050. /** @hidden */
  84051. _unpackFlipY(value: boolean): void;
  84052. /** @hidden */
  84053. _getUnpackAlignement(): number;
  84054. /**
  84055. * Creates a dynamic texture
  84056. * @param width defines the width of the texture
  84057. * @param height defines the height of the texture
  84058. * @param generateMipMaps defines if the engine should generate the mip levels
  84059. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84060. * @returns the dynamic texture inside an InternalTexture
  84061. */
  84062. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84063. /**
  84064. * Update the sampling mode of a given texture
  84065. * @param samplingMode defines the required sampling mode
  84066. * @param texture defines the texture to update
  84067. */
  84068. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  84069. /**
  84070. * Update the content of a dynamic texture
  84071. * @param texture defines the texture to update
  84072. * @param canvas defines the canvas containing the source
  84073. * @param invertY defines if data must be stored with Y axis inverted
  84074. * @param premulAlpha defines if alpha is stored as premultiplied
  84075. * @param format defines the format of the data
  84076. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84077. */
  84078. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84079. /**
  84080. * Update a video texture
  84081. * @param texture defines the texture to update
  84082. * @param video defines the video element to use
  84083. * @param invertY defines if data must be stored with Y axis inverted
  84084. */
  84085. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  84086. /**
  84087. * Updates a depth texture Comparison Mode and Function.
  84088. * If the comparison Function is equal to 0, the mode will be set to none.
  84089. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  84090. * @param texture The texture to set the comparison function for
  84091. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  84092. */
  84093. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  84094. private _setupDepthStencilTexture;
  84095. /**
  84096. * Creates a depth stencil texture.
  84097. * This is only available in WebGL 2 or with the depth texture extension available.
  84098. * @param size The size of face edge in the texture.
  84099. * @param options The options defining the texture.
  84100. * @returns The texture
  84101. */
  84102. createDepthStencilTexture(size: number | {
  84103. width: number;
  84104. height: number;
  84105. }, options: DepthTextureCreationOptions): InternalTexture;
  84106. /**
  84107. * Creates a depth stencil texture.
  84108. * This is only available in WebGL 2 or with the depth texture extension available.
  84109. * @param size The size of face edge in the texture.
  84110. * @param options The options defining the texture.
  84111. * @returns The texture
  84112. */
  84113. private _createDepthStencilTexture;
  84114. /**
  84115. * Creates a depth stencil cube texture.
  84116. * This is only available in WebGL 2.
  84117. * @param size The size of face edge in the cube texture.
  84118. * @param options The options defining the cube texture.
  84119. * @returns The cube texture
  84120. */
  84121. private _createDepthStencilCubeTexture;
  84122. /**
  84123. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  84124. * @param renderTarget The render target to set the frame buffer for
  84125. */
  84126. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  84127. /**
  84128. * Creates a new render target texture
  84129. * @param size defines the size of the texture
  84130. * @param options defines the options used to create the texture
  84131. * @returns a new render target texture stored in an InternalTexture
  84132. */
  84133. createRenderTargetTexture(size: number | {
  84134. width: number;
  84135. height: number;
  84136. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  84137. /**
  84138. * Create a multi render target texture
  84139. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  84140. * @param size defines the size of the texture
  84141. * @param options defines the creation options
  84142. * @returns the cube texture as an InternalTexture
  84143. */
  84144. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  84145. private _setupFramebufferDepthAttachments;
  84146. /**
  84147. * Updates the sample count of a render target texture
  84148. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84149. * @param texture defines the texture to update
  84150. * @param samples defines the sample count to set
  84151. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84152. */
  84153. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  84154. /**
  84155. * Update the sample count for a given multiple render target texture
  84156. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  84157. * @param textures defines the textures to update
  84158. * @param samples defines the sample count to set
  84159. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  84160. */
  84161. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  84162. /** @hidden */
  84163. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84164. /** @hidden */
  84165. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84166. /** @hidden */
  84167. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  84168. /** @hidden */
  84169. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  84170. /**
  84171. * Creates a new render target cube texture
  84172. * @param size defines the size of the texture
  84173. * @param options defines the options used to create the texture
  84174. * @returns a new render target cube texture stored in an InternalTexture
  84175. */
  84176. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84177. /**
  84178. * Creates a cube texture
  84179. * @param rootUrl defines the url where the files to load is located
  84180. * @param scene defines the current scene
  84181. * @param files defines the list of files to load (1 per face)
  84182. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  84183. * @param onLoad defines an optional callback raised when the texture is loaded
  84184. * @param onError defines an optional callback raised if there is an issue to load the texture
  84185. * @param format defines the format of the data
  84186. * @param forcedExtension defines the extension to use to pick the right loader
  84187. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  84188. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  84189. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  84190. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  84191. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  84192. * @returns the cube texture as an InternalTexture
  84193. */
  84194. 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;
  84195. /**
  84196. * @hidden
  84197. */
  84198. _setCubeMapTextureParams(loadMipmap: boolean): void;
  84199. /**
  84200. * Update a raw cube texture
  84201. * @param texture defines the texture to udpdate
  84202. * @param data defines the data to store
  84203. * @param format defines the data format
  84204. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84205. * @param invertY defines if data must be stored with Y axis inverted
  84206. * @param compression defines the compression used (null by default)
  84207. * @param level defines which level of the texture to update
  84208. */
  84209. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  84210. /**
  84211. * Creates a new raw cube texture
  84212. * @param data defines the array of data to use to create each face
  84213. * @param size defines the size of the textures
  84214. * @param format defines the format of the data
  84215. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84216. * @param generateMipMaps defines if the engine should generate the mip levels
  84217. * @param invertY defines if data must be stored with Y axis inverted
  84218. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84219. * @param compression defines the compression used (null by default)
  84220. * @returns the cube texture as an InternalTexture
  84221. */
  84222. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  84223. /**
  84224. * Creates a new raw cube texture from a specified url
  84225. * @param url defines the url where the data is located
  84226. * @param scene defines the current scene
  84227. * @param size defines the size of the textures
  84228. * @param format defines the format of the data
  84229. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84230. * @param noMipmap defines if the engine should avoid generating the mip levels
  84231. * @param callback defines a callback used to extract texture data from loaded data
  84232. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84233. * @param onLoad defines a callback called when texture is loaded
  84234. * @param onError defines a callback called if there is an error
  84235. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84236. * @param invertY defines if data must be stored with Y axis inverted
  84237. * @returns the cube texture as an InternalTexture
  84238. */
  84239. 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;
  84240. /**
  84241. * Update a raw 3D texture
  84242. * @param texture defines the texture to update
  84243. * @param data defines the data to store
  84244. * @param format defines the data format
  84245. * @param invertY defines if data must be stored with Y axis inverted
  84246. * @param compression defines the used compression (can be null)
  84247. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84248. */
  84249. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  84250. /**
  84251. * Creates a new raw 3D texture
  84252. * @param data defines the data used to create the texture
  84253. * @param width defines the width of the texture
  84254. * @param height defines the height of the texture
  84255. * @param depth defines the depth of the texture
  84256. * @param format defines the format of the texture
  84257. * @param generateMipMaps defines if the engine must generate mip levels
  84258. * @param invertY defines if data must be stored with Y axis inverted
  84259. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84260. * @param compression defines the compressed used (can be null)
  84261. * @param textureType defines the compressed used (can be null)
  84262. * @returns a new raw 3D texture (stored in an InternalTexture)
  84263. */
  84264. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  84265. private _prepareWebGLTextureContinuation;
  84266. private _prepareWebGLTexture;
  84267. private _convertRGBtoRGBATextureData;
  84268. /** @hidden */
  84269. _releaseFramebufferObjects(texture: InternalTexture): void;
  84270. /** @hidden */
  84271. _releaseTexture(texture: InternalTexture): void;
  84272. private setProgram;
  84273. private _boundUniforms;
  84274. /**
  84275. * Binds an effect to the webGL context
  84276. * @param effect defines the effect to bind
  84277. */
  84278. bindSamplers(effect: Effect): void;
  84279. private _moveBoundTextureOnTop;
  84280. private _getCorrectTextureChannel;
  84281. private _linkTrackers;
  84282. private _removeDesignatedSlot;
  84283. private _activateCurrentTexture;
  84284. /** @hidden */
  84285. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  84286. /** @hidden */
  84287. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  84288. /**
  84289. * Sets a texture to the webGL context from a postprocess
  84290. * @param channel defines the channel to use
  84291. * @param postProcess defines the source postprocess
  84292. */
  84293. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  84294. /**
  84295. * Binds the output of the passed in post process to the texture channel specified
  84296. * @param channel The channel the texture should be bound to
  84297. * @param postProcess The post process which's output should be bound
  84298. */
  84299. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  84300. /**
  84301. * Unbind all textures from the webGL context
  84302. */
  84303. unbindAllTextures(): void;
  84304. /**
  84305. * Sets a texture to the according uniform.
  84306. * @param channel The texture channel
  84307. * @param uniform The uniform to set
  84308. * @param texture The texture to apply
  84309. */
  84310. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  84311. /**
  84312. * Sets a depth stencil texture from a render target to the according uniform.
  84313. * @param channel The texture channel
  84314. * @param uniform The uniform to set
  84315. * @param texture The render target texture containing the depth stencil texture to apply
  84316. */
  84317. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  84318. private _bindSamplerUniformToChannel;
  84319. private _getTextureWrapMode;
  84320. private _setTexture;
  84321. /**
  84322. * Sets an array of texture to the webGL context
  84323. * @param channel defines the channel where the texture array must be set
  84324. * @param uniform defines the associated uniform location
  84325. * @param textures defines the array of textures to bind
  84326. */
  84327. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  84328. /** @hidden */
  84329. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  84330. private _setTextureParameterFloat;
  84331. private _setTextureParameterInteger;
  84332. /**
  84333. * Reads pixels from the current frame buffer. Please note that this function can be slow
  84334. * @param x defines the x coordinate of the rectangle where pixels must be read
  84335. * @param y defines the y coordinate of the rectangle where pixels must be read
  84336. * @param width defines the width of the rectangle where pixels must be read
  84337. * @param height defines the height of the rectangle where pixels must be read
  84338. * @returns a Uint8Array containing RGBA colors
  84339. */
  84340. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  84341. /**
  84342. * Add an externaly attached data from its key.
  84343. * This method call will fail and return false, if such key already exists.
  84344. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  84345. * @param key the unique key that identifies the data
  84346. * @param data the data object to associate to the key for this Engine instance
  84347. * @return true if no such key were already present and the data was added successfully, false otherwise
  84348. */
  84349. addExternalData<T>(key: string, data: T): boolean;
  84350. /**
  84351. * Get an externaly attached data from its key
  84352. * @param key the unique key that identifies the data
  84353. * @return the associated data, if present (can be null), or undefined if not present
  84354. */
  84355. getExternalData<T>(key: string): T;
  84356. /**
  84357. * Get an externaly attached data from its key, create it using a factory if it's not already present
  84358. * @param key the unique key that identifies the data
  84359. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  84360. * @return the associated data, can be null if the factory returned null.
  84361. */
  84362. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  84363. /**
  84364. * Remove an externaly attached data from the Engine instance
  84365. * @param key the unique key that identifies the data
  84366. * @return true if the data was successfully removed, false if it doesn't exist
  84367. */
  84368. removeExternalData(key: string): boolean;
  84369. /**
  84370. * Unbind all vertex attributes from the webGL context
  84371. */
  84372. unbindAllAttributes(): void;
  84373. /**
  84374. * 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
  84375. */
  84376. releaseEffects(): void;
  84377. /**
  84378. * Dispose and release all associated resources
  84379. */
  84380. dispose(): void;
  84381. /**
  84382. * Display the loading screen
  84383. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84384. */
  84385. displayLoadingUI(): void;
  84386. /**
  84387. * Hide the loading screen
  84388. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84389. */
  84390. hideLoadingUI(): void;
  84391. /**
  84392. * Gets the current loading screen object
  84393. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84394. */
  84395. /**
  84396. * Sets the current loading screen object
  84397. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84398. */
  84399. loadingScreen: ILoadingScreen;
  84400. /**
  84401. * Sets the current loading screen text
  84402. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84403. */
  84404. loadingUIText: string;
  84405. /**
  84406. * Sets the current loading screen background color
  84407. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  84408. */
  84409. loadingUIBackgroundColor: string;
  84410. /**
  84411. * Attach a new callback raised when context lost event is fired
  84412. * @param callback defines the callback to call
  84413. */
  84414. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84415. /**
  84416. * Attach a new callback raised when context restored event is fired
  84417. * @param callback defines the callback to call
  84418. */
  84419. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  84420. /**
  84421. * Gets the source code of the vertex shader associated with a specific webGL program
  84422. * @param program defines the program to use
  84423. * @returns a string containing the source code of the vertex shader associated with the program
  84424. */
  84425. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  84426. /**
  84427. * Gets the source code of the fragment shader associated with a specific webGL program
  84428. * @param program defines the program to use
  84429. * @returns a string containing the source code of the fragment shader associated with the program
  84430. */
  84431. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  84432. /**
  84433. * Get the current error code of the webGL context
  84434. * @returns the error code
  84435. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  84436. */
  84437. getError(): number;
  84438. /**
  84439. * Gets the current framerate
  84440. * @returns a number representing the framerate
  84441. */
  84442. getFps(): number;
  84443. /**
  84444. * Gets the time spent between current and previous frame
  84445. * @returns a number representing the delta time in ms
  84446. */
  84447. getDeltaTime(): number;
  84448. private _measureFps;
  84449. /** @hidden */
  84450. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  84451. private _canRenderToFloatFramebuffer;
  84452. private _canRenderToHalfFloatFramebuffer;
  84453. private _canRenderToFramebuffer;
  84454. /** @hidden */
  84455. _getWebGLTextureType(type: number): number;
  84456. private _getInternalFormat;
  84457. /** @hidden */
  84458. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  84459. /** @hidden */
  84460. _getRGBAMultiSampleBufferFormat(type: number): number;
  84461. /** @hidden */
  84462. _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;
  84463. /** @hidden */
  84464. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  84465. private _partialLoadFile;
  84466. private _cascadeLoadFiles;
  84467. /**
  84468. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  84469. * @returns true if the engine can be created
  84470. * @ignorenaming
  84471. */
  84472. static isSupported(): boolean;
  84473. }
  84474. }
  84475. declare module BABYLON {
  84476. /**
  84477. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  84478. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  84479. */
  84480. export class EffectFallbacks {
  84481. private _defines;
  84482. private _currentRank;
  84483. private _maxRank;
  84484. private _mesh;
  84485. /**
  84486. * Removes the fallback from the bound mesh.
  84487. */
  84488. unBindMesh(): void;
  84489. /**
  84490. * Adds a fallback on the specified property.
  84491. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84492. * @param define The name of the define in the shader
  84493. */
  84494. addFallback(rank: number, define: string): void;
  84495. /**
  84496. * Sets the mesh to use CPU skinning when needing to fallback.
  84497. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  84498. * @param mesh The mesh to use the fallbacks.
  84499. */
  84500. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  84501. /**
  84502. * Checks to see if more fallbacks are still availible.
  84503. */
  84504. readonly isMoreFallbacks: boolean;
  84505. /**
  84506. * Removes the defines that shoould be removed when falling back.
  84507. * @param currentDefines defines the current define statements for the shader.
  84508. * @param effect defines the current effect we try to compile
  84509. * @returns The resulting defines with defines of the current rank removed.
  84510. */
  84511. reduce(currentDefines: string, effect: Effect): string;
  84512. }
  84513. /**
  84514. * Options to be used when creating an effect.
  84515. */
  84516. export class EffectCreationOptions {
  84517. /**
  84518. * Atrributes that will be used in the shader.
  84519. */
  84520. attributes: string[];
  84521. /**
  84522. * Uniform varible names that will be set in the shader.
  84523. */
  84524. uniformsNames: string[];
  84525. /**
  84526. * Uniform buffer varible names that will be set in the shader.
  84527. */
  84528. uniformBuffersNames: string[];
  84529. /**
  84530. * Sampler texture variable names that will be set in the shader.
  84531. */
  84532. samplers: string[];
  84533. /**
  84534. * Define statements that will be set in the shader.
  84535. */
  84536. defines: any;
  84537. /**
  84538. * Possible fallbacks for this effect to improve performance when needed.
  84539. */
  84540. fallbacks: Nullable<EffectFallbacks>;
  84541. /**
  84542. * Callback that will be called when the shader is compiled.
  84543. */
  84544. onCompiled: Nullable<(effect: Effect) => void>;
  84545. /**
  84546. * Callback that will be called if an error occurs during shader compilation.
  84547. */
  84548. onError: Nullable<(effect: Effect, errors: string) => void>;
  84549. /**
  84550. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84551. */
  84552. indexParameters: any;
  84553. /**
  84554. * Max number of lights that can be used in the shader.
  84555. */
  84556. maxSimultaneousLights: number;
  84557. /**
  84558. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  84559. */
  84560. transformFeedbackVaryings: Nullable<string[]>;
  84561. }
  84562. /**
  84563. * Effect containing vertex and fragment shader that can be executed on an object.
  84564. */
  84565. export class Effect {
  84566. /**
  84567. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  84568. */
  84569. static ShadersRepository: string;
  84570. /**
  84571. * Name of the effect.
  84572. */
  84573. name: any;
  84574. /**
  84575. * String container all the define statements that should be set on the shader.
  84576. */
  84577. defines: string;
  84578. /**
  84579. * Callback that will be called when the shader is compiled.
  84580. */
  84581. onCompiled: Nullable<(effect: Effect) => void>;
  84582. /**
  84583. * Callback that will be called if an error occurs during shader compilation.
  84584. */
  84585. onError: Nullable<(effect: Effect, errors: string) => void>;
  84586. /**
  84587. * Callback that will be called when effect is bound.
  84588. */
  84589. onBind: Nullable<(effect: Effect) => void>;
  84590. /**
  84591. * Unique ID of the effect.
  84592. */
  84593. uniqueId: number;
  84594. /**
  84595. * Observable that will be called when the shader is compiled.
  84596. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  84597. */
  84598. onCompileObservable: Observable<Effect>;
  84599. /**
  84600. * Observable that will be called if an error occurs during shader compilation.
  84601. */
  84602. onErrorObservable: Observable<Effect>;
  84603. /** @hidden */
  84604. _onBindObservable: Nullable<Observable<Effect>>;
  84605. /**
  84606. * Observable that will be called when effect is bound.
  84607. */
  84608. readonly onBindObservable: Observable<Effect>;
  84609. /** @hidden */
  84610. _bonesComputationForcedToCPU: boolean;
  84611. private static _uniqueIdSeed;
  84612. private _engine;
  84613. private _uniformBuffersNames;
  84614. private _uniformsNames;
  84615. private _samplers;
  84616. private _isReady;
  84617. private _compilationError;
  84618. private _attributesNames;
  84619. private _attributes;
  84620. private _uniforms;
  84621. /**
  84622. * Key for the effect.
  84623. * @hidden
  84624. */
  84625. _key: string;
  84626. private _indexParameters;
  84627. private _fallbacks;
  84628. private _vertexSourceCode;
  84629. private _fragmentSourceCode;
  84630. private _vertexSourceCodeOverride;
  84631. private _fragmentSourceCodeOverride;
  84632. private _transformFeedbackVaryings;
  84633. /**
  84634. * Compiled shader to webGL program.
  84635. * @hidden
  84636. */
  84637. _program: WebGLProgram;
  84638. private _valueCache;
  84639. private static _baseCache;
  84640. /**
  84641. * Instantiates an effect.
  84642. * An effect can be used to create/manage/execute vertex and fragment shaders.
  84643. * @param baseName Name of the effect.
  84644. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  84645. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  84646. * @param samplers List of sampler variables that will be passed to the shader.
  84647. * @param engine Engine to be used to render the effect
  84648. * @param defines Define statements to be added to the shader.
  84649. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  84650. * @param onCompiled Callback that will be called when the shader is compiled.
  84651. * @param onError Callback that will be called if an error occurs during shader compilation.
  84652. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  84653. */
  84654. 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);
  84655. /**
  84656. * Unique key for this effect
  84657. */
  84658. readonly key: string;
  84659. /**
  84660. * If the effect has been compiled and prepared.
  84661. * @returns if the effect is compiled and prepared.
  84662. */
  84663. isReady(): boolean;
  84664. /**
  84665. * The engine the effect was initialized with.
  84666. * @returns the engine.
  84667. */
  84668. getEngine(): Engine;
  84669. /**
  84670. * The compiled webGL program for the effect
  84671. * @returns the webGL program.
  84672. */
  84673. getProgram(): WebGLProgram;
  84674. /**
  84675. * The set of names of attribute variables for the shader.
  84676. * @returns An array of attribute names.
  84677. */
  84678. getAttributesNames(): string[];
  84679. /**
  84680. * Returns the attribute at the given index.
  84681. * @param index The index of the attribute.
  84682. * @returns The location of the attribute.
  84683. */
  84684. getAttributeLocation(index: number): number;
  84685. /**
  84686. * Returns the attribute based on the name of the variable.
  84687. * @param name of the attribute to look up.
  84688. * @returns the attribute location.
  84689. */
  84690. getAttributeLocationByName(name: string): number;
  84691. /**
  84692. * The number of attributes.
  84693. * @returns the numnber of attributes.
  84694. */
  84695. getAttributesCount(): number;
  84696. /**
  84697. * Gets the index of a uniform variable.
  84698. * @param uniformName of the uniform to look up.
  84699. * @returns the index.
  84700. */
  84701. getUniformIndex(uniformName: string): number;
  84702. /**
  84703. * Returns the attribute based on the name of the variable.
  84704. * @param uniformName of the uniform to look up.
  84705. * @returns the location of the uniform.
  84706. */
  84707. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  84708. /**
  84709. * Returns an array of sampler variable names
  84710. * @returns The array of sampler variable neames.
  84711. */
  84712. getSamplers(): string[];
  84713. /**
  84714. * The error from the last compilation.
  84715. * @returns the error string.
  84716. */
  84717. getCompilationError(): string;
  84718. /**
  84719. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  84720. * @param func The callback to be used.
  84721. */
  84722. executeWhenCompiled(func: (effect: Effect) => void): void;
  84723. private _checkIsReady;
  84724. /** @hidden */
  84725. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  84726. /** @hidden */
  84727. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  84728. /** @hidden */
  84729. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  84730. private _processShaderConversion;
  84731. private _processIncludes;
  84732. private _processPrecision;
  84733. /**
  84734. * Recompiles the webGL program
  84735. * @param vertexSourceCode The source code for the vertex shader.
  84736. * @param fragmentSourceCode The source code for the fragment shader.
  84737. * @param onCompiled Callback called when completed.
  84738. * @param onError Callback called on error.
  84739. * @hidden
  84740. */
  84741. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  84742. /**
  84743. * Gets the uniform locations of the the specified variable names
  84744. * @param names THe names of the variables to lookup.
  84745. * @returns Array of locations in the same order as variable names.
  84746. */
  84747. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  84748. /**
  84749. * Prepares the effect
  84750. * @hidden
  84751. */
  84752. _prepareEffect(): void;
  84753. /**
  84754. * Checks if the effect is supported. (Must be called after compilation)
  84755. */
  84756. readonly isSupported: boolean;
  84757. /**
  84758. * Binds a texture to the engine to be used as output of the shader.
  84759. * @param channel Name of the output variable.
  84760. * @param texture Texture to bind.
  84761. * @hidden
  84762. */
  84763. _bindTexture(channel: string, texture: InternalTexture): void;
  84764. /**
  84765. * Sets a texture on the engine to be used in the shader.
  84766. * @param channel Name of the sampler variable.
  84767. * @param texture Texture to set.
  84768. */
  84769. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  84770. /**
  84771. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  84772. * @param channel Name of the sampler variable.
  84773. * @param texture Texture to set.
  84774. */
  84775. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  84776. /**
  84777. * Sets an array of textures on the engine to be used in the shader.
  84778. * @param channel Name of the variable.
  84779. * @param textures Textures to set.
  84780. */
  84781. setTextureArray(channel: string, textures: BaseTexture[]): void;
  84782. /**
  84783. * 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)
  84784. * @param channel Name of the sampler variable.
  84785. * @param postProcess Post process to get the input texture from.
  84786. */
  84787. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  84788. /**
  84789. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  84790. * 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)
  84791. * @param channel Name of the sampler variable.
  84792. * @param postProcess Post process to get the output texture from.
  84793. */
  84794. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  84795. /** @hidden */
  84796. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  84797. /** @hidden */
  84798. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  84799. /** @hidden */
  84800. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  84801. /** @hidden */
  84802. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  84803. /**
  84804. * Binds a buffer to a uniform.
  84805. * @param buffer Buffer to bind.
  84806. * @param name Name of the uniform variable to bind to.
  84807. */
  84808. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  84809. /**
  84810. * Binds block to a uniform.
  84811. * @param blockName Name of the block to bind.
  84812. * @param index Index to bind.
  84813. */
  84814. bindUniformBlock(blockName: string, index: number): void;
  84815. /**
  84816. * Sets an interger value on a uniform variable.
  84817. * @param uniformName Name of the variable.
  84818. * @param value Value to be set.
  84819. * @returns this effect.
  84820. */
  84821. setInt(uniformName: string, value: number): Effect;
  84822. /**
  84823. * Sets an int array on a uniform variable.
  84824. * @param uniformName Name of the variable.
  84825. * @param array array to be set.
  84826. * @returns this effect.
  84827. */
  84828. setIntArray(uniformName: string, array: Int32Array): Effect;
  84829. /**
  84830. * 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)
  84831. * @param uniformName Name of the variable.
  84832. * @param array array to be set.
  84833. * @returns this effect.
  84834. */
  84835. setIntArray2(uniformName: string, array: Int32Array): Effect;
  84836. /**
  84837. * 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)
  84838. * @param uniformName Name of the variable.
  84839. * @param array array to be set.
  84840. * @returns this effect.
  84841. */
  84842. setIntArray3(uniformName: string, array: Int32Array): Effect;
  84843. /**
  84844. * 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)
  84845. * @param uniformName Name of the variable.
  84846. * @param array array to be set.
  84847. * @returns this effect.
  84848. */
  84849. setIntArray4(uniformName: string, array: Int32Array): Effect;
  84850. /**
  84851. * Sets an float array on a uniform variable.
  84852. * @param uniformName Name of the variable.
  84853. * @param array array to be set.
  84854. * @returns this effect.
  84855. */
  84856. setFloatArray(uniformName: string, array: Float32Array): Effect;
  84857. /**
  84858. * 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)
  84859. * @param uniformName Name of the variable.
  84860. * @param array array to be set.
  84861. * @returns this effect.
  84862. */
  84863. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  84864. /**
  84865. * 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)
  84866. * @param uniformName Name of the variable.
  84867. * @param array array to be set.
  84868. * @returns this effect.
  84869. */
  84870. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  84871. /**
  84872. * 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)
  84873. * @param uniformName Name of the variable.
  84874. * @param array array to be set.
  84875. * @returns this effect.
  84876. */
  84877. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  84878. /**
  84879. * Sets an array on a uniform variable.
  84880. * @param uniformName Name of the variable.
  84881. * @param array array to be set.
  84882. * @returns this effect.
  84883. */
  84884. setArray(uniformName: string, array: number[]): Effect;
  84885. /**
  84886. * 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)
  84887. * @param uniformName Name of the variable.
  84888. * @param array array to be set.
  84889. * @returns this effect.
  84890. */
  84891. setArray2(uniformName: string, array: number[]): Effect;
  84892. /**
  84893. * 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)
  84894. * @param uniformName Name of the variable.
  84895. * @param array array to be set.
  84896. * @returns this effect.
  84897. */
  84898. setArray3(uniformName: string, array: number[]): Effect;
  84899. /**
  84900. * 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)
  84901. * @param uniformName Name of the variable.
  84902. * @param array array to be set.
  84903. * @returns this effect.
  84904. */
  84905. setArray4(uniformName: string, array: number[]): Effect;
  84906. /**
  84907. * Sets matrices on a uniform variable.
  84908. * @param uniformName Name of the variable.
  84909. * @param matrices matrices to be set.
  84910. * @returns this effect.
  84911. */
  84912. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  84913. /**
  84914. * Sets matrix on a uniform variable.
  84915. * @param uniformName Name of the variable.
  84916. * @param matrix matrix to be set.
  84917. * @returns this effect.
  84918. */
  84919. setMatrix(uniformName: string, matrix: Matrix): Effect;
  84920. /**
  84921. * 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)
  84922. * @param uniformName Name of the variable.
  84923. * @param matrix matrix to be set.
  84924. * @returns this effect.
  84925. */
  84926. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  84927. /**
  84928. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  84929. * @param uniformName Name of the variable.
  84930. * @param matrix matrix to be set.
  84931. * @returns this effect.
  84932. */
  84933. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  84934. /**
  84935. * Sets a float on a uniform variable.
  84936. * @param uniformName Name of the variable.
  84937. * @param value value to be set.
  84938. * @returns this effect.
  84939. */
  84940. setFloat(uniformName: string, value: number): Effect;
  84941. /**
  84942. * Sets a boolean on a uniform variable.
  84943. * @param uniformName Name of the variable.
  84944. * @param bool value to be set.
  84945. * @returns this effect.
  84946. */
  84947. setBool(uniformName: string, bool: boolean): Effect;
  84948. /**
  84949. * Sets a Vector2 on a uniform variable.
  84950. * @param uniformName Name of the variable.
  84951. * @param vector2 vector2 to be set.
  84952. * @returns this effect.
  84953. */
  84954. setVector2(uniformName: string, vector2: Vector2): Effect;
  84955. /**
  84956. * Sets a float2 on a uniform variable.
  84957. * @param uniformName Name of the variable.
  84958. * @param x First float in float2.
  84959. * @param y Second float in float2.
  84960. * @returns this effect.
  84961. */
  84962. setFloat2(uniformName: string, x: number, y: number): Effect;
  84963. /**
  84964. * Sets a Vector3 on a uniform variable.
  84965. * @param uniformName Name of the variable.
  84966. * @param vector3 Value to be set.
  84967. * @returns this effect.
  84968. */
  84969. setVector3(uniformName: string, vector3: Vector3): Effect;
  84970. /**
  84971. * Sets a float3 on a uniform variable.
  84972. * @param uniformName Name of the variable.
  84973. * @param x First float in float3.
  84974. * @param y Second float in float3.
  84975. * @param z Third float in float3.
  84976. * @returns this effect.
  84977. */
  84978. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  84979. /**
  84980. * Sets a Vector4 on a uniform variable.
  84981. * @param uniformName Name of the variable.
  84982. * @param vector4 Value to be set.
  84983. * @returns this effect.
  84984. */
  84985. setVector4(uniformName: string, vector4: Vector4): Effect;
  84986. /**
  84987. * Sets a float4 on a uniform variable.
  84988. * @param uniformName Name of the variable.
  84989. * @param x First float in float4.
  84990. * @param y Second float in float4.
  84991. * @param z Third float in float4.
  84992. * @param w Fourth float in float4.
  84993. * @returns this effect.
  84994. */
  84995. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  84996. /**
  84997. * Sets a Color3 on a uniform variable.
  84998. * @param uniformName Name of the variable.
  84999. * @param color3 Value to be set.
  85000. * @returns this effect.
  85001. */
  85002. setColor3(uniformName: string, color3: Color3): Effect;
  85003. /**
  85004. * Sets a Color4 on a uniform variable.
  85005. * @param uniformName Name of the variable.
  85006. * @param color3 Value to be set.
  85007. * @param alpha Alpha value to be set.
  85008. * @returns this effect.
  85009. */
  85010. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  85011. /**
  85012. * Sets a Color4 on a uniform variable
  85013. * @param uniformName defines the name of the variable
  85014. * @param color4 defines the value to be set
  85015. * @returns this effect.
  85016. */
  85017. setDirectColor4(uniformName: string, color4: Color4): Effect;
  85018. /**
  85019. * This function will add a new shader to the shader store
  85020. * @param name the name of the shader
  85021. * @param pixelShader optional pixel shader content
  85022. * @param vertexShader optional vertex shader content
  85023. */
  85024. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  85025. /**
  85026. * Store of each shader (The can be looked up using effect.key)
  85027. */
  85028. static ShadersStore: {
  85029. [key: string]: string;
  85030. };
  85031. /**
  85032. * Store of each included file for a shader (The can be looked up using effect.key)
  85033. */
  85034. static IncludesShadersStore: {
  85035. [key: string]: string;
  85036. };
  85037. /**
  85038. * Resets the cache of effects.
  85039. */
  85040. static ResetCache(): void;
  85041. }
  85042. }
  85043. declare module BABYLON {
  85044. /**
  85045. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  85046. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  85047. * 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;
  85048. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  85049. */
  85050. export class ColorCurves {
  85051. private _dirty;
  85052. private _tempColor;
  85053. private _globalCurve;
  85054. private _highlightsCurve;
  85055. private _midtonesCurve;
  85056. private _shadowsCurve;
  85057. private _positiveCurve;
  85058. private _negativeCurve;
  85059. private _globalHue;
  85060. private _globalDensity;
  85061. private _globalSaturation;
  85062. private _globalExposure;
  85063. /**
  85064. * Gets the global Hue value.
  85065. * 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).
  85066. */
  85067. /**
  85068. * Sets the global Hue value.
  85069. * 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).
  85070. */
  85071. globalHue: number;
  85072. /**
  85073. * Gets the global Density value.
  85074. * 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.
  85075. * Values less than zero provide a filter of opposite hue.
  85076. */
  85077. /**
  85078. * Sets the global Density value.
  85079. * 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.
  85080. * Values less than zero provide a filter of opposite hue.
  85081. */
  85082. globalDensity: number;
  85083. /**
  85084. * Gets the global Saturation value.
  85085. * 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.
  85086. */
  85087. /**
  85088. * Sets the global Saturation value.
  85089. * 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.
  85090. */
  85091. globalSaturation: number;
  85092. /**
  85093. * Gets the global Exposure value.
  85094. * 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.
  85095. */
  85096. /**
  85097. * Sets the global Exposure value.
  85098. * 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.
  85099. */
  85100. globalExposure: number;
  85101. private _highlightsHue;
  85102. private _highlightsDensity;
  85103. private _highlightsSaturation;
  85104. private _highlightsExposure;
  85105. /**
  85106. * Gets the highlights Hue value.
  85107. * 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).
  85108. */
  85109. /**
  85110. * Sets the highlights Hue value.
  85111. * 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).
  85112. */
  85113. highlightsHue: number;
  85114. /**
  85115. * Gets the highlights Density value.
  85116. * 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.
  85117. * Values less than zero provide a filter of opposite hue.
  85118. */
  85119. /**
  85120. * Sets the highlights Density value.
  85121. * 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.
  85122. * Values less than zero provide a filter of opposite hue.
  85123. */
  85124. highlightsDensity: number;
  85125. /**
  85126. * Gets the highlights Saturation value.
  85127. * 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.
  85128. */
  85129. /**
  85130. * Sets the highlights Saturation value.
  85131. * 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.
  85132. */
  85133. highlightsSaturation: number;
  85134. /**
  85135. * Gets the highlights Exposure value.
  85136. * 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.
  85137. */
  85138. /**
  85139. * Sets the highlights Exposure value.
  85140. * 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.
  85141. */
  85142. highlightsExposure: number;
  85143. private _midtonesHue;
  85144. private _midtonesDensity;
  85145. private _midtonesSaturation;
  85146. private _midtonesExposure;
  85147. /**
  85148. * Gets the midtones Hue value.
  85149. * 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).
  85150. */
  85151. /**
  85152. * Sets the midtones Hue value.
  85153. * 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).
  85154. */
  85155. midtonesHue: number;
  85156. /**
  85157. * Gets the midtones Density value.
  85158. * 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.
  85159. * Values less than zero provide a filter of opposite hue.
  85160. */
  85161. /**
  85162. * Sets the midtones Density value.
  85163. * 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.
  85164. * Values less than zero provide a filter of opposite hue.
  85165. */
  85166. midtonesDensity: number;
  85167. /**
  85168. * Gets the midtones Saturation value.
  85169. * 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.
  85170. */
  85171. /**
  85172. * Sets the midtones Saturation value.
  85173. * 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.
  85174. */
  85175. midtonesSaturation: number;
  85176. /**
  85177. * Gets the midtones Exposure value.
  85178. * 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.
  85179. */
  85180. /**
  85181. * Sets the midtones Exposure value.
  85182. * 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.
  85183. */
  85184. midtonesExposure: number;
  85185. private _shadowsHue;
  85186. private _shadowsDensity;
  85187. private _shadowsSaturation;
  85188. private _shadowsExposure;
  85189. /**
  85190. * Gets the shadows Hue value.
  85191. * 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).
  85192. */
  85193. /**
  85194. * Sets the shadows Hue value.
  85195. * 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).
  85196. */
  85197. shadowsHue: number;
  85198. /**
  85199. * Gets the shadows Density value.
  85200. * 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.
  85201. * Values less than zero provide a filter of opposite hue.
  85202. */
  85203. /**
  85204. * Sets the shadows Density value.
  85205. * 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.
  85206. * Values less than zero provide a filter of opposite hue.
  85207. */
  85208. shadowsDensity: number;
  85209. /**
  85210. * Gets the shadows Saturation value.
  85211. * 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.
  85212. */
  85213. /**
  85214. * Sets the shadows Saturation value.
  85215. * 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.
  85216. */
  85217. shadowsSaturation: number;
  85218. /**
  85219. * Gets the shadows Exposure value.
  85220. * 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.
  85221. */
  85222. /**
  85223. * Sets the shadows Exposure value.
  85224. * 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.
  85225. */
  85226. shadowsExposure: number;
  85227. /**
  85228. * Returns the class name
  85229. * @returns The class name
  85230. */
  85231. getClassName(): string;
  85232. /**
  85233. * Binds the color curves to the shader.
  85234. * @param colorCurves The color curve to bind
  85235. * @param effect The effect to bind to
  85236. * @param positiveUniform The positive uniform shader parameter
  85237. * @param neutralUniform The neutral uniform shader parameter
  85238. * @param negativeUniform The negative uniform shader parameter
  85239. */
  85240. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  85241. /**
  85242. * Prepare the list of uniforms associated with the ColorCurves effects.
  85243. * @param uniformsList The list of uniforms used in the effect
  85244. */
  85245. static PrepareUniforms(uniformsList: string[]): void;
  85246. /**
  85247. * Returns color grading data based on a hue, density, saturation and exposure value.
  85248. * @param filterHue The hue of the color filter.
  85249. * @param filterDensity The density of the color filter.
  85250. * @param saturation The saturation.
  85251. * @param exposure The exposure.
  85252. * @param result The result data container.
  85253. */
  85254. private getColorGradingDataToRef;
  85255. /**
  85256. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  85257. * @param value The input slider value in range [-100,100].
  85258. * @returns Adjusted value.
  85259. */
  85260. private static applyColorGradingSliderNonlinear;
  85261. /**
  85262. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  85263. * @param hue The hue (H) input.
  85264. * @param saturation The saturation (S) input.
  85265. * @param brightness The brightness (B) input.
  85266. * @result An RGBA color represented as Vector4.
  85267. */
  85268. private static fromHSBToRef;
  85269. /**
  85270. * Returns a value clamped between min and max
  85271. * @param value The value to clamp
  85272. * @param min The minimum of value
  85273. * @param max The maximum of value
  85274. * @returns The clamped value.
  85275. */
  85276. private static clamp;
  85277. /**
  85278. * Clones the current color curve instance.
  85279. * @return The cloned curves
  85280. */
  85281. clone(): ColorCurves;
  85282. /**
  85283. * Serializes the current color curve instance to a json representation.
  85284. * @return a JSON representation
  85285. */
  85286. serialize(): any;
  85287. /**
  85288. * Parses the color curve from a json representation.
  85289. * @param source the JSON source to parse
  85290. * @return The parsed curves
  85291. */
  85292. static Parse(source: any): ColorCurves;
  85293. }
  85294. }
  85295. declare module BABYLON {
  85296. /**
  85297. * Interface to follow in your material defines to integrate easily the
  85298. * Image proccessing functions.
  85299. * @hidden
  85300. */
  85301. export interface IImageProcessingConfigurationDefines {
  85302. IMAGEPROCESSING: boolean;
  85303. VIGNETTE: boolean;
  85304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85305. VIGNETTEBLENDMODEOPAQUE: boolean;
  85306. TONEMAPPING: boolean;
  85307. TONEMAPPING_ACES: boolean;
  85308. CONTRAST: boolean;
  85309. EXPOSURE: boolean;
  85310. COLORCURVES: boolean;
  85311. COLORGRADING: boolean;
  85312. COLORGRADING3D: boolean;
  85313. SAMPLER3DGREENDEPTH: boolean;
  85314. SAMPLER3DBGRMAP: boolean;
  85315. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85316. }
  85317. /**
  85318. * @hidden
  85319. */
  85320. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  85321. IMAGEPROCESSING: boolean;
  85322. VIGNETTE: boolean;
  85323. VIGNETTEBLENDMODEMULTIPLY: boolean;
  85324. VIGNETTEBLENDMODEOPAQUE: boolean;
  85325. TONEMAPPING: boolean;
  85326. TONEMAPPING_ACES: boolean;
  85327. CONTRAST: boolean;
  85328. COLORCURVES: boolean;
  85329. COLORGRADING: boolean;
  85330. COLORGRADING3D: boolean;
  85331. SAMPLER3DGREENDEPTH: boolean;
  85332. SAMPLER3DBGRMAP: boolean;
  85333. IMAGEPROCESSINGPOSTPROCESS: boolean;
  85334. EXPOSURE: boolean;
  85335. constructor();
  85336. }
  85337. /**
  85338. * This groups together the common properties used for image processing either in direct forward pass
  85339. * or through post processing effect depending on the use of the image processing pipeline in your scene
  85340. * or not.
  85341. */
  85342. export class ImageProcessingConfiguration {
  85343. /**
  85344. * Default tone mapping applied in BabylonJS.
  85345. */
  85346. static readonly TONEMAPPING_STANDARD: number;
  85347. /**
  85348. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  85349. * to other engines rendering to increase portability.
  85350. */
  85351. static readonly TONEMAPPING_ACES: number;
  85352. /**
  85353. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  85354. */
  85355. colorCurves: Nullable<ColorCurves>;
  85356. private _colorCurvesEnabled;
  85357. /**
  85358. * Gets wether the color curves effect is enabled.
  85359. */
  85360. /**
  85361. * Sets wether the color curves effect is enabled.
  85362. */
  85363. colorCurvesEnabled: boolean;
  85364. private _colorGradingTexture;
  85365. /**
  85366. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85367. */
  85368. /**
  85369. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  85370. */
  85371. colorGradingTexture: Nullable<BaseTexture>;
  85372. private _colorGradingEnabled;
  85373. /**
  85374. * Gets wether the color grading effect is enabled.
  85375. */
  85376. /**
  85377. * Sets wether the color grading effect is enabled.
  85378. */
  85379. colorGradingEnabled: boolean;
  85380. private _colorGradingWithGreenDepth;
  85381. /**
  85382. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  85383. */
  85384. /**
  85385. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  85386. */
  85387. colorGradingWithGreenDepth: boolean;
  85388. private _colorGradingBGR;
  85389. /**
  85390. * Gets wether the color grading texture contains BGR values.
  85391. */
  85392. /**
  85393. * Sets wether the color grading texture contains BGR values.
  85394. */
  85395. colorGradingBGR: boolean;
  85396. /** @hidden */
  85397. _exposure: number;
  85398. /**
  85399. * Gets the Exposure used in the effect.
  85400. */
  85401. /**
  85402. * Sets the Exposure used in the effect.
  85403. */
  85404. exposure: number;
  85405. private _toneMappingEnabled;
  85406. /**
  85407. * Gets wether the tone mapping effect is enabled.
  85408. */
  85409. /**
  85410. * Sets wether the tone mapping effect is enabled.
  85411. */
  85412. toneMappingEnabled: boolean;
  85413. private _toneMappingType;
  85414. /**
  85415. * Gets the type of tone mapping effect.
  85416. */
  85417. /**
  85418. * Sets the type of tone mapping effect used in BabylonJS.
  85419. */
  85420. toneMappingType: number;
  85421. protected _contrast: number;
  85422. /**
  85423. * Gets the contrast used in the effect.
  85424. */
  85425. /**
  85426. * Sets the contrast used in the effect.
  85427. */
  85428. contrast: number;
  85429. /**
  85430. * Vignette stretch size.
  85431. */
  85432. vignetteStretch: number;
  85433. /**
  85434. * Vignette centre X Offset.
  85435. */
  85436. vignetteCentreX: number;
  85437. /**
  85438. * Vignette centre Y Offset.
  85439. */
  85440. vignetteCentreY: number;
  85441. /**
  85442. * Vignette weight or intensity of the vignette effect.
  85443. */
  85444. vignetteWeight: number;
  85445. /**
  85446. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  85447. * if vignetteEnabled is set to true.
  85448. */
  85449. vignetteColor: Color4;
  85450. /**
  85451. * Camera field of view used by the Vignette effect.
  85452. */
  85453. vignetteCameraFov: number;
  85454. private _vignetteBlendMode;
  85455. /**
  85456. * Gets the vignette blend mode allowing different kind of effect.
  85457. */
  85458. /**
  85459. * Sets the vignette blend mode allowing different kind of effect.
  85460. */
  85461. vignetteBlendMode: number;
  85462. private _vignetteEnabled;
  85463. /**
  85464. * Gets wether the vignette effect is enabled.
  85465. */
  85466. /**
  85467. * Sets wether the vignette effect is enabled.
  85468. */
  85469. vignetteEnabled: boolean;
  85470. private _applyByPostProcess;
  85471. /**
  85472. * Gets wether the image processing is applied through a post process or not.
  85473. */
  85474. /**
  85475. * Sets wether the image processing is applied through a post process or not.
  85476. */
  85477. applyByPostProcess: boolean;
  85478. private _isEnabled;
  85479. /**
  85480. * Gets wether the image processing is enabled or not.
  85481. */
  85482. /**
  85483. * Sets wether the image processing is enabled or not.
  85484. */
  85485. isEnabled: boolean;
  85486. /**
  85487. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  85488. */
  85489. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  85490. /**
  85491. * Method called each time the image processing information changes requires to recompile the effect.
  85492. */
  85493. protected _updateParameters(): void;
  85494. /**
  85495. * Gets the current class name.
  85496. * @return "ImageProcessingConfiguration"
  85497. */
  85498. getClassName(): string;
  85499. /**
  85500. * Prepare the list of uniforms associated with the Image Processing effects.
  85501. * @param uniforms The list of uniforms used in the effect
  85502. * @param defines the list of defines currently in use
  85503. */
  85504. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  85505. /**
  85506. * Prepare the list of samplers associated with the Image Processing effects.
  85507. * @param samplersList The list of uniforms used in the effect
  85508. * @param defines the list of defines currently in use
  85509. */
  85510. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  85511. /**
  85512. * Prepare the list of defines associated to the shader.
  85513. * @param defines the list of defines to complete
  85514. * @param forPostProcess Define if we are currently in post process mode or not
  85515. */
  85516. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  85517. /**
  85518. * Returns true if all the image processing information are ready.
  85519. * @returns True if ready, otherwise, false
  85520. */
  85521. isReady(): boolean;
  85522. /**
  85523. * Binds the image processing to the shader.
  85524. * @param effect The effect to bind to
  85525. * @param aspectRatio Define the current aspect ratio of the effect
  85526. */
  85527. bind(effect: Effect, aspectRatio?: number): void;
  85528. /**
  85529. * Clones the current image processing instance.
  85530. * @return The cloned image processing
  85531. */
  85532. clone(): ImageProcessingConfiguration;
  85533. /**
  85534. * Serializes the current image processing instance to a json representation.
  85535. * @return a JSON representation
  85536. */
  85537. serialize(): any;
  85538. /**
  85539. * Parses the image processing from a json representation.
  85540. * @param source the JSON source to parse
  85541. * @return The parsed image processing
  85542. */
  85543. static Parse(source: any): ImageProcessingConfiguration;
  85544. private static _VIGNETTEMODE_MULTIPLY;
  85545. private static _VIGNETTEMODE_OPAQUE;
  85546. /**
  85547. * Used to apply the vignette as a mix with the pixel color.
  85548. */
  85549. static readonly VIGNETTEMODE_MULTIPLY: number;
  85550. /**
  85551. * Used to apply the vignette as a replacement of the pixel color.
  85552. */
  85553. static readonly VIGNETTEMODE_OPAQUE: number;
  85554. }
  85555. }
  85556. declare module BABYLON {
  85557. /**
  85558. * This represents all the required information to add a fresnel effect on a material:
  85559. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  85560. */
  85561. export class FresnelParameters {
  85562. private _isEnabled;
  85563. /**
  85564. * Define if the fresnel effect is enable or not.
  85565. */
  85566. isEnabled: boolean;
  85567. /**
  85568. * Define the color used on edges (grazing angle)
  85569. */
  85570. leftColor: Color3;
  85571. /**
  85572. * Define the color used on center
  85573. */
  85574. rightColor: Color3;
  85575. /**
  85576. * Define bias applied to computed fresnel term
  85577. */
  85578. bias: number;
  85579. /**
  85580. * Defined the power exponent applied to fresnel term
  85581. */
  85582. power: number;
  85583. /**
  85584. * Clones the current fresnel and its valuues
  85585. * @returns a clone fresnel configuration
  85586. */
  85587. clone(): FresnelParameters;
  85588. /**
  85589. * Serializes the current fresnel parameters to a JSON representation.
  85590. * @return the JSON serialization
  85591. */
  85592. serialize(): any;
  85593. /**
  85594. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  85595. * @param parsedFresnelParameters Define the JSON representation
  85596. * @returns the parsed parameters
  85597. */
  85598. static Parse(parsedFresnelParameters: any): FresnelParameters;
  85599. }
  85600. }
  85601. declare module BABYLON {
  85602. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  85603. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85604. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85605. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85606. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85607. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85608. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85609. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85610. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85611. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85612. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85613. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85614. /**
  85615. * Decorator used to define property that can be serialized as reference to a camera
  85616. * @param sourceName defines the name of the property to decorate
  85617. */
  85618. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  85619. /**
  85620. * Class used to help serialization objects
  85621. */
  85622. export class SerializationHelper {
  85623. /** hidden */
  85624. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  85625. /** hidden */
  85626. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  85627. /** hidden */
  85628. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  85629. /** hidden */
  85630. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  85631. /**
  85632. * Appends the serialized animations from the source animations
  85633. * @param source Source containing the animations
  85634. * @param destination Target to store the animations
  85635. */
  85636. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85637. /**
  85638. * Static function used to serialized a specific entity
  85639. * @param entity defines the entity to serialize
  85640. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  85641. * @returns a JSON compatible object representing the serialization of the entity
  85642. */
  85643. static Serialize<T>(entity: T, serializationObject?: any): any;
  85644. /**
  85645. * Creates a new entity from a serialization data object
  85646. * @param creationFunction defines a function used to instanciated the new entity
  85647. * @param source defines the source serialization data
  85648. * @param scene defines the hosting scene
  85649. * @param rootUrl defines the root url for resources
  85650. * @returns a new entity
  85651. */
  85652. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  85653. /**
  85654. * Clones an object
  85655. * @param creationFunction defines the function used to instanciate the new object
  85656. * @param source defines the source object
  85657. * @returns the cloned object
  85658. */
  85659. static Clone<T>(creationFunction: () => T, source: T): T;
  85660. /**
  85661. * Instanciates a new object based on a source one (some data will be shared between both object)
  85662. * @param creationFunction defines the function used to instanciate the new object
  85663. * @param source defines the source object
  85664. * @returns the new object
  85665. */
  85666. static Instanciate<T>(creationFunction: () => T, source: T): T;
  85667. }
  85668. }
  85669. declare module BABYLON {
  85670. /**
  85671. * This is the base class of all the camera used in the application.
  85672. * @see http://doc.babylonjs.com/features/cameras
  85673. */
  85674. export class Camera extends Node {
  85675. /** @hidden */
  85676. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  85677. /**
  85678. * This is the default projection mode used by the cameras.
  85679. * It helps recreating a feeling of perspective and better appreciate depth.
  85680. * This is the best way to simulate real life cameras.
  85681. */
  85682. static readonly PERSPECTIVE_CAMERA: number;
  85683. /**
  85684. * This helps creating camera with an orthographic mode.
  85685. * 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.
  85686. */
  85687. static readonly ORTHOGRAPHIC_CAMERA: number;
  85688. /**
  85689. * This is the default FOV mode for perspective cameras.
  85690. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  85691. */
  85692. static readonly FOVMODE_VERTICAL_FIXED: number;
  85693. /**
  85694. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  85695. */
  85696. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  85697. /**
  85698. * This specifies ther is no need for a camera rig.
  85699. * Basically only one eye is rendered corresponding to the camera.
  85700. */
  85701. static readonly RIG_MODE_NONE: number;
  85702. /**
  85703. * Simulates a camera Rig with one blue eye and one red eye.
  85704. * This can be use with 3d blue and red glasses.
  85705. */
  85706. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  85707. /**
  85708. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  85709. */
  85710. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  85711. /**
  85712. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  85713. */
  85714. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  85715. /**
  85716. * Defines that both eyes of the camera will be rendered over under each other.
  85717. */
  85718. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  85719. /**
  85720. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  85721. */
  85722. static readonly RIG_MODE_VR: number;
  85723. /**
  85724. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  85725. */
  85726. static readonly RIG_MODE_WEBVR: number;
  85727. /**
  85728. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  85729. */
  85730. static readonly RIG_MODE_CUSTOM: number;
  85731. /**
  85732. * Defines if by default attaching controls should prevent the default javascript event to continue.
  85733. */
  85734. static ForceAttachControlToAlwaysPreventDefault: boolean;
  85735. /**
  85736. * @hidden
  85737. * Might be removed once multiview will be a thing
  85738. */
  85739. static UseAlternateWebVRRendering: boolean;
  85740. /**
  85741. * Define the input manager associated with the camera.
  85742. */
  85743. inputs: CameraInputsManager<Camera>;
  85744. /**
  85745. * Define the current local position of the camera in the scene
  85746. */
  85747. position: Vector3;
  85748. /**
  85749. * The vector the camera should consider as up.
  85750. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  85751. */
  85752. upVector: Vector3;
  85753. /**
  85754. * Define the current limit on the left side for an orthographic camera
  85755. * In scene unit
  85756. */
  85757. orthoLeft: Nullable<number>;
  85758. /**
  85759. * Define the current limit on the right side for an orthographic camera
  85760. * In scene unit
  85761. */
  85762. orthoRight: Nullable<number>;
  85763. /**
  85764. * Define the current limit on the bottom side for an orthographic camera
  85765. * In scene unit
  85766. */
  85767. orthoBottom: Nullable<number>;
  85768. /**
  85769. * Define the current limit on the top side for an orthographic camera
  85770. * In scene unit
  85771. */
  85772. orthoTop: Nullable<number>;
  85773. /**
  85774. * Field Of View is set in Radians. (default is 0.8)
  85775. */
  85776. fov: number;
  85777. /**
  85778. * Define the minimum distance the camera can see from.
  85779. * This is important to note that the depth buffer are not infinite and the closer it starts
  85780. * the more your scene might encounter depth fighting issue.
  85781. */
  85782. minZ: number;
  85783. /**
  85784. * Define the maximum distance the camera can see to.
  85785. * This is important to note that the depth buffer are not infinite and the further it end
  85786. * the more your scene might encounter depth fighting issue.
  85787. */
  85788. maxZ: number;
  85789. /**
  85790. * Define the default inertia of the camera.
  85791. * This helps giving a smooth feeling to the camera movement.
  85792. */
  85793. inertia: number;
  85794. /**
  85795. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  85796. */
  85797. mode: number;
  85798. /**
  85799. * Define wether the camera is intermediate.
  85800. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  85801. */
  85802. isIntermediate: boolean;
  85803. /**
  85804. * Define the viewport of the camera.
  85805. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  85806. */
  85807. viewport: Viewport;
  85808. /**
  85809. * Restricts the camera to viewing objects with the same layerMask.
  85810. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  85811. */
  85812. layerMask: number;
  85813. /**
  85814. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  85815. */
  85816. fovMode: number;
  85817. /**
  85818. * Rig mode of the camera.
  85819. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  85820. * This is normally controlled byt the camera themselves as internal use.
  85821. */
  85822. cameraRigMode: number;
  85823. /**
  85824. * Defines the distance between both "eyes" in case of a RIG
  85825. */
  85826. interaxialDistance: number;
  85827. /**
  85828. * Defines if stereoscopic rendering is done side by side or over under.
  85829. */
  85830. isStereoscopicSideBySide: boolean;
  85831. /**
  85832. * 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
  85833. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  85834. * else in the scene.
  85835. */
  85836. customRenderTargets: RenderTargetTexture[];
  85837. /**
  85838. * When set, the camera will render to this render target instead of the default canvas
  85839. */
  85840. outputRenderTarget: Nullable<RenderTargetTexture>;
  85841. /**
  85842. * Observable triggered when the camera view matrix has changed.
  85843. */
  85844. onViewMatrixChangedObservable: Observable<Camera>;
  85845. /**
  85846. * Observable triggered when the camera Projection matrix has changed.
  85847. */
  85848. onProjectionMatrixChangedObservable: Observable<Camera>;
  85849. /**
  85850. * Observable triggered when the inputs have been processed.
  85851. */
  85852. onAfterCheckInputsObservable: Observable<Camera>;
  85853. /**
  85854. * Observable triggered when reset has been called and applied to the camera.
  85855. */
  85856. onRestoreStateObservable: Observable<Camera>;
  85857. /** @hidden */
  85858. _cameraRigParams: any;
  85859. /** @hidden */
  85860. _rigCameras: Camera[];
  85861. /** @hidden */
  85862. _rigPostProcess: Nullable<PostProcess>;
  85863. protected _webvrViewMatrix: Matrix;
  85864. /** @hidden */
  85865. _skipRendering: boolean;
  85866. /** @hidden */
  85867. _alternateCamera: Camera;
  85868. /** @hidden */
  85869. _projectionMatrix: Matrix;
  85870. /** @hidden */
  85871. _postProcesses: Nullable<PostProcess>[];
  85872. /** @hidden */
  85873. _activeMeshes: SmartArray<AbstractMesh>;
  85874. protected _globalPosition: Vector3;
  85875. /** hidden */
  85876. _computedViewMatrix: Matrix;
  85877. private _doNotComputeProjectionMatrix;
  85878. private _transformMatrix;
  85879. private _frustumPlanes;
  85880. private _refreshFrustumPlanes;
  85881. private _storedFov;
  85882. private _stateStored;
  85883. /**
  85884. * Instantiates a new camera object.
  85885. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  85886. * @see http://doc.babylonjs.com/features/cameras
  85887. * @param name Defines the name of the camera in the scene
  85888. * @param position Defines the position of the camera
  85889. * @param scene Defines the scene the camera belongs too
  85890. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  85891. */
  85892. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  85893. /**
  85894. * Store current camera state (fov, position, etc..)
  85895. * @returns the camera
  85896. */
  85897. storeState(): Camera;
  85898. /**
  85899. * Restores the camera state values if it has been stored. You must call storeState() first
  85900. */
  85901. protected _restoreStateValues(): boolean;
  85902. /**
  85903. * Restored camera state. You must call storeState() first.
  85904. * @returns true if restored and false otherwise
  85905. */
  85906. restoreState(): boolean;
  85907. /**
  85908. * Gets the class name of the camera.
  85909. * @returns the class name
  85910. */
  85911. getClassName(): string;
  85912. /** @hidden */
  85913. readonly _isCamera: boolean;
  85914. /**
  85915. * Gets a string representation of the camera useful for debug purpose.
  85916. * @param fullDetails Defines that a more verboe level of logging is required
  85917. * @returns the string representation
  85918. */
  85919. toString(fullDetails?: boolean): string;
  85920. /**
  85921. * Gets the current world space position of the camera.
  85922. */
  85923. readonly globalPosition: Vector3;
  85924. /**
  85925. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  85926. * @returns the active meshe list
  85927. */
  85928. getActiveMeshes(): SmartArray<AbstractMesh>;
  85929. /**
  85930. * Check wether a mesh is part of the current active mesh list of the camera
  85931. * @param mesh Defines the mesh to check
  85932. * @returns true if active, false otherwise
  85933. */
  85934. isActiveMesh(mesh: Mesh): boolean;
  85935. /**
  85936. * Is this camera ready to be used/rendered
  85937. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  85938. * @return true if the camera is ready
  85939. */
  85940. isReady(completeCheck?: boolean): boolean;
  85941. /** @hidden */
  85942. _initCache(): void;
  85943. /** @hidden */
  85944. _updateCache(ignoreParentClass?: boolean): void;
  85945. /** @hidden */
  85946. _isSynchronized(): boolean;
  85947. /** @hidden */
  85948. _isSynchronizedViewMatrix(): boolean;
  85949. /** @hidden */
  85950. _isSynchronizedProjectionMatrix(): boolean;
  85951. /**
  85952. * Attach the input controls to a specific dom element to get the input from.
  85953. * @param element Defines the element the controls should be listened from
  85954. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  85955. */
  85956. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  85957. /**
  85958. * Detach the current controls from the specified dom element.
  85959. * @param element Defines the element to stop listening the inputs from
  85960. */
  85961. detachControl(element: HTMLElement): void;
  85962. /**
  85963. * Update the camera state according to the different inputs gathered during the frame.
  85964. */
  85965. update(): void;
  85966. /** @hidden */
  85967. _checkInputs(): void;
  85968. /** @hidden */
  85969. readonly rigCameras: Camera[];
  85970. /**
  85971. * Gets the post process used by the rig cameras
  85972. */
  85973. readonly rigPostProcess: Nullable<PostProcess>;
  85974. /**
  85975. * Internal, gets the first post proces.
  85976. * @returns the first post process to be run on this camera.
  85977. */
  85978. _getFirstPostProcess(): Nullable<PostProcess>;
  85979. private _cascadePostProcessesToRigCams;
  85980. /**
  85981. * Attach a post process to the camera.
  85982. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  85983. * @param postProcess The post process to attach to the camera
  85984. * @param insertAt The position of the post process in case several of them are in use in the scene
  85985. * @returns the position the post process has been inserted at
  85986. */
  85987. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  85988. /**
  85989. * Detach a post process to the camera.
  85990. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  85991. * @param postProcess The post process to detach from the camera
  85992. */
  85993. detachPostProcess(postProcess: PostProcess): void;
  85994. /**
  85995. * Gets the current world matrix of the camera
  85996. */
  85997. getWorldMatrix(): Matrix;
  85998. /** @hidden */
  85999. _getViewMatrix(): Matrix;
  86000. /**
  86001. * Gets the current view matrix of the camera.
  86002. * @param force forces the camera to recompute the matrix without looking at the cached state
  86003. * @returns the view matrix
  86004. */
  86005. getViewMatrix(force?: boolean): Matrix;
  86006. /**
  86007. * Freeze the projection matrix.
  86008. * It will prevent the cache check of the camera projection compute and can speed up perf
  86009. * if no parameter of the camera are meant to change
  86010. * @param projection Defines manually a projection if necessary
  86011. */
  86012. freezeProjectionMatrix(projection?: Matrix): void;
  86013. /**
  86014. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  86015. */
  86016. unfreezeProjectionMatrix(): void;
  86017. /**
  86018. * Gets the current projection matrix of the camera.
  86019. * @param force forces the camera to recompute the matrix without looking at the cached state
  86020. * @returns the projection matrix
  86021. */
  86022. getProjectionMatrix(force?: boolean): Matrix;
  86023. /**
  86024. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  86025. * @returns a Matrix
  86026. */
  86027. getTransformationMatrix(): Matrix;
  86028. private _updateFrustumPlanes;
  86029. /**
  86030. * Checks if a cullable object (mesh...) is in the camera frustum
  86031. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  86032. * @param target The object to check
  86033. * @returns true if the object is in frustum otherwise false
  86034. */
  86035. isInFrustum(target: ICullable): boolean;
  86036. /**
  86037. * Checks if a cullable object (mesh...) is in the camera frustum
  86038. * Unlike isInFrustum this cheks the full bounding box
  86039. * @param target The object to check
  86040. * @returns true if the object is in frustum otherwise false
  86041. */
  86042. isCompletelyInFrustum(target: ICullable): boolean;
  86043. /**
  86044. * Gets a ray in the forward direction from the camera.
  86045. * @param length Defines the length of the ray to create
  86046. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  86047. * @param origin Defines the start point of the ray which defaults to the camera position
  86048. * @returns the forward ray
  86049. */
  86050. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  86051. /**
  86052. * Releases resources associated with this node.
  86053. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86054. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86055. */
  86056. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86057. /**
  86058. * Gets the left camera of a rig setup in case of Rigged Camera
  86059. */
  86060. readonly leftCamera: Nullable<FreeCamera>;
  86061. /**
  86062. * Gets the right camera of a rig setup in case of Rigged Camera
  86063. */
  86064. readonly rightCamera: Nullable<FreeCamera>;
  86065. /**
  86066. * Gets the left camera target of a rig setup in case of Rigged Camera
  86067. * @returns the target position
  86068. */
  86069. getLeftTarget(): Nullable<Vector3>;
  86070. /**
  86071. * Gets the right camera target of a rig setup in case of Rigged Camera
  86072. * @returns the target position
  86073. */
  86074. getRightTarget(): Nullable<Vector3>;
  86075. /**
  86076. * @hidden
  86077. */
  86078. setCameraRigMode(mode: number, rigParams: any): void;
  86079. /** @hidden */
  86080. static _setStereoscopicRigMode(camera: Camera): void;
  86081. /** @hidden */
  86082. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  86083. /** @hidden */
  86084. static _setVRRigMode(camera: Camera, rigParams: any): void;
  86085. /** @hidden */
  86086. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  86087. /** @hidden */
  86088. _getVRProjectionMatrix(): Matrix;
  86089. protected _updateCameraRotationMatrix(): void;
  86090. protected _updateWebVRCameraRotationMatrix(): void;
  86091. /**
  86092. * This function MUST be overwritten by the different WebVR cameras available.
  86093. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86094. * @hidden
  86095. */
  86096. _getWebVRProjectionMatrix(): Matrix;
  86097. /**
  86098. * This function MUST be overwritten by the different WebVR cameras available.
  86099. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  86100. * @hidden
  86101. */
  86102. _getWebVRViewMatrix(): Matrix;
  86103. /** @hidden */
  86104. setCameraRigParameter(name: string, value: any): void;
  86105. /**
  86106. * needs to be overridden by children so sub has required properties to be copied
  86107. * @hidden
  86108. */
  86109. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  86110. /**
  86111. * May need to be overridden by children
  86112. * @hidden
  86113. */
  86114. _updateRigCameras(): void;
  86115. /** @hidden */
  86116. _setupInputs(): void;
  86117. /**
  86118. * Serialiaze the camera setup to a json represention
  86119. * @returns the JSON representation
  86120. */
  86121. serialize(): any;
  86122. /**
  86123. * Clones the current camera.
  86124. * @param name The cloned camera name
  86125. * @returns the cloned camera
  86126. */
  86127. clone(name: string): Camera;
  86128. /**
  86129. * Gets the direction of the camera relative to a given local axis.
  86130. * @param localAxis Defines the reference axis to provide a relative direction.
  86131. * @return the direction
  86132. */
  86133. getDirection(localAxis: Vector3): Vector3;
  86134. /**
  86135. * Gets the direction of the camera relative to a given local axis into a passed vector.
  86136. * @param localAxis Defines the reference axis to provide a relative direction.
  86137. * @param result Defines the vector to store the result in
  86138. */
  86139. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  86140. /**
  86141. * Gets a camera constructor for a given camera type
  86142. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  86143. * @param name The name of the camera the result will be able to instantiate
  86144. * @param scene The scene the result will construct the camera in
  86145. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  86146. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  86147. * @returns a factory method to construc the camera
  86148. */
  86149. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  86150. /**
  86151. * Compute the world matrix of the camera.
  86152. * @returns the camera workd matrix
  86153. */
  86154. computeWorldMatrix(): Matrix;
  86155. /**
  86156. * Parse a JSON and creates the camera from the parsed information
  86157. * @param parsedCamera The JSON to parse
  86158. * @param scene The scene to instantiate the camera in
  86159. * @returns the newly constructed camera
  86160. */
  86161. static Parse(parsedCamera: any, scene: Scene): Camera;
  86162. }
  86163. }
  86164. declare module BABYLON {
  86165. /**
  86166. * Interface for any object that can request an animation frame
  86167. */
  86168. export interface ICustomAnimationFrameRequester {
  86169. /**
  86170. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  86171. */
  86172. renderFunction?: Function;
  86173. /**
  86174. * Called to request the next frame to render to
  86175. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  86176. */
  86177. requestAnimationFrame: Function;
  86178. /**
  86179. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  86180. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  86181. */
  86182. requestID?: number;
  86183. }
  86184. /**
  86185. * Interface containing an array of animations
  86186. */
  86187. export interface IAnimatable {
  86188. /**
  86189. * Array of animations
  86190. */
  86191. animations: Array<Animation>;
  86192. }
  86193. /** Interface used by value gradients (color, factor, ...) */
  86194. export interface IValueGradient {
  86195. /**
  86196. * Gets or sets the gradient value (between 0 and 1)
  86197. */
  86198. gradient: number;
  86199. }
  86200. /** Class used to store color4 gradient */
  86201. export class ColorGradient implements IValueGradient {
  86202. /**
  86203. * Gets or sets the gradient value (between 0 and 1)
  86204. */
  86205. gradient: number;
  86206. /**
  86207. * Gets or sets first associated color
  86208. */
  86209. color1: Color4;
  86210. /**
  86211. * Gets or sets second associated color
  86212. */
  86213. color2?: Color4;
  86214. /**
  86215. * Will get a color picked randomly between color1 and color2.
  86216. * If color2 is undefined then color1 will be used
  86217. * @param result defines the target Color4 to store the result in
  86218. */
  86219. getColorToRef(result: Color4): void;
  86220. }
  86221. /** Class used to store color 3 gradient */
  86222. export class Color3Gradient implements IValueGradient {
  86223. /**
  86224. * Gets or sets the gradient value (between 0 and 1)
  86225. */
  86226. gradient: number;
  86227. /**
  86228. * Gets or sets the associated color
  86229. */
  86230. color: Color3;
  86231. }
  86232. /** Class used to store factor gradient */
  86233. export class FactorGradient implements IValueGradient {
  86234. /**
  86235. * Gets or sets the gradient value (between 0 and 1)
  86236. */
  86237. gradient: number;
  86238. /**
  86239. * Gets or sets first associated factor
  86240. */
  86241. factor1: number;
  86242. /**
  86243. * Gets or sets second associated factor
  86244. */
  86245. factor2?: number;
  86246. /**
  86247. * Will get a number picked randomly between factor1 and factor2.
  86248. * If factor2 is undefined then factor1 will be used
  86249. * @returns the picked number
  86250. */
  86251. getFactor(): number;
  86252. }
  86253. /**
  86254. * @ignore
  86255. * Application error to support additional information when loading a file
  86256. */
  86257. export class LoadFileError extends Error {
  86258. /** defines the optional XHR request */
  86259. request?: XMLHttpRequest | undefined;
  86260. private static _setPrototypeOf;
  86261. /**
  86262. * Creates a new LoadFileError
  86263. * @param message defines the message of the error
  86264. * @param request defines the optional XHR request
  86265. */
  86266. constructor(message: string,
  86267. /** defines the optional XHR request */
  86268. request?: XMLHttpRequest | undefined);
  86269. }
  86270. /**
  86271. * Class used to define a retry strategy when error happens while loading assets
  86272. */
  86273. export class RetryStrategy {
  86274. /**
  86275. * Function used to defines an exponential back off strategy
  86276. * @param maxRetries defines the maximum number of retries (3 by default)
  86277. * @param baseInterval defines the interval between retries
  86278. * @returns the strategy function to use
  86279. */
  86280. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86281. }
  86282. /**
  86283. * File request interface
  86284. */
  86285. export interface IFileRequest {
  86286. /**
  86287. * Raised when the request is complete (success or error).
  86288. */
  86289. onCompleteObservable: Observable<IFileRequest>;
  86290. /**
  86291. * Aborts the request for a file.
  86292. */
  86293. abort: () => void;
  86294. }
  86295. /**
  86296. * Class containing a set of static utilities functions
  86297. */
  86298. export class Tools {
  86299. /**
  86300. * Gets or sets the base URL to use to load assets
  86301. */
  86302. static BaseUrl: string;
  86303. /**
  86304. * Enable/Disable Custom HTTP Request Headers globally.
  86305. * default = false
  86306. * @see CustomRequestHeaders
  86307. */
  86308. static UseCustomRequestHeaders: boolean;
  86309. /**
  86310. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  86311. * i.e. when loading files, where the server/service expects an Authorization header.
  86312. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  86313. */
  86314. static CustomRequestHeaders: {
  86315. [key: string]: string;
  86316. };
  86317. /**
  86318. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  86319. */
  86320. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  86321. /**
  86322. * Default behaviour for cors in the application.
  86323. * It can be a string if the expected behavior is identical in the entire app.
  86324. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  86325. */
  86326. static CorsBehavior: string | ((url: string | string[]) => string);
  86327. /**
  86328. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  86329. * @ignorenaming
  86330. */
  86331. static UseFallbackTexture: boolean;
  86332. /**
  86333. * Use this object to register external classes like custom textures or material
  86334. * to allow the laoders to instantiate them
  86335. */
  86336. static RegisteredExternalClasses: {
  86337. [key: string]: Object;
  86338. };
  86339. /**
  86340. * Texture content used if a texture cannot loaded
  86341. * @ignorenaming
  86342. */
  86343. static fallbackTexture: string;
  86344. /**
  86345. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  86346. * @param u defines the coordinate on X axis
  86347. * @param v defines the coordinate on Y axis
  86348. * @param width defines the width of the source data
  86349. * @param height defines the height of the source data
  86350. * @param pixels defines the source byte array
  86351. * @param color defines the output color
  86352. */
  86353. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  86354. /**
  86355. * Interpolates between a and b via alpha
  86356. * @param a The lower value (returned when alpha = 0)
  86357. * @param b The upper value (returned when alpha = 1)
  86358. * @param alpha The interpolation-factor
  86359. * @return The mixed value
  86360. */
  86361. static Mix(a: number, b: number, alpha: number): number;
  86362. /**
  86363. * Tries to instantiate a new object from a given class name
  86364. * @param className defines the class name to instantiate
  86365. * @returns the new object or null if the system was not able to do the instantiation
  86366. */
  86367. static Instantiate(className: string): any;
  86368. /**
  86369. * Provides a slice function that will work even on IE
  86370. * @param data defines the array to slice
  86371. * @param start defines the start of the data (optional)
  86372. * @param end defines the end of the data (optional)
  86373. * @returns the new sliced array
  86374. */
  86375. static Slice<T>(data: T, start?: number, end?: number): T;
  86376. /**
  86377. * Polyfill for setImmediate
  86378. * @param action defines the action to execute after the current execution block
  86379. */
  86380. static SetImmediate(action: () => void): void;
  86381. /**
  86382. * Function indicating if a number is an exponent of 2
  86383. * @param value defines the value to test
  86384. * @returns true if the value is an exponent of 2
  86385. */
  86386. static IsExponentOfTwo(value: number): boolean;
  86387. private static _tmpFloatArray;
  86388. /**
  86389. * Returns the nearest 32-bit single precision float representation of a Number
  86390. * @param value A Number. If the parameter is of a different type, it will get converted
  86391. * to a number or to NaN if it cannot be converted
  86392. * @returns number
  86393. */
  86394. static FloatRound(value: number): number;
  86395. /**
  86396. * Find the next highest power of two.
  86397. * @param x Number to start search from.
  86398. * @return Next highest power of two.
  86399. */
  86400. static CeilingPOT(x: number): number;
  86401. /**
  86402. * Find the next lowest power of two.
  86403. * @param x Number to start search from.
  86404. * @return Next lowest power of two.
  86405. */
  86406. static FloorPOT(x: number): number;
  86407. /**
  86408. * Find the nearest power of two.
  86409. * @param x Number to start search from.
  86410. * @return Next nearest power of two.
  86411. */
  86412. static NearestPOT(x: number): number;
  86413. /**
  86414. * Get the closest exponent of two
  86415. * @param value defines the value to approximate
  86416. * @param max defines the maximum value to return
  86417. * @param mode defines how to define the closest value
  86418. * @returns closest exponent of two of the given value
  86419. */
  86420. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  86421. /**
  86422. * Extracts the filename from a path
  86423. * @param path defines the path to use
  86424. * @returns the filename
  86425. */
  86426. static GetFilename(path: string): string;
  86427. /**
  86428. * Extracts the "folder" part of a path (everything before the filename).
  86429. * @param uri The URI to extract the info from
  86430. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  86431. * @returns The "folder" part of the path
  86432. */
  86433. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  86434. /**
  86435. * Extracts text content from a DOM element hierarchy
  86436. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  86437. */
  86438. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  86439. /**
  86440. * Convert an angle in radians to degrees
  86441. * @param angle defines the angle to convert
  86442. * @returns the angle in degrees
  86443. */
  86444. static ToDegrees(angle: number): number;
  86445. /**
  86446. * Convert an angle in degrees to radians
  86447. * @param angle defines the angle to convert
  86448. * @returns the angle in radians
  86449. */
  86450. static ToRadians(angle: number): number;
  86451. /**
  86452. * Encode a buffer to a base64 string
  86453. * @param buffer defines the buffer to encode
  86454. * @returns the encoded string
  86455. */
  86456. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  86457. /**
  86458. * Extracts minimum and maximum values from a list of indexed positions
  86459. * @param positions defines the positions to use
  86460. * @param indices defines the indices to the positions
  86461. * @param indexStart defines the start index
  86462. * @param indexCount defines the end index
  86463. * @param bias defines bias value to add to the result
  86464. * @return minimum and maximum values
  86465. */
  86466. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  86467. minimum: Vector3;
  86468. maximum: Vector3;
  86469. };
  86470. /**
  86471. * Extracts minimum and maximum values from a list of positions
  86472. * @param positions defines the positions to use
  86473. * @param start defines the start index in the positions array
  86474. * @param count defines the number of positions to handle
  86475. * @param bias defines bias value to add to the result
  86476. * @param stride defines the stride size to use (distance between two positions in the positions array)
  86477. * @return minimum and maximum values
  86478. */
  86479. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  86480. minimum: Vector3;
  86481. maximum: Vector3;
  86482. };
  86483. /**
  86484. * Returns an array if obj is not an array
  86485. * @param obj defines the object to evaluate as an array
  86486. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  86487. * @returns either obj directly if obj is an array or a new array containing obj
  86488. */
  86489. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  86490. /**
  86491. * Gets the pointer prefix to use
  86492. * @returns "pointer" if touch is enabled. Else returns "mouse"
  86493. */
  86494. static GetPointerPrefix(): string;
  86495. /**
  86496. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  86497. * @param func - the function to be called
  86498. * @param requester - the object that will request the next frame. Falls back to window.
  86499. * @returns frame number
  86500. */
  86501. static QueueNewFrame(func: () => void, requester?: any): number;
  86502. /**
  86503. * Ask the browser to promote the current element to fullscreen rendering mode
  86504. * @param element defines the DOM element to promote
  86505. */
  86506. static RequestFullscreen(element: HTMLElement): void;
  86507. /**
  86508. * Asks the browser to exit fullscreen mode
  86509. */
  86510. static ExitFullscreen(): void;
  86511. /**
  86512. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  86513. * @param url define the url we are trying
  86514. * @param element define the dom element where to configure the cors policy
  86515. */
  86516. static SetCorsBehavior(url: string | string[], element: {
  86517. crossOrigin: string | null;
  86518. }): void;
  86519. /**
  86520. * Removes unwanted characters from an url
  86521. * @param url defines the url to clean
  86522. * @returns the cleaned url
  86523. */
  86524. static CleanUrl(url: string): string;
  86525. /**
  86526. * Gets or sets a function used to pre-process url before using them to load assets
  86527. */
  86528. static PreprocessUrl: (url: string) => string;
  86529. /**
  86530. * Loads an image as an HTMLImageElement.
  86531. * @param input url string, ArrayBuffer, or Blob to load
  86532. * @param onLoad callback called when the image successfully loads
  86533. * @param onError callback called when the image fails to load
  86534. * @param offlineProvider offline provider for caching
  86535. * @returns the HTMLImageElement of the loaded image
  86536. */
  86537. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  86538. /**
  86539. * Loads a file
  86540. * @param url url string, ArrayBuffer, or Blob to load
  86541. * @param onSuccess callback called when the file successfully loads
  86542. * @param onProgress callback called while file is loading (if the server supports this mode)
  86543. * @param offlineProvider defines the offline provider for caching
  86544. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  86545. * @param onError callback called when the file fails to load
  86546. * @returns a file request object
  86547. */
  86548. 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;
  86549. /**
  86550. * Load a script (identified by an url). When the url returns, the
  86551. * content of this file is added into a new script element, attached to the DOM (body element)
  86552. * @param scriptUrl defines the url of the script to laod
  86553. * @param onSuccess defines the callback called when the script is loaded
  86554. * @param onError defines the callback to call if an error occurs
  86555. */
  86556. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  86557. /**
  86558. * Loads a file from a blob
  86559. * @param fileToLoad defines the blob to use
  86560. * @param callback defines the callback to call when data is loaded
  86561. * @param progressCallback defines the callback to call during loading process
  86562. * @returns a file request object
  86563. */
  86564. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  86565. /**
  86566. * Loads a file
  86567. * @param fileToLoad defines the file to load
  86568. * @param callback defines the callback to call when data is loaded
  86569. * @param progressCallBack defines the callback to call during loading process
  86570. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  86571. * @returns a file request object
  86572. */
  86573. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  86574. /**
  86575. * Creates a data url from a given string content
  86576. * @param content defines the content to convert
  86577. * @returns the new data url link
  86578. */
  86579. static FileAsURL(content: string): string;
  86580. /**
  86581. * Format the given number to a specific decimal format
  86582. * @param value defines the number to format
  86583. * @param decimals defines the number of decimals to use
  86584. * @returns the formatted string
  86585. */
  86586. static Format(value: number, decimals?: number): string;
  86587. /**
  86588. * Checks if a given vector is inside a specific range
  86589. * @param v defines the vector to test
  86590. * @param min defines the minimum range
  86591. * @param max defines the maximum range
  86592. */
  86593. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  86594. /**
  86595. * Tries to copy an object by duplicating every property
  86596. * @param source defines the source object
  86597. * @param destination defines the target object
  86598. * @param doNotCopyList defines a list of properties to avoid
  86599. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  86600. */
  86601. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  86602. /**
  86603. * Gets a boolean indicating if the given object has no own property
  86604. * @param obj defines the object to test
  86605. * @returns true if object has no own property
  86606. */
  86607. static IsEmpty(obj: any): boolean;
  86608. /**
  86609. * Function used to register events at window level
  86610. * @param events defines the events to register
  86611. */
  86612. static RegisterTopRootEvents(events: {
  86613. name: string;
  86614. handler: Nullable<(e: FocusEvent) => any>;
  86615. }[]): void;
  86616. /**
  86617. * Function used to unregister events from window level
  86618. * @param events defines the events to unregister
  86619. */
  86620. static UnregisterTopRootEvents(events: {
  86621. name: string;
  86622. handler: Nullable<(e: FocusEvent) => any>;
  86623. }[]): void;
  86624. /**
  86625. * Dumps the current bound framebuffer
  86626. * @param width defines the rendering width
  86627. * @param height defines the rendering height
  86628. * @param engine defines the hosting engine
  86629. * @param successCallback defines the callback triggered once the data are available
  86630. * @param mimeType defines the mime type of the result
  86631. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  86632. */
  86633. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86634. /**
  86635. * Converts the canvas data to blob.
  86636. * This acts as a polyfill for browsers not supporting the to blob function.
  86637. * @param canvas Defines the canvas to extract the data from
  86638. * @param successCallback Defines the callback triggered once the data are available
  86639. * @param mimeType Defines the mime type of the result
  86640. */
  86641. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  86642. /**
  86643. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  86644. * @param successCallback defines the callback triggered once the data are available
  86645. * @param mimeType defines the mime type of the result
  86646. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  86647. */
  86648. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  86649. /**
  86650. * Downloads a blob in the browser
  86651. * @param blob defines the blob to download
  86652. * @param fileName defines the name of the downloaded file
  86653. */
  86654. static Download(blob: Blob, fileName: string): void;
  86655. /**
  86656. * Captures a screenshot of the current rendering
  86657. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86658. * @param engine defines the rendering engine
  86659. * @param camera defines the source camera
  86660. * @param size This parameter can be set to a single number or to an object with the
  86661. * following (optional) properties: precision, width, height. If a single number is passed,
  86662. * it will be used for both width and height. If an object is passed, the screenshot size
  86663. * will be derived from the parameters. The precision property is a multiplier allowing
  86664. * rendering at a higher or lower resolution
  86665. * @param successCallback defines the callback receives a single parameter which contains the
  86666. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86667. * src parameter of an <img> to display it
  86668. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  86669. * Check your browser for supported MIME types
  86670. */
  86671. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  86672. /**
  86673. * Generates an image screenshot from the specified camera.
  86674. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  86675. * @param engine The engine to use for rendering
  86676. * @param camera The camera to use for rendering
  86677. * @param size This parameter can be set to a single number or to an object with the
  86678. * following (optional) properties: precision, width, height. If a single number is passed,
  86679. * it will be used for both width and height. If an object is passed, the screenshot size
  86680. * will be derived from the parameters. The precision property is a multiplier allowing
  86681. * rendering at a higher or lower resolution
  86682. * @param successCallback The callback receives a single parameter which contains the
  86683. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  86684. * src parameter of an <img> to display it
  86685. * @param mimeType The MIME type of the screenshot image (default: image/png).
  86686. * Check your browser for supported MIME types
  86687. * @param samples Texture samples (default: 1)
  86688. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  86689. * @param fileName A name for for the downloaded file.
  86690. */
  86691. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  86692. /**
  86693. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  86694. * Be aware Math.random() could cause collisions, but:
  86695. * "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"
  86696. * @returns a pseudo random id
  86697. */
  86698. static RandomId(): string;
  86699. /**
  86700. * Test if the given uri is a base64 string
  86701. * @param uri The uri to test
  86702. * @return True if the uri is a base64 string or false otherwise
  86703. */
  86704. static IsBase64(uri: string): boolean;
  86705. /**
  86706. * Decode the given base64 uri.
  86707. * @param uri The uri to decode
  86708. * @return The decoded base64 data.
  86709. */
  86710. static DecodeBase64(uri: string): ArrayBuffer;
  86711. /**
  86712. * No log
  86713. */
  86714. static readonly NoneLogLevel: number;
  86715. /**
  86716. * Only message logs
  86717. */
  86718. static readonly MessageLogLevel: number;
  86719. /**
  86720. * Only warning logs
  86721. */
  86722. static readonly WarningLogLevel: number;
  86723. /**
  86724. * Only error logs
  86725. */
  86726. static readonly ErrorLogLevel: number;
  86727. /**
  86728. * All logs
  86729. */
  86730. static readonly AllLogLevel: number;
  86731. /**
  86732. * Gets a value indicating the number of loading errors
  86733. * @ignorenaming
  86734. */
  86735. static readonly errorsCount: number;
  86736. /**
  86737. * Callback called when a new log is added
  86738. */
  86739. static OnNewCacheEntry: (entry: string) => void;
  86740. /**
  86741. * Log a message to the console
  86742. * @param message defines the message to log
  86743. */
  86744. static Log(message: string): void;
  86745. /**
  86746. * Write a warning message to the console
  86747. * @param message defines the message to log
  86748. */
  86749. static Warn(message: string): void;
  86750. /**
  86751. * Write an error message to the console
  86752. * @param message defines the message to log
  86753. */
  86754. static Error(message: string): void;
  86755. /**
  86756. * Gets current log cache (list of logs)
  86757. */
  86758. static readonly LogCache: string;
  86759. /**
  86760. * Clears the log cache
  86761. */
  86762. static ClearLogCache(): void;
  86763. /**
  86764. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  86765. */
  86766. static LogLevels: number;
  86767. /**
  86768. * Checks if the loaded document was accessed via `file:`-Protocol.
  86769. * @returns boolean
  86770. */
  86771. static IsFileURL(): boolean;
  86772. /**
  86773. * Checks if the window object exists
  86774. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  86775. */
  86776. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  86777. /**
  86778. * No performance log
  86779. */
  86780. static readonly PerformanceNoneLogLevel: number;
  86781. /**
  86782. * Use user marks to log performance
  86783. */
  86784. static readonly PerformanceUserMarkLogLevel: number;
  86785. /**
  86786. * Log performance to the console
  86787. */
  86788. static readonly PerformanceConsoleLogLevel: number;
  86789. private static _performance;
  86790. /**
  86791. * Sets the current performance log level
  86792. */
  86793. static PerformanceLogLevel: number;
  86794. private static _StartPerformanceCounterDisabled;
  86795. private static _EndPerformanceCounterDisabled;
  86796. private static _StartUserMark;
  86797. private static _EndUserMark;
  86798. private static _StartPerformanceConsole;
  86799. private static _EndPerformanceConsole;
  86800. /**
  86801. * Injects the @see CustomRequestHeaders into the given request
  86802. * @param request the request that should be used for injection
  86803. */
  86804. static InjectCustomRequestHeaders(request: XMLHttpRequest): void;
  86805. /**
  86806. * Starts a performance counter
  86807. */
  86808. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86809. /**
  86810. * Ends a specific performance coutner
  86811. */
  86812. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  86813. /**
  86814. * Gets either window.performance.now() if supported or Date.now() else
  86815. */
  86816. static readonly Now: number;
  86817. /**
  86818. * This method will return the name of the class used to create the instance of the given object.
  86819. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  86820. * @param object the object to get the class name from
  86821. * @param isType defines if the object is actually a type
  86822. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  86823. */
  86824. static GetClassName(object: any, isType?: boolean): string;
  86825. /**
  86826. * Gets the first element of an array satisfying a given predicate
  86827. * @param array defines the array to browse
  86828. * @param predicate defines the predicate to use
  86829. * @returns null if not found or the element
  86830. */
  86831. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  86832. /**
  86833. * This method will return the name of the full name of the class, including its owning module (if any).
  86834. * 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).
  86835. * @param object the object to get the class name from
  86836. * @param isType defines if the object is actually a type
  86837. * @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.
  86838. * @ignorenaming
  86839. */
  86840. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  86841. /**
  86842. * Returns a promise that resolves after the given amount of time.
  86843. * @param delay Number of milliseconds to delay
  86844. * @returns Promise that resolves after the given amount of time
  86845. */
  86846. static DelayAsync(delay: number): Promise<void>;
  86847. /**
  86848. * Gets the current gradient from an array of IValueGradient
  86849. * @param ratio defines the current ratio to get
  86850. * @param gradients defines the array of IValueGradient
  86851. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  86852. */
  86853. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  86854. }
  86855. /**
  86856. * This class is used to track a performance counter which is number based.
  86857. * The user has access to many properties which give statistics of different nature.
  86858. *
  86859. * The implementer can track two kinds of Performance Counter: time and count.
  86860. * 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.
  86861. * 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.
  86862. */
  86863. export class PerfCounter {
  86864. /**
  86865. * Gets or sets a global boolean to turn on and off all the counters
  86866. */
  86867. static Enabled: boolean;
  86868. /**
  86869. * Returns the smallest value ever
  86870. */
  86871. readonly min: number;
  86872. /**
  86873. * Returns the biggest value ever
  86874. */
  86875. readonly max: number;
  86876. /**
  86877. * Returns the average value since the performance counter is running
  86878. */
  86879. readonly average: number;
  86880. /**
  86881. * Returns the average value of the last second the counter was monitored
  86882. */
  86883. readonly lastSecAverage: number;
  86884. /**
  86885. * Returns the current value
  86886. */
  86887. readonly current: number;
  86888. /**
  86889. * Gets the accumulated total
  86890. */
  86891. readonly total: number;
  86892. /**
  86893. * Gets the total value count
  86894. */
  86895. readonly count: number;
  86896. /**
  86897. * Creates a new counter
  86898. */
  86899. constructor();
  86900. /**
  86901. * Call this method to start monitoring a new frame.
  86902. * 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.
  86903. */
  86904. fetchNewFrame(): void;
  86905. /**
  86906. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  86907. * @param newCount the count value to add to the monitored count
  86908. * @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.
  86909. */
  86910. addCount(newCount: number, fetchResult: boolean): void;
  86911. /**
  86912. * Start monitoring this performance counter
  86913. */
  86914. beginMonitoring(): void;
  86915. /**
  86916. * Compute the time lapsed since the previous beginMonitoring() call.
  86917. * @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
  86918. */
  86919. endMonitoring(newFrame?: boolean): void;
  86920. private _fetchResult;
  86921. private _startMonitoringTime;
  86922. private _min;
  86923. private _max;
  86924. private _average;
  86925. private _current;
  86926. private _totalValueCount;
  86927. private _totalAccumulated;
  86928. private _lastSecAverage;
  86929. private _lastSecAccumulated;
  86930. private _lastSecTime;
  86931. private _lastSecValueCount;
  86932. }
  86933. /**
  86934. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  86935. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  86936. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  86937. * @param name The name of the class, case should be preserved
  86938. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  86939. */
  86940. export function className(name: string, module?: string): (target: Object) => void;
  86941. /**
  86942. * An implementation of a loop for asynchronous functions.
  86943. */
  86944. export class AsyncLoop {
  86945. /**
  86946. * Defines the number of iterations for the loop
  86947. */
  86948. iterations: number;
  86949. /**
  86950. * Defines the current index of the loop.
  86951. */
  86952. index: number;
  86953. private _done;
  86954. private _fn;
  86955. private _successCallback;
  86956. /**
  86957. * Constructor.
  86958. * @param iterations the number of iterations.
  86959. * @param func the function to run each iteration
  86960. * @param successCallback the callback that will be called upon succesful execution
  86961. * @param offset starting offset.
  86962. */
  86963. constructor(
  86964. /**
  86965. * Defines the number of iterations for the loop
  86966. */
  86967. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  86968. /**
  86969. * Execute the next iteration. Must be called after the last iteration was finished.
  86970. */
  86971. executeNext(): void;
  86972. /**
  86973. * Break the loop and run the success callback.
  86974. */
  86975. breakLoop(): void;
  86976. /**
  86977. * Create and run an async loop.
  86978. * @param iterations the number of iterations.
  86979. * @param fn the function to run each iteration
  86980. * @param successCallback the callback that will be called upon succesful execution
  86981. * @param offset starting offset.
  86982. * @returns the created async loop object
  86983. */
  86984. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  86985. /**
  86986. * A for-loop that will run a given number of iterations synchronous and the rest async.
  86987. * @param iterations total number of iterations
  86988. * @param syncedIterations number of synchronous iterations in each async iteration.
  86989. * @param fn the function to call each iteration.
  86990. * @param callback a success call back that will be called when iterating stops.
  86991. * @param breakFunction a break condition (optional)
  86992. * @param timeout timeout settings for the setTimeout function. default - 0.
  86993. * @returns the created async loop object
  86994. */
  86995. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  86996. }
  86997. }
  86998. declare module BABYLON {
  86999. /** @hidden */
  87000. export interface ICollisionCoordinator {
  87001. createCollider(): Collider;
  87002. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87003. init(scene: Scene): void;
  87004. }
  87005. /** @hidden */
  87006. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  87007. private _scene;
  87008. private _scaledPosition;
  87009. private _scaledVelocity;
  87010. private _finalPosition;
  87011. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  87012. createCollider(): Collider;
  87013. init(scene: Scene): void;
  87014. private _collideWithWorld;
  87015. }
  87016. }
  87017. declare module BABYLON {
  87018. /**
  87019. * This class defines the direct association between an animation and a target
  87020. */
  87021. export class TargetedAnimation {
  87022. /**
  87023. * Animation to perform
  87024. */
  87025. animation: Animation;
  87026. /**
  87027. * Target to animate
  87028. */
  87029. target: any;
  87030. }
  87031. /**
  87032. * Use this class to create coordinated animations on multiple targets
  87033. */
  87034. export class AnimationGroup implements IDisposable {
  87035. /** The name of the animation group */
  87036. name: string;
  87037. private _scene;
  87038. private _targetedAnimations;
  87039. private _animatables;
  87040. private _from;
  87041. private _to;
  87042. private _isStarted;
  87043. private _isPaused;
  87044. private _speedRatio;
  87045. /**
  87046. * Gets or sets the unique id of the node
  87047. */
  87048. uniqueId: number;
  87049. /**
  87050. * This observable will notify when one animation have ended
  87051. */
  87052. onAnimationEndObservable: Observable<TargetedAnimation>;
  87053. /**
  87054. * Observer raised when one animation loops
  87055. */
  87056. onAnimationLoopObservable: Observable<TargetedAnimation>;
  87057. /**
  87058. * This observable will notify when all animations have ended.
  87059. */
  87060. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  87061. /**
  87062. * This observable will notify when all animations have paused.
  87063. */
  87064. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  87065. /**
  87066. * This observable will notify when all animations are playing.
  87067. */
  87068. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  87069. /**
  87070. * Gets the first frame
  87071. */
  87072. readonly from: number;
  87073. /**
  87074. * Gets the last frame
  87075. */
  87076. readonly to: number;
  87077. /**
  87078. * Define if the animations are started
  87079. */
  87080. readonly isStarted: boolean;
  87081. /**
  87082. * Gets a value indicating that the current group is playing
  87083. */
  87084. readonly isPlaying: boolean;
  87085. /**
  87086. * Gets or sets the speed ratio to use for all animations
  87087. */
  87088. /**
  87089. * Gets or sets the speed ratio to use for all animations
  87090. */
  87091. speedRatio: number;
  87092. /**
  87093. * Gets the targeted animations for this animation group
  87094. */
  87095. readonly targetedAnimations: Array<TargetedAnimation>;
  87096. /**
  87097. * returning the list of animatables controlled by this animation group.
  87098. */
  87099. readonly animatables: Array<Animatable>;
  87100. /**
  87101. * Instantiates a new Animation Group.
  87102. * This helps managing several animations at once.
  87103. * @see http://doc.babylonjs.com/how_to/group
  87104. * @param name Defines the name of the group
  87105. * @param scene Defines the scene the group belongs to
  87106. */
  87107. constructor(
  87108. /** The name of the animation group */
  87109. name: string, scene?: Nullable<Scene>);
  87110. /**
  87111. * Add an animation (with its target) in the group
  87112. * @param animation defines the animation we want to add
  87113. * @param target defines the target of the animation
  87114. * @returns the TargetedAnimation object
  87115. */
  87116. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  87117. /**
  87118. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  87119. * It can add constant keys at begin or end
  87120. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  87121. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  87122. * @returns the animation group
  87123. */
  87124. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  87125. /**
  87126. * Start all animations on given targets
  87127. * @param loop defines if animations must loop
  87128. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  87129. * @param from defines the from key (optional)
  87130. * @param to defines the to key (optional)
  87131. * @returns the current animation group
  87132. */
  87133. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  87134. /**
  87135. * Pause all animations
  87136. * @returns the animation group
  87137. */
  87138. pause(): AnimationGroup;
  87139. /**
  87140. * Play all animations to initial state
  87141. * This function will start() the animations if they were not started or will restart() them if they were paused
  87142. * @param loop defines if animations must loop
  87143. * @returns the animation group
  87144. */
  87145. play(loop?: boolean): AnimationGroup;
  87146. /**
  87147. * Reset all animations to initial state
  87148. * @returns the animation group
  87149. */
  87150. reset(): AnimationGroup;
  87151. /**
  87152. * Restart animations from key 0
  87153. * @returns the animation group
  87154. */
  87155. restart(): AnimationGroup;
  87156. /**
  87157. * Stop all animations
  87158. * @returns the animation group
  87159. */
  87160. stop(): AnimationGroup;
  87161. /**
  87162. * Set animation weight for all animatables
  87163. * @param weight defines the weight to use
  87164. * @return the animationGroup
  87165. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87166. */
  87167. setWeightForAllAnimatables(weight: number): AnimationGroup;
  87168. /**
  87169. * Synchronize and normalize all animatables with a source animatable
  87170. * @param root defines the root animatable to synchronize with
  87171. * @return the animationGroup
  87172. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  87173. */
  87174. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  87175. /**
  87176. * Goes to a specific frame in this animation group
  87177. * @param frame the frame number to go to
  87178. * @return the animationGroup
  87179. */
  87180. goToFrame(frame: number): AnimationGroup;
  87181. /**
  87182. * Dispose all associated resources
  87183. */
  87184. dispose(): void;
  87185. private _checkAnimationGroupEnded;
  87186. /**
  87187. * Returns a new AnimationGroup object parsed from the source provided.
  87188. * @param parsedAnimationGroup defines the source
  87189. * @param scene defines the scene that will receive the animationGroup
  87190. * @returns a new AnimationGroup
  87191. */
  87192. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  87193. /**
  87194. * Returns the string "AnimationGroup"
  87195. * @returns "AnimationGroup"
  87196. */
  87197. getClassName(): string;
  87198. /**
  87199. * Creates a detailled string about the object
  87200. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  87201. * @returns a string representing the object
  87202. */
  87203. toString(fullDetails?: boolean): string;
  87204. }
  87205. }
  87206. declare module BABYLON {
  87207. /**
  87208. * Define an interface for all classes that will hold resources
  87209. */
  87210. export interface IDisposable {
  87211. /**
  87212. * Releases all held resources
  87213. */
  87214. dispose(): void;
  87215. }
  87216. /** Interface defining initialization parameters for Scene class */
  87217. export interface SceneOptions {
  87218. /**
  87219. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  87220. * It will improve performance when the number of geometries becomes important.
  87221. */
  87222. useGeometryUniqueIdsMap?: boolean;
  87223. /**
  87224. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  87225. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87226. */
  87227. useMaterialMeshMap?: boolean;
  87228. /**
  87229. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  87230. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  87231. */
  87232. useClonedMeshhMap?: boolean;
  87233. }
  87234. /**
  87235. * Represents a scene to be rendered by the engine.
  87236. * @see http://doc.babylonjs.com/features/scene
  87237. */
  87238. export class Scene extends AbstractScene implements IAnimatable {
  87239. private static _uniqueIdCounter;
  87240. /** The fog is deactivated */
  87241. static readonly FOGMODE_NONE: number;
  87242. /** The fog density is following an exponential function */
  87243. static readonly FOGMODE_EXP: number;
  87244. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  87245. static readonly FOGMODE_EXP2: number;
  87246. /** The fog density is following a linear function. */
  87247. static readonly FOGMODE_LINEAR: number;
  87248. /**
  87249. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  87250. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87251. */
  87252. static MinDeltaTime: number;
  87253. /**
  87254. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  87255. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87256. */
  87257. static MaxDeltaTime: number;
  87258. /**
  87259. * Factory used to create the default material.
  87260. * @param name The name of the material to create
  87261. * @param scene The scene to create the material for
  87262. * @returns The default material
  87263. */
  87264. static DefaultMaterialFactory(scene: Scene): Material;
  87265. /**
  87266. * Factory used to create the a collision coordinator.
  87267. * @returns The collision coordinator
  87268. */
  87269. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  87270. /** @hidden */
  87271. readonly _isScene: boolean;
  87272. /**
  87273. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  87274. */
  87275. autoClear: boolean;
  87276. /**
  87277. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  87278. */
  87279. autoClearDepthAndStencil: boolean;
  87280. /**
  87281. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  87282. */
  87283. clearColor: Color4;
  87284. /**
  87285. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  87286. */
  87287. ambientColor: Color3;
  87288. /** @hidden */
  87289. _environmentBRDFTexture: BaseTexture;
  87290. /** @hidden */
  87291. protected _environmentTexture: Nullable<BaseTexture>;
  87292. /**
  87293. * Texture used in all pbr material as the reflection texture.
  87294. * As in the majority of the scene they are the same (exception for multi room and so on),
  87295. * this is easier to reference from here than from all the materials.
  87296. */
  87297. /**
  87298. * Texture used in all pbr material as the reflection texture.
  87299. * As in the majority of the scene they are the same (exception for multi room and so on),
  87300. * this is easier to set here than in all the materials.
  87301. */
  87302. environmentTexture: Nullable<BaseTexture>;
  87303. /** @hidden */
  87304. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  87305. /**
  87306. * Default image processing configuration used either in the rendering
  87307. * Forward main pass or through the imageProcessingPostProcess if present.
  87308. * As in the majority of the scene they are the same (exception for multi camera),
  87309. * this is easier to reference from here than from all the materials and post process.
  87310. *
  87311. * No setter as we it is a shared configuration, you can set the values instead.
  87312. */
  87313. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  87314. private _forceWireframe;
  87315. /**
  87316. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  87317. */
  87318. forceWireframe: boolean;
  87319. private _forcePointsCloud;
  87320. /**
  87321. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  87322. */
  87323. forcePointsCloud: boolean;
  87324. /**
  87325. * Gets or sets the active clipplane 1
  87326. */
  87327. clipPlane: Nullable<Plane>;
  87328. /**
  87329. * Gets or sets the active clipplane 2
  87330. */
  87331. clipPlane2: Nullable<Plane>;
  87332. /**
  87333. * Gets or sets the active clipplane 3
  87334. */
  87335. clipPlane3: Nullable<Plane>;
  87336. /**
  87337. * Gets or sets the active clipplane 4
  87338. */
  87339. clipPlane4: Nullable<Plane>;
  87340. /**
  87341. * Gets or sets a boolean indicating if animations are enabled
  87342. */
  87343. animationsEnabled: boolean;
  87344. private _animationPropertiesOverride;
  87345. /**
  87346. * Gets or sets the animation properties override
  87347. */
  87348. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87349. /**
  87350. * Gets or sets a boolean indicating if a constant deltatime has to be used
  87351. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  87352. */
  87353. useConstantAnimationDeltaTime: boolean;
  87354. /**
  87355. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  87356. * Please note that it requires to run a ray cast through the scene on every frame
  87357. */
  87358. constantlyUpdateMeshUnderPointer: boolean;
  87359. /**
  87360. * Defines the HTML cursor to use when hovering over interactive elements
  87361. */
  87362. hoverCursor: string;
  87363. /**
  87364. * Defines the HTML default cursor to use (empty by default)
  87365. */
  87366. defaultCursor: string;
  87367. /**
  87368. * This is used to call preventDefault() on pointer down
  87369. * in order to block unwanted artifacts like system double clicks
  87370. */
  87371. preventDefaultOnPointerDown: boolean;
  87372. /**
  87373. * This is used to call preventDefault() on pointer up
  87374. * in order to block unwanted artifacts like system double clicks
  87375. */
  87376. preventDefaultOnPointerUp: boolean;
  87377. /**
  87378. * Gets or sets user defined metadata
  87379. */
  87380. metadata: any;
  87381. /**
  87382. * For internal use only. Please do not use.
  87383. */
  87384. reservedDataStore: any;
  87385. /**
  87386. * Gets the name of the plugin used to load this scene (null by default)
  87387. */
  87388. loadingPluginName: string;
  87389. /**
  87390. * Use this array to add regular expressions used to disable offline support for specific urls
  87391. */
  87392. disableOfflineSupportExceptionRules: RegExp[];
  87393. /**
  87394. * An event triggered when the scene is disposed.
  87395. */
  87396. onDisposeObservable: Observable<Scene>;
  87397. private _onDisposeObserver;
  87398. /** Sets a function to be executed when this scene is disposed. */
  87399. onDispose: () => void;
  87400. /**
  87401. * An event triggered before rendering the scene (right after animations and physics)
  87402. */
  87403. onBeforeRenderObservable: Observable<Scene>;
  87404. private _onBeforeRenderObserver;
  87405. /** Sets a function to be executed before rendering this scene */
  87406. beforeRender: Nullable<() => void>;
  87407. /**
  87408. * An event triggered after rendering the scene
  87409. */
  87410. onAfterRenderObservable: Observable<Scene>;
  87411. private _onAfterRenderObserver;
  87412. /** Sets a function to be executed after rendering this scene */
  87413. afterRender: Nullable<() => void>;
  87414. /**
  87415. * An event triggered before animating the scene
  87416. */
  87417. onBeforeAnimationsObservable: Observable<Scene>;
  87418. /**
  87419. * An event triggered after animations processing
  87420. */
  87421. onAfterAnimationsObservable: Observable<Scene>;
  87422. /**
  87423. * An event triggered before draw calls are ready to be sent
  87424. */
  87425. onBeforeDrawPhaseObservable: Observable<Scene>;
  87426. /**
  87427. * An event triggered after draw calls have been sent
  87428. */
  87429. onAfterDrawPhaseObservable: Observable<Scene>;
  87430. /**
  87431. * An event triggered when the scene is ready
  87432. */
  87433. onReadyObservable: Observable<Scene>;
  87434. /**
  87435. * An event triggered before rendering a camera
  87436. */
  87437. onBeforeCameraRenderObservable: Observable<Camera>;
  87438. private _onBeforeCameraRenderObserver;
  87439. /** Sets a function to be executed before rendering a camera*/
  87440. beforeCameraRender: () => void;
  87441. /**
  87442. * An event triggered after rendering a camera
  87443. */
  87444. onAfterCameraRenderObservable: Observable<Camera>;
  87445. private _onAfterCameraRenderObserver;
  87446. /** Sets a function to be executed after rendering a camera*/
  87447. afterCameraRender: () => void;
  87448. /**
  87449. * An event triggered when active meshes evaluation is about to start
  87450. */
  87451. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  87452. /**
  87453. * An event triggered when active meshes evaluation is done
  87454. */
  87455. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  87456. /**
  87457. * An event triggered when particles rendering is about to start
  87458. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87459. */
  87460. onBeforeParticlesRenderingObservable: Observable<Scene>;
  87461. /**
  87462. * An event triggered when particles rendering is done
  87463. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  87464. */
  87465. onAfterParticlesRenderingObservable: Observable<Scene>;
  87466. /**
  87467. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  87468. */
  87469. onDataLoadedObservable: Observable<Scene>;
  87470. /**
  87471. * An event triggered when a camera is created
  87472. */
  87473. onNewCameraAddedObservable: Observable<Camera>;
  87474. /**
  87475. * An event triggered when a camera is removed
  87476. */
  87477. onCameraRemovedObservable: Observable<Camera>;
  87478. /**
  87479. * An event triggered when a light is created
  87480. */
  87481. onNewLightAddedObservable: Observable<Light>;
  87482. /**
  87483. * An event triggered when a light is removed
  87484. */
  87485. onLightRemovedObservable: Observable<Light>;
  87486. /**
  87487. * An event triggered when a geometry is created
  87488. */
  87489. onNewGeometryAddedObservable: Observable<Geometry>;
  87490. /**
  87491. * An event triggered when a geometry is removed
  87492. */
  87493. onGeometryRemovedObservable: Observable<Geometry>;
  87494. /**
  87495. * An event triggered when a transform node is created
  87496. */
  87497. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  87498. /**
  87499. * An event triggered when a transform node is removed
  87500. */
  87501. onTransformNodeRemovedObservable: Observable<TransformNode>;
  87502. /**
  87503. * An event triggered when a mesh is created
  87504. */
  87505. onNewMeshAddedObservable: Observable<AbstractMesh>;
  87506. /**
  87507. * An event triggered when a mesh is removed
  87508. */
  87509. onMeshRemovedObservable: Observable<AbstractMesh>;
  87510. /**
  87511. * An event triggered when a material is created
  87512. */
  87513. onNewMaterialAddedObservable: Observable<Material>;
  87514. /**
  87515. * An event triggered when a material is removed
  87516. */
  87517. onMaterialRemovedObservable: Observable<Material>;
  87518. /**
  87519. * An event triggered when a texture is created
  87520. */
  87521. onNewTextureAddedObservable: Observable<BaseTexture>;
  87522. /**
  87523. * An event triggered when a texture is removed
  87524. */
  87525. onTextureRemovedObservable: Observable<BaseTexture>;
  87526. /**
  87527. * An event triggered when render targets are about to be rendered
  87528. * Can happen multiple times per frame.
  87529. */
  87530. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  87531. /**
  87532. * An event triggered when render targets were rendered.
  87533. * Can happen multiple times per frame.
  87534. */
  87535. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  87536. /**
  87537. * An event triggered before calculating deterministic simulation step
  87538. */
  87539. onBeforeStepObservable: Observable<Scene>;
  87540. /**
  87541. * An event triggered after calculating deterministic simulation step
  87542. */
  87543. onAfterStepObservable: Observable<Scene>;
  87544. /**
  87545. * An event triggered when the activeCamera property is updated
  87546. */
  87547. onActiveCameraChanged: Observable<Scene>;
  87548. /**
  87549. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  87550. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87551. * 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)
  87552. */
  87553. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87554. /**
  87555. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  87556. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  87557. * 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)
  87558. */
  87559. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  87560. /**
  87561. * This Observable will when a mesh has been imported into the scene.
  87562. */
  87563. onMeshImportedObservable: Observable<AbstractMesh>;
  87564. /** @hidden */
  87565. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  87566. /**
  87567. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  87568. */
  87569. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  87570. /**
  87571. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  87572. */
  87573. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  87574. /**
  87575. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  87576. */
  87577. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  87578. private _onPointerMove;
  87579. private _onPointerDown;
  87580. private _onPointerUp;
  87581. /** Callback called when a pointer move is detected */
  87582. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87583. /** Callback called when a pointer down is detected */
  87584. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  87585. /** Callback called when a pointer up is detected */
  87586. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  87587. /** Callback called when a pointer pick is detected */
  87588. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  87589. /**
  87590. * 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).
  87591. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  87592. */
  87593. onPrePointerObservable: Observable<PointerInfoPre>;
  87594. /**
  87595. * Observable event triggered each time an input event is received from the rendering canvas
  87596. */
  87597. onPointerObservable: Observable<PointerInfo>;
  87598. /**
  87599. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  87600. */
  87601. readonly unTranslatedPointer: Vector2;
  87602. /** The distance in pixel that you have to move to prevent some events */
  87603. static DragMovementThreshold: number;
  87604. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  87605. static LongPressDelay: number;
  87606. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  87607. static DoubleClickDelay: number;
  87608. /** If you need to check double click without raising a single click at first click, enable this flag */
  87609. static ExclusiveDoubleClickMode: boolean;
  87610. private _initClickEvent;
  87611. private _initActionManager;
  87612. private _delayedSimpleClick;
  87613. private _delayedSimpleClickTimeout;
  87614. private _previousDelayedSimpleClickTimeout;
  87615. private _meshPickProceed;
  87616. private _previousButtonPressed;
  87617. private _currentPickResult;
  87618. private _previousPickResult;
  87619. private _totalPointersPressed;
  87620. private _doubleClickOccured;
  87621. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  87622. cameraToUseForPointers: Nullable<Camera>;
  87623. private _pointerX;
  87624. private _pointerY;
  87625. private _unTranslatedPointerX;
  87626. private _unTranslatedPointerY;
  87627. private _startingPointerPosition;
  87628. private _previousStartingPointerPosition;
  87629. private _startingPointerTime;
  87630. private _previousStartingPointerTime;
  87631. private _pointerCaptures;
  87632. private _timeAccumulator;
  87633. private _currentStepId;
  87634. private _currentInternalStep;
  87635. /** @hidden */
  87636. _mirroredCameraPosition: Nullable<Vector3>;
  87637. /**
  87638. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  87639. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  87640. */
  87641. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  87642. /**
  87643. * Observable event triggered each time an keyboard event is received from the hosting window
  87644. */
  87645. onKeyboardObservable: Observable<KeyboardInfo>;
  87646. private _onKeyDown;
  87647. private _onKeyUp;
  87648. private _onCanvasFocusObserver;
  87649. private _onCanvasBlurObserver;
  87650. private _useRightHandedSystem;
  87651. /**
  87652. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  87653. */
  87654. useRightHandedSystem: boolean;
  87655. /**
  87656. * Sets the step Id used by deterministic lock step
  87657. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87658. * @param newStepId defines the step Id
  87659. */
  87660. setStepId(newStepId: number): void;
  87661. /**
  87662. * Gets the step Id used by deterministic lock step
  87663. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87664. * @returns the step Id
  87665. */
  87666. getStepId(): number;
  87667. /**
  87668. * Gets the internal step used by deterministic lock step
  87669. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87670. * @returns the internal step
  87671. */
  87672. getInternalStep(): number;
  87673. private _fogEnabled;
  87674. /**
  87675. * Gets or sets a boolean indicating if fog is enabled on this scene
  87676. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87677. * (Default is true)
  87678. */
  87679. fogEnabled: boolean;
  87680. private _fogMode;
  87681. /**
  87682. * Gets or sets the fog mode to use
  87683. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87684. * | mode | value |
  87685. * | --- | --- |
  87686. * | FOGMODE_NONE | 0 |
  87687. * | FOGMODE_EXP | 1 |
  87688. * | FOGMODE_EXP2 | 2 |
  87689. * | FOGMODE_LINEAR | 3 |
  87690. */
  87691. fogMode: number;
  87692. /**
  87693. * Gets or sets the fog color to use
  87694. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87695. * (Default is Color3(0.2, 0.2, 0.3))
  87696. */
  87697. fogColor: Color3;
  87698. /**
  87699. * Gets or sets the fog density to use
  87700. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87701. * (Default is 0.1)
  87702. */
  87703. fogDensity: number;
  87704. /**
  87705. * Gets or sets the fog start distance to use
  87706. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87707. * (Default is 0)
  87708. */
  87709. fogStart: number;
  87710. /**
  87711. * Gets or sets the fog end distance to use
  87712. * @see http://doc.babylonjs.com/babylon101/environment#fog
  87713. * (Default is 1000)
  87714. */
  87715. fogEnd: number;
  87716. private _shadowsEnabled;
  87717. /**
  87718. * Gets or sets a boolean indicating if shadows are enabled on this scene
  87719. */
  87720. shadowsEnabled: boolean;
  87721. private _lightsEnabled;
  87722. /**
  87723. * Gets or sets a boolean indicating if lights are enabled on this scene
  87724. */
  87725. lightsEnabled: boolean;
  87726. /** All of the active cameras added to this scene. */
  87727. activeCameras: Camera[];
  87728. private _activeCamera;
  87729. /** Gets or sets the current active camera */
  87730. activeCamera: Nullable<Camera>;
  87731. private _defaultMaterial;
  87732. /** The default material used on meshes when no material is affected */
  87733. /** The default material used on meshes when no material is affected */
  87734. defaultMaterial: Material;
  87735. private _texturesEnabled;
  87736. /**
  87737. * Gets or sets a boolean indicating if textures are enabled on this scene
  87738. */
  87739. texturesEnabled: boolean;
  87740. /**
  87741. * Gets or sets a boolean indicating if particles are enabled on this scene
  87742. */
  87743. particlesEnabled: boolean;
  87744. /**
  87745. * Gets or sets a boolean indicating if sprites are enabled on this scene
  87746. */
  87747. spritesEnabled: boolean;
  87748. private _skeletonsEnabled;
  87749. /**
  87750. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  87751. */
  87752. skeletonsEnabled: boolean;
  87753. /**
  87754. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  87755. */
  87756. lensFlaresEnabled: boolean;
  87757. /**
  87758. * Gets or sets a boolean indicating if collisions are enabled on this scene
  87759. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87760. */
  87761. collisionsEnabled: boolean;
  87762. private _collisionCoordinator;
  87763. /** @hidden */
  87764. readonly collisionCoordinator: ICollisionCoordinator;
  87765. /**
  87766. * Defines the gravity applied to this scene (used only for collisions)
  87767. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87768. */
  87769. gravity: Vector3;
  87770. /**
  87771. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  87772. */
  87773. postProcessesEnabled: boolean;
  87774. /**
  87775. * The list of postprocesses added to the scene
  87776. */
  87777. postProcesses: PostProcess[];
  87778. /**
  87779. * Gets the current postprocess manager
  87780. */
  87781. postProcessManager: PostProcessManager;
  87782. /**
  87783. * Gets or sets a boolean indicating if render targets are enabled on this scene
  87784. */
  87785. renderTargetsEnabled: boolean;
  87786. /**
  87787. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  87788. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  87789. */
  87790. dumpNextRenderTargets: boolean;
  87791. /**
  87792. * The list of user defined render targets added to the scene
  87793. */
  87794. customRenderTargets: RenderTargetTexture[];
  87795. /**
  87796. * Defines if texture loading must be delayed
  87797. * If true, textures will only be loaded when they need to be rendered
  87798. */
  87799. useDelayedTextureLoading: boolean;
  87800. /**
  87801. * Gets the list of meshes imported to the scene through SceneLoader
  87802. */
  87803. importedMeshesFiles: String[];
  87804. /**
  87805. * Gets or sets a boolean indicating if probes are enabled on this scene
  87806. */
  87807. probesEnabled: boolean;
  87808. /**
  87809. * Gets or sets the current offline provider to use to store scene data
  87810. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  87811. */
  87812. offlineProvider: IOfflineProvider;
  87813. /**
  87814. * Gets or sets the action manager associated with the scene
  87815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87816. */
  87817. actionManager: AbstractActionManager;
  87818. private _meshesForIntersections;
  87819. /**
  87820. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  87821. */
  87822. proceduralTexturesEnabled: boolean;
  87823. private _engine;
  87824. private _totalVertices;
  87825. /** @hidden */
  87826. _activeIndices: PerfCounter;
  87827. /** @hidden */
  87828. _activeParticles: PerfCounter;
  87829. /** @hidden */
  87830. _activeBones: PerfCounter;
  87831. private _animationRatio;
  87832. /** @hidden */
  87833. _animationTimeLast: number;
  87834. /** @hidden */
  87835. _animationTime: number;
  87836. /**
  87837. * Gets or sets a general scale for animation speed
  87838. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  87839. */
  87840. animationTimeScale: number;
  87841. /** @hidden */
  87842. _cachedMaterial: Nullable<Material>;
  87843. /** @hidden */
  87844. _cachedEffect: Nullable<Effect>;
  87845. /** @hidden */
  87846. _cachedVisibility: Nullable<number>;
  87847. private _renderId;
  87848. private _frameId;
  87849. private _executeWhenReadyTimeoutId;
  87850. private _intermediateRendering;
  87851. private _viewUpdateFlag;
  87852. private _projectionUpdateFlag;
  87853. private _alternateViewUpdateFlag;
  87854. private _alternateProjectionUpdateFlag;
  87855. /** @hidden */
  87856. _toBeDisposed: Nullable<IDisposable>[];
  87857. private _activeRequests;
  87858. /** @hidden */
  87859. _pendingData: any[];
  87860. private _isDisposed;
  87861. /**
  87862. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  87863. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  87864. */
  87865. dispatchAllSubMeshesOfActiveMeshes: boolean;
  87866. private _activeMeshes;
  87867. private _processedMaterials;
  87868. private _renderTargets;
  87869. /** @hidden */
  87870. _activeParticleSystems: SmartArray<IParticleSystem>;
  87871. private _activeSkeletons;
  87872. private _softwareSkinnedMeshes;
  87873. private _renderingManager;
  87874. /** @hidden */
  87875. _activeAnimatables: Animatable[];
  87876. private _transformMatrix;
  87877. private _sceneUbo;
  87878. private _alternateSceneUbo;
  87879. private _pickWithRayInverseMatrix;
  87880. private _viewMatrix;
  87881. private _projectionMatrix;
  87882. private _alternateViewMatrix;
  87883. private _alternateProjectionMatrix;
  87884. private _alternateTransformMatrix;
  87885. private _useAlternateCameraConfiguration;
  87886. private _alternateRendering;
  87887. private _wheelEventName;
  87888. /** @hidden */
  87889. _forcedViewPosition: Nullable<Vector3>;
  87890. /** @hidden */
  87891. readonly _isAlternateRenderingEnabled: boolean;
  87892. private _frustumPlanes;
  87893. /**
  87894. * Gets the list of frustum planes (built from the active camera)
  87895. */
  87896. readonly frustumPlanes: Plane[];
  87897. /**
  87898. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  87899. * This is useful if there are more lights that the maximum simulteanous authorized
  87900. */
  87901. requireLightSorting: boolean;
  87902. /** @hidden */
  87903. readonly useMaterialMeshMap: boolean;
  87904. /** @hidden */
  87905. readonly useClonedMeshhMap: boolean;
  87906. private _pointerOverMesh;
  87907. private _pickedDownMesh;
  87908. private _pickedUpMesh;
  87909. private _externalData;
  87910. private _uid;
  87911. /**
  87912. * @hidden
  87913. * Backing store of defined scene components.
  87914. */
  87915. _components: ISceneComponent[];
  87916. /**
  87917. * @hidden
  87918. * Backing store of defined scene components.
  87919. */
  87920. _serializableComponents: ISceneSerializableComponent[];
  87921. /**
  87922. * List of components to register on the next registration step.
  87923. */
  87924. private _transientComponents;
  87925. /**
  87926. * Registers the transient components if needed.
  87927. */
  87928. private _registerTransientComponents;
  87929. /**
  87930. * @hidden
  87931. * Add a component to the scene.
  87932. * Note that the ccomponent could be registered on th next frame if this is called after
  87933. * the register component stage.
  87934. * @param component Defines the component to add to the scene
  87935. */
  87936. _addComponent(component: ISceneComponent): void;
  87937. /**
  87938. * @hidden
  87939. * Gets a component from the scene.
  87940. * @param name defines the name of the component to retrieve
  87941. * @returns the component or null if not present
  87942. */
  87943. _getComponent(name: string): Nullable<ISceneComponent>;
  87944. /**
  87945. * @hidden
  87946. * Defines the actions happening before camera updates.
  87947. */
  87948. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  87949. /**
  87950. * @hidden
  87951. * Defines the actions happening before clear the canvas.
  87952. */
  87953. _beforeClearStage: Stage<SimpleStageAction>;
  87954. /**
  87955. * @hidden
  87956. * Defines the actions when collecting render targets for the frame.
  87957. */
  87958. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  87959. /**
  87960. * @hidden
  87961. * Defines the actions happening for one camera in the frame.
  87962. */
  87963. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  87964. /**
  87965. * @hidden
  87966. * Defines the actions happening during the per mesh ready checks.
  87967. */
  87968. _isReadyForMeshStage: Stage<MeshStageAction>;
  87969. /**
  87970. * @hidden
  87971. * Defines the actions happening before evaluate active mesh checks.
  87972. */
  87973. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  87974. /**
  87975. * @hidden
  87976. * Defines the actions happening during the evaluate sub mesh checks.
  87977. */
  87978. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  87979. /**
  87980. * @hidden
  87981. * Defines the actions happening during the active mesh stage.
  87982. */
  87983. _activeMeshStage: Stage<ActiveMeshStageAction>;
  87984. /**
  87985. * @hidden
  87986. * Defines the actions happening during the per camera render target step.
  87987. */
  87988. _cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  87989. /**
  87990. * @hidden
  87991. * Defines the actions happening just before the active camera is drawing.
  87992. */
  87993. _beforeCameraDrawStage: Stage<CameraStageAction>;
  87994. /**
  87995. * @hidden
  87996. * Defines the actions happening just before a render target is drawing.
  87997. */
  87998. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  87999. /**
  88000. * @hidden
  88001. * Defines the actions happening just before a rendering group is drawing.
  88002. */
  88003. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88004. /**
  88005. * @hidden
  88006. * Defines the actions happening just before a mesh is drawing.
  88007. */
  88008. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88009. /**
  88010. * @hidden
  88011. * Defines the actions happening just after a mesh has been drawn.
  88012. */
  88013. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  88014. /**
  88015. * @hidden
  88016. * Defines the actions happening just after a rendering group has been drawn.
  88017. */
  88018. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  88019. /**
  88020. * @hidden
  88021. * Defines the actions happening just after the active camera has been drawn.
  88022. */
  88023. _afterCameraDrawStage: Stage<CameraStageAction>;
  88024. /**
  88025. * @hidden
  88026. * Defines the actions happening just after a render target has been drawn.
  88027. */
  88028. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  88029. /**
  88030. * @hidden
  88031. * Defines the actions happening just after rendering all cameras and computing intersections.
  88032. */
  88033. _afterRenderStage: Stage<SimpleStageAction>;
  88034. /**
  88035. * @hidden
  88036. * Defines the actions happening when a pointer move event happens.
  88037. */
  88038. _pointerMoveStage: Stage<PointerMoveStageAction>;
  88039. /**
  88040. * @hidden
  88041. * Defines the actions happening when a pointer down event happens.
  88042. */
  88043. _pointerDownStage: Stage<PointerUpDownStageAction>;
  88044. /**
  88045. * @hidden
  88046. * Defines the actions happening when a pointer up event happens.
  88047. */
  88048. _pointerUpStage: Stage<PointerUpDownStageAction>;
  88049. /**
  88050. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  88051. */
  88052. private geometriesByUniqueId;
  88053. /**
  88054. * Creates a new Scene
  88055. * @param engine defines the engine to use to render this scene
  88056. * @param options defines the scene options
  88057. */
  88058. constructor(engine: Engine, options?: SceneOptions);
  88059. private _defaultMeshCandidates;
  88060. /**
  88061. * @hidden
  88062. */
  88063. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  88064. private _defaultSubMeshCandidates;
  88065. /**
  88066. * @hidden
  88067. */
  88068. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  88069. /**
  88070. * Sets the default candidate providers for the scene.
  88071. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  88072. * and getCollidingSubMeshCandidates to their default function
  88073. */
  88074. setDefaultCandidateProviders(): void;
  88075. /**
  88076. * Gets the mesh that is currently under the pointer
  88077. */
  88078. readonly meshUnderPointer: Nullable<AbstractMesh>;
  88079. /**
  88080. * Gets or sets the current on-screen X position of the pointer
  88081. */
  88082. pointerX: number;
  88083. /**
  88084. * Gets or sets the current on-screen Y position of the pointer
  88085. */
  88086. pointerY: number;
  88087. /**
  88088. * Gets the cached material (ie. the latest rendered one)
  88089. * @returns the cached material
  88090. */
  88091. getCachedMaterial(): Nullable<Material>;
  88092. /**
  88093. * Gets the cached effect (ie. the latest rendered one)
  88094. * @returns the cached effect
  88095. */
  88096. getCachedEffect(): Nullable<Effect>;
  88097. /**
  88098. * Gets the cached visibility state (ie. the latest rendered one)
  88099. * @returns the cached visibility state
  88100. */
  88101. getCachedVisibility(): Nullable<number>;
  88102. /**
  88103. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  88104. * @param material defines the current material
  88105. * @param effect defines the current effect
  88106. * @param visibility defines the current visibility state
  88107. * @returns true if one parameter is not cached
  88108. */
  88109. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  88110. /**
  88111. * Gets the engine associated with the scene
  88112. * @returns an Engine
  88113. */
  88114. getEngine(): Engine;
  88115. /**
  88116. * Gets the total number of vertices rendered per frame
  88117. * @returns the total number of vertices rendered per frame
  88118. */
  88119. getTotalVertices(): number;
  88120. /**
  88121. * Gets the performance counter for total vertices
  88122. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88123. */
  88124. readonly totalVerticesPerfCounter: PerfCounter;
  88125. /**
  88126. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  88127. * @returns the total number of active indices rendered per frame
  88128. */
  88129. getActiveIndices(): number;
  88130. /**
  88131. * Gets the performance counter for active indices
  88132. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88133. */
  88134. readonly totalActiveIndicesPerfCounter: PerfCounter;
  88135. /**
  88136. * Gets the total number of active particles rendered per frame
  88137. * @returns the total number of active particles rendered per frame
  88138. */
  88139. getActiveParticles(): number;
  88140. /**
  88141. * Gets the performance counter for active particles
  88142. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88143. */
  88144. readonly activeParticlesPerfCounter: PerfCounter;
  88145. /**
  88146. * Gets the total number of active bones rendered per frame
  88147. * @returns the total number of active bones rendered per frame
  88148. */
  88149. getActiveBones(): number;
  88150. /**
  88151. * Gets the performance counter for active bones
  88152. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  88153. */
  88154. readonly activeBonesPerfCounter: PerfCounter;
  88155. /**
  88156. * Gets the array of active meshes
  88157. * @returns an array of AbstractMesh
  88158. */
  88159. getActiveMeshes(): SmartArray<AbstractMesh>;
  88160. /**
  88161. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  88162. * @returns a number
  88163. */
  88164. getAnimationRatio(): number;
  88165. /**
  88166. * Gets an unique Id for the current render phase
  88167. * @returns a number
  88168. */
  88169. getRenderId(): number;
  88170. /**
  88171. * Gets an unique Id for the current frame
  88172. * @returns a number
  88173. */
  88174. getFrameId(): number;
  88175. /** Call this function if you want to manually increment the render Id*/
  88176. incrementRenderId(): void;
  88177. private _updatePointerPosition;
  88178. private _createUbo;
  88179. private _createAlternateUbo;
  88180. private _setRayOnPointerInfo;
  88181. /**
  88182. * Use this method to simulate a pointer move on a mesh
  88183. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88184. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88185. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88186. * @returns the current scene
  88187. */
  88188. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88189. private _processPointerMove;
  88190. private _checkPrePointerObservable;
  88191. /**
  88192. * Use this method to simulate a pointer down on a mesh
  88193. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88194. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88195. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88196. * @returns the current scene
  88197. */
  88198. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  88199. private _processPointerDown;
  88200. /**
  88201. * Use this method to simulate a pointer up on a mesh
  88202. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  88203. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  88204. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  88205. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  88206. * @returns the current scene
  88207. */
  88208. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  88209. private _processPointerUp;
  88210. /**
  88211. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  88212. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  88213. * @returns true if the pointer was captured
  88214. */
  88215. isPointerCaptured(pointerId?: number): boolean;
  88216. /** @hidden */
  88217. _isPointerSwiping(): boolean;
  88218. /**
  88219. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  88220. * @param attachUp defines if you want to attach events to pointerup
  88221. * @param attachDown defines if you want to attach events to pointerdown
  88222. * @param attachMove defines if you want to attach events to pointermove
  88223. */
  88224. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  88225. /** Detaches all event handlers*/
  88226. detachControl(): void;
  88227. /**
  88228. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  88229. * Delay loaded resources are not taking in account
  88230. * @return true if all required resources are ready
  88231. */
  88232. isReady(): boolean;
  88233. /** Resets all cached information relative to material (including effect and visibility) */
  88234. resetCachedMaterial(): void;
  88235. /**
  88236. * Registers a function to be called before every frame render
  88237. * @param func defines the function to register
  88238. */
  88239. registerBeforeRender(func: () => void): void;
  88240. /**
  88241. * Unregisters a function called before every frame render
  88242. * @param func defines the function to unregister
  88243. */
  88244. unregisterBeforeRender(func: () => void): void;
  88245. /**
  88246. * Registers a function to be called after every frame render
  88247. * @param func defines the function to register
  88248. */
  88249. registerAfterRender(func: () => void): void;
  88250. /**
  88251. * Unregisters a function called after every frame render
  88252. * @param func defines the function to unregister
  88253. */
  88254. unregisterAfterRender(func: () => void): void;
  88255. private _executeOnceBeforeRender;
  88256. /**
  88257. * The provided function will run before render once and will be disposed afterwards.
  88258. * A timeout delay can be provided so that the function will be executed in N ms.
  88259. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  88260. * @param func The function to be executed.
  88261. * @param timeout optional delay in ms
  88262. */
  88263. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  88264. /** @hidden */
  88265. _addPendingData(data: any): void;
  88266. /** @hidden */
  88267. _removePendingData(data: any): void;
  88268. /**
  88269. * Returns the number of items waiting to be loaded
  88270. * @returns the number of items waiting to be loaded
  88271. */
  88272. getWaitingItemsCount(): number;
  88273. /**
  88274. * Returns a boolean indicating if the scene is still loading data
  88275. */
  88276. readonly isLoading: boolean;
  88277. /**
  88278. * Registers a function to be executed when the scene is ready
  88279. * @param {Function} func - the function to be executed
  88280. */
  88281. executeWhenReady(func: () => void): void;
  88282. /**
  88283. * Returns a promise that resolves when the scene is ready
  88284. * @returns A promise that resolves when the scene is ready
  88285. */
  88286. whenReadyAsync(): Promise<void>;
  88287. /** @hidden */
  88288. _checkIsReady(): void;
  88289. /**
  88290. * Gets all animatable attached to the scene
  88291. */
  88292. readonly animatables: Animatable[];
  88293. /**
  88294. * Resets the last animation time frame.
  88295. * Useful to override when animations start running when loading a scene for the first time.
  88296. */
  88297. resetLastAnimationTimeFrame(): void;
  88298. /** @hidden */
  88299. _switchToAlternateCameraConfiguration(active: boolean): void;
  88300. /**
  88301. * Gets the current view matrix
  88302. * @returns a Matrix
  88303. */
  88304. getViewMatrix(): Matrix;
  88305. /**
  88306. * Gets the current projection matrix
  88307. * @returns a Matrix
  88308. */
  88309. getProjectionMatrix(): Matrix;
  88310. /**
  88311. * Gets the current transform matrix
  88312. * @returns a Matrix made of View * Projection
  88313. */
  88314. getTransformMatrix(): Matrix;
  88315. /**
  88316. * Sets the current transform matrix
  88317. * @param view defines the View matrix to use
  88318. * @param projection defines the Projection matrix to use
  88319. */
  88320. setTransformMatrix(view: Matrix, projection: Matrix): void;
  88321. /** @hidden */
  88322. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  88323. /**
  88324. * Gets the uniform buffer used to store scene data
  88325. * @returns a UniformBuffer
  88326. */
  88327. getSceneUniformBuffer(): UniformBuffer;
  88328. /**
  88329. * Gets an unique (relatively to the current scene) Id
  88330. * @returns an unique number for the scene
  88331. */
  88332. getUniqueId(): number;
  88333. /**
  88334. * Add a mesh to the list of scene's meshes
  88335. * @param newMesh defines the mesh to add
  88336. * @param recursive if all child meshes should also be added to the scene
  88337. */
  88338. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  88339. /**
  88340. * Remove a mesh for the list of scene's meshes
  88341. * @param toRemove defines the mesh to remove
  88342. * @param recursive if all child meshes should also be removed from the scene
  88343. * @returns the index where the mesh was in the mesh list
  88344. */
  88345. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  88346. /**
  88347. * Add a transform node to the list of scene's transform nodes
  88348. * @param newTransformNode defines the transform node to add
  88349. */
  88350. addTransformNode(newTransformNode: TransformNode): void;
  88351. /**
  88352. * Remove a transform node for the list of scene's transform nodes
  88353. * @param toRemove defines the transform node to remove
  88354. * @returns the index where the transform node was in the transform node list
  88355. */
  88356. removeTransformNode(toRemove: TransformNode): number;
  88357. /**
  88358. * Remove a skeleton for the list of scene's skeletons
  88359. * @param toRemove defines the skeleton to remove
  88360. * @returns the index where the skeleton was in the skeleton list
  88361. */
  88362. removeSkeleton(toRemove: Skeleton): number;
  88363. /**
  88364. * Remove a morph target for the list of scene's morph targets
  88365. * @param toRemove defines the morph target to remove
  88366. * @returns the index where the morph target was in the morph target list
  88367. */
  88368. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  88369. /**
  88370. * Remove a light for the list of scene's lights
  88371. * @param toRemove defines the light to remove
  88372. * @returns the index where the light was in the light list
  88373. */
  88374. removeLight(toRemove: Light): number;
  88375. /**
  88376. * Remove a camera for the list of scene's cameras
  88377. * @param toRemove defines the camera to remove
  88378. * @returns the index where the camera was in the camera list
  88379. */
  88380. removeCamera(toRemove: Camera): number;
  88381. /**
  88382. * Remove a particle system for the list of scene's particle systems
  88383. * @param toRemove defines the particle system to remove
  88384. * @returns the index where the particle system was in the particle system list
  88385. */
  88386. removeParticleSystem(toRemove: IParticleSystem): number;
  88387. /**
  88388. * Remove a animation for the list of scene's animations
  88389. * @param toRemove defines the animation to remove
  88390. * @returns the index where the animation was in the animation list
  88391. */
  88392. removeAnimation(toRemove: Animation): number;
  88393. /**
  88394. * Removes the given animation group from this scene.
  88395. * @param toRemove The animation group to remove
  88396. * @returns The index of the removed animation group
  88397. */
  88398. removeAnimationGroup(toRemove: AnimationGroup): number;
  88399. /**
  88400. * Removes the given multi-material from this scene.
  88401. * @param toRemove The multi-material to remove
  88402. * @returns The index of the removed multi-material
  88403. */
  88404. removeMultiMaterial(toRemove: MultiMaterial): number;
  88405. /**
  88406. * Removes the given material from this scene.
  88407. * @param toRemove The material to remove
  88408. * @returns The index of the removed material
  88409. */
  88410. removeMaterial(toRemove: Material): number;
  88411. /**
  88412. * Removes the given action manager from this scene.
  88413. * @param toRemove The action manager to remove
  88414. * @returns The index of the removed action manager
  88415. */
  88416. removeActionManager(toRemove: AbstractActionManager): number;
  88417. /**
  88418. * Removes the given texture from this scene.
  88419. * @param toRemove The texture to remove
  88420. * @returns The index of the removed texture
  88421. */
  88422. removeTexture(toRemove: BaseTexture): number;
  88423. /**
  88424. * Adds the given light to this scene
  88425. * @param newLight The light to add
  88426. */
  88427. addLight(newLight: Light): void;
  88428. /**
  88429. * Sorts the list list based on light priorities
  88430. */
  88431. sortLightsByPriority(): void;
  88432. /**
  88433. * Adds the given camera to this scene
  88434. * @param newCamera The camera to add
  88435. */
  88436. addCamera(newCamera: Camera): void;
  88437. /**
  88438. * Adds the given skeleton to this scene
  88439. * @param newSkeleton The skeleton to add
  88440. */
  88441. addSkeleton(newSkeleton: Skeleton): void;
  88442. /**
  88443. * Adds the given particle system to this scene
  88444. * @param newParticleSystem The particle system to add
  88445. */
  88446. addParticleSystem(newParticleSystem: IParticleSystem): void;
  88447. /**
  88448. * Adds the given animation to this scene
  88449. * @param newAnimation The animation to add
  88450. */
  88451. addAnimation(newAnimation: Animation): void;
  88452. /**
  88453. * Adds the given animation group to this scene.
  88454. * @param newAnimationGroup The animation group to add
  88455. */
  88456. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  88457. /**
  88458. * Adds the given multi-material to this scene
  88459. * @param newMultiMaterial The multi-material to add
  88460. */
  88461. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  88462. /**
  88463. * Adds the given material to this scene
  88464. * @param newMaterial The material to add
  88465. */
  88466. addMaterial(newMaterial: Material): void;
  88467. /**
  88468. * Adds the given morph target to this scene
  88469. * @param newMorphTargetManager The morph target to add
  88470. */
  88471. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  88472. /**
  88473. * Adds the given geometry to this scene
  88474. * @param newGeometry The geometry to add
  88475. */
  88476. addGeometry(newGeometry: Geometry): void;
  88477. /**
  88478. * Adds the given action manager to this scene
  88479. * @param newActionManager The action manager to add
  88480. */
  88481. addActionManager(newActionManager: AbstractActionManager): void;
  88482. /**
  88483. * Adds the given texture to this scene.
  88484. * @param newTexture The texture to add
  88485. */
  88486. addTexture(newTexture: BaseTexture): void;
  88487. /**
  88488. * Switch active camera
  88489. * @param newCamera defines the new active camera
  88490. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  88491. */
  88492. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  88493. /**
  88494. * sets the active camera of the scene using its ID
  88495. * @param id defines the camera's ID
  88496. * @return the new active camera or null if none found.
  88497. */
  88498. setActiveCameraByID(id: string): Nullable<Camera>;
  88499. /**
  88500. * sets the active camera of the scene using its name
  88501. * @param name defines the camera's name
  88502. * @returns the new active camera or null if none found.
  88503. */
  88504. setActiveCameraByName(name: string): Nullable<Camera>;
  88505. /**
  88506. * get an animation group using its name
  88507. * @param name defines the material's name
  88508. * @return the animation group or null if none found.
  88509. */
  88510. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  88511. /**
  88512. * get a material using its id
  88513. * @param id defines the material's ID
  88514. * @return the material or null if none found.
  88515. */
  88516. getMaterialByID(id: string): Nullable<Material>;
  88517. /**
  88518. * Gets a material using its name
  88519. * @param name defines the material's name
  88520. * @return the material or null if none found.
  88521. */
  88522. getMaterialByName(name: string): Nullable<Material>;
  88523. /**
  88524. * Gets a camera using its id
  88525. * @param id defines the id to look for
  88526. * @returns the camera or null if not found
  88527. */
  88528. getCameraByID(id: string): Nullable<Camera>;
  88529. /**
  88530. * Gets a camera using its unique id
  88531. * @param uniqueId defines the unique id to look for
  88532. * @returns the camera or null if not found
  88533. */
  88534. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  88535. /**
  88536. * Gets a camera using its name
  88537. * @param name defines the camera's name
  88538. * @return the camera or null if none found.
  88539. */
  88540. getCameraByName(name: string): Nullable<Camera>;
  88541. /**
  88542. * Gets a bone using its id
  88543. * @param id defines the bone's id
  88544. * @return the bone or null if not found
  88545. */
  88546. getBoneByID(id: string): Nullable<Bone>;
  88547. /**
  88548. * Gets a bone using its id
  88549. * @param name defines the bone's name
  88550. * @return the bone or null if not found
  88551. */
  88552. getBoneByName(name: string): Nullable<Bone>;
  88553. /**
  88554. * Gets a light node using its name
  88555. * @param name defines the the light's name
  88556. * @return the light or null if none found.
  88557. */
  88558. getLightByName(name: string): Nullable<Light>;
  88559. /**
  88560. * Gets a light node using its id
  88561. * @param id defines the light's id
  88562. * @return the light or null if none found.
  88563. */
  88564. getLightByID(id: string): Nullable<Light>;
  88565. /**
  88566. * Gets a light node using its scene-generated unique ID
  88567. * @param uniqueId defines the light's unique id
  88568. * @return the light or null if none found.
  88569. */
  88570. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  88571. /**
  88572. * Gets a particle system by id
  88573. * @param id defines the particle system id
  88574. * @return the corresponding system or null if none found
  88575. */
  88576. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  88577. /**
  88578. * Gets a geometry using its ID
  88579. * @param id defines the geometry's id
  88580. * @return the geometry or null if none found.
  88581. */
  88582. getGeometryByID(id: string): Nullable<Geometry>;
  88583. private _getGeometryByUniqueID;
  88584. /**
  88585. * Add a new geometry to this scene
  88586. * @param geometry defines the geometry to be added to the scene.
  88587. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  88588. * @return a boolean defining if the geometry was added or not
  88589. */
  88590. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  88591. /**
  88592. * Removes an existing geometry
  88593. * @param geometry defines the geometry to be removed from the scene
  88594. * @return a boolean defining if the geometry was removed or not
  88595. */
  88596. removeGeometry(geometry: Geometry): boolean;
  88597. /**
  88598. * Gets the list of geometries attached to the scene
  88599. * @returns an array of Geometry
  88600. */
  88601. getGeometries(): Geometry[];
  88602. /**
  88603. * Gets the first added mesh found of a given ID
  88604. * @param id defines the id to search for
  88605. * @return the mesh found or null if not found at all
  88606. */
  88607. getMeshByID(id: string): Nullable<AbstractMesh>;
  88608. /**
  88609. * Gets a list of meshes using their id
  88610. * @param id defines the id to search for
  88611. * @returns a list of meshes
  88612. */
  88613. getMeshesByID(id: string): Array<AbstractMesh>;
  88614. /**
  88615. * Gets the first added transform node found of a given ID
  88616. * @param id defines the id to search for
  88617. * @return the found transform node or null if not found at all.
  88618. */
  88619. getTransformNodeByID(id: string): Nullable<TransformNode>;
  88620. /**
  88621. * Gets a list of transform nodes using their id
  88622. * @param id defines the id to search for
  88623. * @returns a list of transform nodes
  88624. */
  88625. getTransformNodesByID(id: string): Array<TransformNode>;
  88626. /**
  88627. * Gets a mesh with its auto-generated unique id
  88628. * @param uniqueId defines the unique id to search for
  88629. * @return the found mesh or null if not found at all.
  88630. */
  88631. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  88632. /**
  88633. * Gets a the last added mesh using a given id
  88634. * @param id defines the id to search for
  88635. * @return the found mesh or null if not found at all.
  88636. */
  88637. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  88638. /**
  88639. * Gets a the last added node (Mesh, Camera, Light) using a given id
  88640. * @param id defines the id to search for
  88641. * @return the found node or null if not found at all
  88642. */
  88643. getLastEntryByID(id: string): Nullable<Node>;
  88644. /**
  88645. * Gets a node (Mesh, Camera, Light) using a given id
  88646. * @param id defines the id to search for
  88647. * @return the found node or null if not found at all
  88648. */
  88649. getNodeByID(id: string): Nullable<Node>;
  88650. /**
  88651. * Gets a node (Mesh, Camera, Light) using a given name
  88652. * @param name defines the name to search for
  88653. * @return the found node or null if not found at all.
  88654. */
  88655. getNodeByName(name: string): Nullable<Node>;
  88656. /**
  88657. * Gets a mesh using a given name
  88658. * @param name defines the name to search for
  88659. * @return the found mesh or null if not found at all.
  88660. */
  88661. getMeshByName(name: string): Nullable<AbstractMesh>;
  88662. /**
  88663. * Gets a transform node using a given name
  88664. * @param name defines the name to search for
  88665. * @return the found transform node or null if not found at all.
  88666. */
  88667. getTransformNodeByName(name: string): Nullable<TransformNode>;
  88668. /**
  88669. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  88670. * @param id defines the id to search for
  88671. * @return the found skeleton or null if not found at all.
  88672. */
  88673. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  88674. /**
  88675. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  88676. * @param id defines the id to search for
  88677. * @return the found skeleton or null if not found at all.
  88678. */
  88679. getSkeletonById(id: string): Nullable<Skeleton>;
  88680. /**
  88681. * Gets a skeleton using a given name
  88682. * @param name defines the name to search for
  88683. * @return the found skeleton or null if not found at all.
  88684. */
  88685. getSkeletonByName(name: string): Nullable<Skeleton>;
  88686. /**
  88687. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  88688. * @param id defines the id to search for
  88689. * @return the found morph target manager or null if not found at all.
  88690. */
  88691. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  88692. /**
  88693. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  88694. * @param id defines the id to search for
  88695. * @return the found morph target or null if not found at all.
  88696. */
  88697. getMorphTargetById(id: string): Nullable<MorphTarget>;
  88698. /**
  88699. * Gets a boolean indicating if the given mesh is active
  88700. * @param mesh defines the mesh to look for
  88701. * @returns true if the mesh is in the active list
  88702. */
  88703. isActiveMesh(mesh: AbstractMesh): boolean;
  88704. /**
  88705. * Return a unique id as a string which can serve as an identifier for the scene
  88706. */
  88707. readonly uid: string;
  88708. /**
  88709. * Add an externaly attached data from its key.
  88710. * This method call will fail and return false, if such key already exists.
  88711. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88712. * @param key the unique key that identifies the data
  88713. * @param data the data object to associate to the key for this Engine instance
  88714. * @return true if no such key were already present and the data was added successfully, false otherwise
  88715. */
  88716. addExternalData<T>(key: string, data: T): boolean;
  88717. /**
  88718. * Get an externaly attached data from its key
  88719. * @param key the unique key that identifies the data
  88720. * @return the associated data, if present (can be null), or undefined if not present
  88721. */
  88722. getExternalData<T>(key: string): Nullable<T>;
  88723. /**
  88724. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88725. * @param key the unique key that identifies the data
  88726. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88727. * @return the associated data, can be null if the factory returned null.
  88728. */
  88729. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88730. /**
  88731. * Remove an externaly attached data from the Engine instance
  88732. * @param key the unique key that identifies the data
  88733. * @return true if the data was successfully removed, false if it doesn't exist
  88734. */
  88735. removeExternalData(key: string): boolean;
  88736. private _evaluateSubMesh;
  88737. /**
  88738. * Clear the processed materials smart array preventing retention point in material dispose.
  88739. */
  88740. freeProcessedMaterials(): void;
  88741. private _preventFreeActiveMeshesAndRenderingGroups;
  88742. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  88743. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  88744. * when disposing several meshes in a row or a hierarchy of meshes.
  88745. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  88746. */
  88747. blockfreeActiveMeshesAndRenderingGroups: boolean;
  88748. /**
  88749. * Clear the active meshes smart array preventing retention point in mesh dispose.
  88750. */
  88751. freeActiveMeshes(): void;
  88752. /**
  88753. * Clear the info related to rendering groups preventing retention points during dispose.
  88754. */
  88755. freeRenderingGroups(): void;
  88756. /** @hidden */
  88757. _isInIntermediateRendering(): boolean;
  88758. /**
  88759. * Lambda returning the list of potentially active meshes.
  88760. */
  88761. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  88762. /**
  88763. * Lambda returning the list of potentially active sub meshes.
  88764. */
  88765. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  88766. /**
  88767. * Lambda returning the list of potentially intersecting sub meshes.
  88768. */
  88769. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  88770. /**
  88771. * Lambda returning the list of potentially colliding sub meshes.
  88772. */
  88773. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  88774. private _activeMeshesFrozen;
  88775. /**
  88776. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  88777. * @returns the current scene
  88778. */
  88779. freezeActiveMeshes(): Scene;
  88780. /**
  88781. * Use this function to restart evaluating active meshes on every frame
  88782. * @returns the current scene
  88783. */
  88784. unfreezeActiveMeshes(): Scene;
  88785. private _evaluateActiveMeshes;
  88786. private _activeMesh;
  88787. /**
  88788. * Update the transform matrix to update from the current active camera
  88789. * @param force defines a boolean used to force the update even if cache is up to date
  88790. */
  88791. updateTransformMatrix(force?: boolean): void;
  88792. /**
  88793. * 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)
  88794. * @param alternateCamera defines the camera to use
  88795. */
  88796. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  88797. /** @hidden */
  88798. _allowPostProcessClearColor: boolean;
  88799. private _renderForCamera;
  88800. private _processSubCameras;
  88801. private _checkIntersections;
  88802. /** @hidden */
  88803. _advancePhysicsEngineStep(step: number): void;
  88804. /**
  88805. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  88806. */
  88807. getDeterministicFrameTime: () => number;
  88808. /**
  88809. * Render the scene
  88810. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  88811. */
  88812. render(updateCameras?: boolean): void;
  88813. /**
  88814. * Freeze all materials
  88815. * A frozen material will not be updatable but should be faster to render
  88816. */
  88817. freezeMaterials(): void;
  88818. /**
  88819. * Unfreeze all materials
  88820. * A frozen material will not be updatable but should be faster to render
  88821. */
  88822. unfreezeMaterials(): void;
  88823. /**
  88824. * Releases all held ressources
  88825. */
  88826. dispose(): void;
  88827. /**
  88828. * Gets if the scene is already disposed
  88829. */
  88830. readonly isDisposed: boolean;
  88831. /**
  88832. * Call this function to reduce memory footprint of the scene.
  88833. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  88834. */
  88835. clearCachedVertexData(): void;
  88836. /**
  88837. * This function will remove the local cached buffer data from texture.
  88838. * It will save memory but will prevent the texture from being rebuilt
  88839. */
  88840. cleanCachedTextureBuffer(): void;
  88841. /**
  88842. * Get the world extend vectors with an optional filter
  88843. *
  88844. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  88845. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  88846. */
  88847. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  88848. min: Vector3;
  88849. max: Vector3;
  88850. };
  88851. /**
  88852. * Creates a ray that can be used to pick in the scene
  88853. * @param x defines the x coordinate of the origin (on-screen)
  88854. * @param y defines the y coordinate of the origin (on-screen)
  88855. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88856. * @param camera defines the camera to use for the picking
  88857. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88858. * @returns a Ray
  88859. */
  88860. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  88861. /**
  88862. * Creates a ray that can be used to pick in the scene
  88863. * @param x defines the x coordinate of the origin (on-screen)
  88864. * @param y defines the y coordinate of the origin (on-screen)
  88865. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  88866. * @param result defines the ray where to store the picking ray
  88867. * @param camera defines the camera to use for the picking
  88868. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  88869. * @returns the current scene
  88870. */
  88871. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  88872. /**
  88873. * Creates a ray that can be used to pick in the scene
  88874. * @param x defines the x coordinate of the origin (on-screen)
  88875. * @param y defines the y coordinate of the origin (on-screen)
  88876. * @param camera defines the camera to use for the picking
  88877. * @returns a Ray
  88878. */
  88879. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  88880. /**
  88881. * Creates a ray that can be used to pick in the scene
  88882. * @param x defines the x coordinate of the origin (on-screen)
  88883. * @param y defines the y coordinate of the origin (on-screen)
  88884. * @param result defines the ray where to store the picking ray
  88885. * @param camera defines the camera to use for the picking
  88886. * @returns the current scene
  88887. */
  88888. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  88889. private _internalPick;
  88890. private _internalMultiPick;
  88891. private _tempPickingRay;
  88892. /** Launch a ray to try to pick a mesh in the scene
  88893. * @param x position on screen
  88894. * @param y position on screen
  88895. * @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
  88896. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  88897. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88898. * @returns a PickingInfo
  88899. */
  88900. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  88901. private _cachedRayForTransform;
  88902. /** Use the given ray to pick a mesh in the scene
  88903. * @param ray The ray to use to pick meshes
  88904. * @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
  88905. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  88906. * @returns a PickingInfo
  88907. */
  88908. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  88909. /**
  88910. * Launch a ray to try to pick a mesh in the scene
  88911. * @param x X position on screen
  88912. * @param y Y position on screen
  88913. * @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
  88914. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  88915. * @returns an array of PickingInfo
  88916. */
  88917. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  88918. /**
  88919. * Launch a ray to try to pick a mesh in the scene
  88920. * @param ray Ray to use
  88921. * @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
  88922. * @returns an array of PickingInfo
  88923. */
  88924. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  88925. /**
  88926. * Force the value of meshUnderPointer
  88927. * @param mesh defines the mesh to use
  88928. */
  88929. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  88930. /**
  88931. * Gets the mesh under the pointer
  88932. * @returns a Mesh or null if no mesh is under the pointer
  88933. */
  88934. getPointerOverMesh(): Nullable<AbstractMesh>;
  88935. /** @hidden */
  88936. _rebuildGeometries(): void;
  88937. /** @hidden */
  88938. _rebuildTextures(): void;
  88939. private _getByTags;
  88940. /**
  88941. * Get a list of meshes by tags
  88942. * @param tagsQuery defines the tags query to use
  88943. * @param forEach defines a predicate used to filter results
  88944. * @returns an array of Mesh
  88945. */
  88946. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  88947. /**
  88948. * Get a list of cameras by tags
  88949. * @param tagsQuery defines the tags query to use
  88950. * @param forEach defines a predicate used to filter results
  88951. * @returns an array of Camera
  88952. */
  88953. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  88954. /**
  88955. * Get a list of lights by tags
  88956. * @param tagsQuery defines the tags query to use
  88957. * @param forEach defines a predicate used to filter results
  88958. * @returns an array of Light
  88959. */
  88960. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  88961. /**
  88962. * Get a list of materials by tags
  88963. * @param tagsQuery defines the tags query to use
  88964. * @param forEach defines a predicate used to filter results
  88965. * @returns an array of Material
  88966. */
  88967. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  88968. /**
  88969. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  88970. * This allowed control for front to back rendering or reversly depending of the special needs.
  88971. *
  88972. * @param renderingGroupId The rendering group id corresponding to its index
  88973. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  88974. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  88975. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  88976. */
  88977. 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;
  88978. /**
  88979. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  88980. *
  88981. * @param renderingGroupId The rendering group id corresponding to its index
  88982. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  88983. * @param depth Automatically clears depth between groups if true and autoClear is true.
  88984. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  88985. */
  88986. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  88987. /**
  88988. * Gets the current auto clear configuration for one rendering group of the rendering
  88989. * manager.
  88990. * @param index the rendering group index to get the information for
  88991. * @returns The auto clear setup for the requested rendering group
  88992. */
  88993. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  88994. private _blockMaterialDirtyMechanism;
  88995. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  88996. blockMaterialDirtyMechanism: boolean;
  88997. /**
  88998. * Will flag all materials as dirty to trigger new shader compilation
  88999. * @param flag defines the flag used to specify which material part must be marked as dirty
  89000. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  89001. */
  89002. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89003. /** @hidden */
  89004. _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;
  89005. /** @hidden */
  89006. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  89007. }
  89008. }
  89009. declare module BABYLON {
  89010. /**
  89011. * Set of assets to keep when moving a scene into an asset container.
  89012. */
  89013. export class KeepAssets extends AbstractScene {
  89014. }
  89015. /**
  89016. * Container with a set of assets that can be added or removed from a scene.
  89017. */
  89018. export class AssetContainer extends AbstractScene {
  89019. /**
  89020. * The scene the AssetContainer belongs to.
  89021. */
  89022. scene: Scene;
  89023. /**
  89024. * Instantiates an AssetContainer.
  89025. * @param scene The scene the AssetContainer belongs to.
  89026. */
  89027. constructor(scene: Scene);
  89028. /**
  89029. * Adds all the assets from the container to the scene.
  89030. */
  89031. addAllToScene(): void;
  89032. /**
  89033. * Removes all the assets in the container from the scene
  89034. */
  89035. removeAllFromScene(): void;
  89036. /**
  89037. * Disposes all the assets in the container
  89038. */
  89039. dispose(): void;
  89040. private _moveAssets;
  89041. /**
  89042. * Removes all the assets contained in the scene and adds them to the container.
  89043. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  89044. */
  89045. moveAllFromScene(keepAssets?: KeepAssets): void;
  89046. /**
  89047. * 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.
  89048. * @returns the root mesh
  89049. */
  89050. createRootMesh(): Mesh;
  89051. }
  89052. }
  89053. declare module BABYLON {
  89054. /**
  89055. * Defines how the parser contract is defined.
  89056. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  89057. */
  89058. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  89059. /**
  89060. * Defines how the individual parser contract is defined.
  89061. * These parser can parse an individual asset
  89062. */
  89063. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  89064. /**
  89065. * Base class of the scene acting as a container for the different elements composing a scene.
  89066. * This class is dynamically extended by the different components of the scene increasing
  89067. * flexibility and reducing coupling
  89068. */
  89069. export abstract class AbstractScene {
  89070. /**
  89071. * Stores the list of available parsers in the application.
  89072. */
  89073. private static _BabylonFileParsers;
  89074. /**
  89075. * Stores the list of available individual parsers in the application.
  89076. */
  89077. private static _IndividualBabylonFileParsers;
  89078. /**
  89079. * Adds a parser in the list of available ones
  89080. * @param name Defines the name of the parser
  89081. * @param parser Defines the parser to add
  89082. */
  89083. static AddParser(name: string, parser: BabylonFileParser): void;
  89084. /**
  89085. * Gets a general parser from the list of avaialble ones
  89086. * @param name Defines the name of the parser
  89087. * @returns the requested parser or null
  89088. */
  89089. static GetParser(name: string): Nullable<BabylonFileParser>;
  89090. /**
  89091. * Adds n individual parser in the list of available ones
  89092. * @param name Defines the name of the parser
  89093. * @param parser Defines the parser to add
  89094. */
  89095. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  89096. /**
  89097. * Gets an individual parser from the list of avaialble ones
  89098. * @param name Defines the name of the parser
  89099. * @returns the requested parser or null
  89100. */
  89101. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  89102. /**
  89103. * Parser json data and populate both a scene and its associated container object
  89104. * @param jsonData Defines the data to parse
  89105. * @param scene Defines the scene to parse the data for
  89106. * @param container Defines the container attached to the parsing sequence
  89107. * @param rootUrl Defines the root url of the data
  89108. */
  89109. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  89110. /**
  89111. * Gets the list of root nodes (ie. nodes with no parent)
  89112. */
  89113. rootNodes: Node[];
  89114. /** All of the cameras added to this scene
  89115. * @see http://doc.babylonjs.com/babylon101/cameras
  89116. */
  89117. cameras: Camera[];
  89118. /**
  89119. * All of the lights added to this scene
  89120. * @see http://doc.babylonjs.com/babylon101/lights
  89121. */
  89122. lights: Light[];
  89123. /**
  89124. * All of the (abstract) meshes added to this scene
  89125. */
  89126. meshes: AbstractMesh[];
  89127. /**
  89128. * The list of skeletons added to the scene
  89129. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89130. */
  89131. skeletons: Skeleton[];
  89132. /**
  89133. * All of the particle systems added to this scene
  89134. * @see http://doc.babylonjs.com/babylon101/particles
  89135. */
  89136. particleSystems: IParticleSystem[];
  89137. /**
  89138. * Gets a list of Animations associated with the scene
  89139. */
  89140. animations: Animation[];
  89141. /**
  89142. * All of the animation groups added to this scene
  89143. * @see http://doc.babylonjs.com/how_to/group
  89144. */
  89145. animationGroups: AnimationGroup[];
  89146. /**
  89147. * All of the multi-materials added to this scene
  89148. * @see http://doc.babylonjs.com/how_to/multi_materials
  89149. */
  89150. multiMaterials: MultiMaterial[];
  89151. /**
  89152. * All of the materials added to this scene
  89153. * In the context of a Scene, it is not supposed to be modified manually.
  89154. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  89155. * Note also that the order of the Material wihin the array is not significant and might change.
  89156. * @see http://doc.babylonjs.com/babylon101/materials
  89157. */
  89158. materials: Material[];
  89159. /**
  89160. * The list of morph target managers added to the scene
  89161. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  89162. */
  89163. morphTargetManagers: MorphTargetManager[];
  89164. /**
  89165. * The list of geometries used in the scene.
  89166. */
  89167. geometries: Geometry[];
  89168. /**
  89169. * All of the tranform nodes added to this scene
  89170. * In the context of a Scene, it is not supposed to be modified manually.
  89171. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  89172. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  89173. * @see http://doc.babylonjs.com/how_to/transformnode
  89174. */
  89175. transformNodes: TransformNode[];
  89176. /**
  89177. * ActionManagers available on the scene.
  89178. */
  89179. actionManagers: AbstractActionManager[];
  89180. /**
  89181. * Textures to keep.
  89182. */
  89183. textures: BaseTexture[];
  89184. }
  89185. }
  89186. declare module BABYLON {
  89187. /**
  89188. * Defines a sound that can be played in the application.
  89189. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  89190. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89191. */
  89192. export class Sound {
  89193. /**
  89194. * The name of the sound in the scene.
  89195. */
  89196. name: string;
  89197. /**
  89198. * Does the sound autoplay once loaded.
  89199. */
  89200. autoplay: boolean;
  89201. /**
  89202. * Does the sound loop after it finishes playing once.
  89203. */
  89204. loop: boolean;
  89205. /**
  89206. * Does the sound use a custom attenuation curve to simulate the falloff
  89207. * happening when the source gets further away from the camera.
  89208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89209. */
  89210. useCustomAttenuation: boolean;
  89211. /**
  89212. * The sound track id this sound belongs to.
  89213. */
  89214. soundTrackId: number;
  89215. /**
  89216. * Is this sound currently played.
  89217. */
  89218. isPlaying: boolean;
  89219. /**
  89220. * Is this sound currently paused.
  89221. */
  89222. isPaused: boolean;
  89223. /**
  89224. * Does this sound enables spatial sound.
  89225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89226. */
  89227. spatialSound: boolean;
  89228. /**
  89229. * Define the reference distance the sound should be heard perfectly.
  89230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89231. */
  89232. refDistance: number;
  89233. /**
  89234. * Define the roll off factor of spatial sounds.
  89235. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89236. */
  89237. rolloffFactor: number;
  89238. /**
  89239. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  89240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89241. */
  89242. maxDistance: number;
  89243. /**
  89244. * Define the distance attenuation model the sound will follow.
  89245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89246. */
  89247. distanceModel: string;
  89248. /**
  89249. * @hidden
  89250. * Back Compat
  89251. **/
  89252. onended: () => any;
  89253. /**
  89254. * Observable event when the current playing sound finishes.
  89255. */
  89256. onEndedObservable: Observable<Sound>;
  89257. private _panningModel;
  89258. private _playbackRate;
  89259. private _streaming;
  89260. private _startTime;
  89261. private _startOffset;
  89262. private _position;
  89263. /** @hidden */
  89264. _positionInEmitterSpace: boolean;
  89265. private _localDirection;
  89266. private _volume;
  89267. private _isReadyToPlay;
  89268. private _isDirectional;
  89269. private _readyToPlayCallback;
  89270. private _audioBuffer;
  89271. private _soundSource;
  89272. private _streamingSource;
  89273. private _soundPanner;
  89274. private _soundGain;
  89275. private _inputAudioNode;
  89276. private _outputAudioNode;
  89277. private _coneInnerAngle;
  89278. private _coneOuterAngle;
  89279. private _coneOuterGain;
  89280. private _scene;
  89281. private _connectedTransformNode;
  89282. private _customAttenuationFunction;
  89283. private _registerFunc;
  89284. private _isOutputConnected;
  89285. private _htmlAudioElement;
  89286. private _urlType;
  89287. /** @hidden */
  89288. static _SceneComponentInitialization: (scene: Scene) => void;
  89289. /**
  89290. * Create a sound and attach it to a scene
  89291. * @param name Name of your sound
  89292. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  89293. * @param scene defines the scene the sound belongs to
  89294. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  89295. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  89296. */
  89297. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  89298. /**
  89299. * Release the sound and its associated resources
  89300. */
  89301. dispose(): void;
  89302. /**
  89303. * Gets if the sounds is ready to be played or not.
  89304. * @returns true if ready, otherwise false
  89305. */
  89306. isReady(): boolean;
  89307. private _soundLoaded;
  89308. /**
  89309. * Sets the data of the sound from an audiobuffer
  89310. * @param audioBuffer The audioBuffer containing the data
  89311. */
  89312. setAudioBuffer(audioBuffer: AudioBuffer): void;
  89313. /**
  89314. * Updates the current sounds options such as maxdistance, loop...
  89315. * @param options A JSON object containing values named as the object properties
  89316. */
  89317. updateOptions(options: any): void;
  89318. private _createSpatialParameters;
  89319. private _updateSpatialParameters;
  89320. /**
  89321. * Switch the panning model to HRTF:
  89322. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89324. */
  89325. switchPanningModelToHRTF(): void;
  89326. /**
  89327. * Switch the panning model to Equal Power:
  89328. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89330. */
  89331. switchPanningModelToEqualPower(): void;
  89332. private _switchPanningModel;
  89333. /**
  89334. * Connect this sound to a sound track audio node like gain...
  89335. * @param soundTrackAudioNode the sound track audio node to connect to
  89336. */
  89337. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  89338. /**
  89339. * Transform this sound into a directional source
  89340. * @param coneInnerAngle Size of the inner cone in degree
  89341. * @param coneOuterAngle Size of the outer cone in degree
  89342. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  89343. */
  89344. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  89345. /**
  89346. * Gets or sets the inner angle for the directional cone.
  89347. */
  89348. /**
  89349. * Gets or sets the inner angle for the directional cone.
  89350. */
  89351. directionalConeInnerAngle: number;
  89352. /**
  89353. * Gets or sets the outer angle for the directional cone.
  89354. */
  89355. /**
  89356. * Gets or sets the outer angle for the directional cone.
  89357. */
  89358. directionalConeOuterAngle: number;
  89359. /**
  89360. * Sets the position of the emitter if spatial sound is enabled
  89361. * @param newPosition Defines the new posisiton
  89362. */
  89363. setPosition(newPosition: Vector3): void;
  89364. /**
  89365. * Sets the local direction of the emitter if spatial sound is enabled
  89366. * @param newLocalDirection Defines the new local direction
  89367. */
  89368. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  89369. private _updateDirection;
  89370. /** @hidden */
  89371. updateDistanceFromListener(): void;
  89372. /**
  89373. * Sets a new custom attenuation function for the sound.
  89374. * @param callback Defines the function used for the attenuation
  89375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  89376. */
  89377. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  89378. /**
  89379. * Play the sound
  89380. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  89381. * @param offset (optional) Start the sound setting it at a specific time
  89382. */
  89383. play(time?: number, offset?: number): void;
  89384. private _onended;
  89385. /**
  89386. * Stop the sound
  89387. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  89388. */
  89389. stop(time?: number): void;
  89390. /**
  89391. * Put the sound in pause
  89392. */
  89393. pause(): void;
  89394. /**
  89395. * Sets a dedicated volume for this sounds
  89396. * @param newVolume Define the new volume of the sound
  89397. * @param time Define in how long the sound should be at this value
  89398. */
  89399. setVolume(newVolume: number, time?: number): void;
  89400. /**
  89401. * Set the sound play back rate
  89402. * @param newPlaybackRate Define the playback rate the sound should be played at
  89403. */
  89404. setPlaybackRate(newPlaybackRate: number): void;
  89405. /**
  89406. * Gets the volume of the sound.
  89407. * @returns the volume of the sound
  89408. */
  89409. getVolume(): number;
  89410. /**
  89411. * Attach the sound to a dedicated mesh
  89412. * @param transformNode The transform node to connect the sound with
  89413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89414. */
  89415. attachToMesh(transformNode: TransformNode): void;
  89416. /**
  89417. * Detach the sound from the previously attached mesh
  89418. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  89419. */
  89420. detachFromMesh(): void;
  89421. private _onRegisterAfterWorldMatrixUpdate;
  89422. /**
  89423. * Clone the current sound in the scene.
  89424. * @returns the new sound clone
  89425. */
  89426. clone(): Nullable<Sound>;
  89427. /**
  89428. * Gets the current underlying audio buffer containing the data
  89429. * @returns the audio buffer
  89430. */
  89431. getAudioBuffer(): Nullable<AudioBuffer>;
  89432. /**
  89433. * Serializes the Sound in a JSON representation
  89434. * @returns the JSON representation of the sound
  89435. */
  89436. serialize(): any;
  89437. /**
  89438. * Parse a JSON representation of a sound to innstantiate in a given scene
  89439. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  89440. * @param scene Define the scene the new parsed sound should be created in
  89441. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  89442. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  89443. * @returns the newly parsed sound
  89444. */
  89445. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  89446. }
  89447. }
  89448. declare module BABYLON {
  89449. /**
  89450. * This defines an action helpful to play a defined sound on a triggered action.
  89451. */
  89452. export class PlaySoundAction extends Action {
  89453. private _sound;
  89454. /**
  89455. * Instantiate the action
  89456. * @param triggerOptions defines the trigger options
  89457. * @param sound defines the sound to play
  89458. * @param condition defines the trigger related conditions
  89459. */
  89460. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89461. /** @hidden */
  89462. _prepare(): void;
  89463. /**
  89464. * Execute the action and play the sound.
  89465. */
  89466. execute(): void;
  89467. /**
  89468. * Serializes the actions and its related information.
  89469. * @param parent defines the object to serialize in
  89470. * @returns the serialized object
  89471. */
  89472. serialize(parent: any): any;
  89473. }
  89474. /**
  89475. * This defines an action helpful to stop a defined sound on a triggered action.
  89476. */
  89477. export class StopSoundAction extends Action {
  89478. private _sound;
  89479. /**
  89480. * Instantiate the action
  89481. * @param triggerOptions defines the trigger options
  89482. * @param sound defines the sound to stop
  89483. * @param condition defines the trigger related conditions
  89484. */
  89485. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  89486. /** @hidden */
  89487. _prepare(): void;
  89488. /**
  89489. * Execute the action and stop the sound.
  89490. */
  89491. execute(): void;
  89492. /**
  89493. * Serializes the actions and its related information.
  89494. * @param parent defines the object to serialize in
  89495. * @returns the serialized object
  89496. */
  89497. serialize(parent: any): any;
  89498. }
  89499. }
  89500. declare module BABYLON {
  89501. /**
  89502. * This defines an action responsible to change the value of a property
  89503. * by interpolating between its current value and the newly set one once triggered.
  89504. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  89505. */
  89506. export class InterpolateValueAction extends Action {
  89507. /**
  89508. * Defines the path of the property where the value should be interpolated
  89509. */
  89510. propertyPath: string;
  89511. /**
  89512. * Defines the target value at the end of the interpolation.
  89513. */
  89514. value: any;
  89515. /**
  89516. * Defines the time it will take for the property to interpolate to the value.
  89517. */
  89518. duration: number;
  89519. /**
  89520. * Defines if the other scene animations should be stopped when the action has been triggered
  89521. */
  89522. stopOtherAnimations?: boolean;
  89523. /**
  89524. * Defines a callback raised once the interpolation animation has been done.
  89525. */
  89526. onInterpolationDone?: () => void;
  89527. /**
  89528. * Observable triggered once the interpolation animation has been done.
  89529. */
  89530. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  89531. private _target;
  89532. private _effectiveTarget;
  89533. private _property;
  89534. /**
  89535. * Instantiate the action
  89536. * @param triggerOptions defines the trigger options
  89537. * @param target defines the object containing the value to interpolate
  89538. * @param propertyPath defines the path to the property in the target object
  89539. * @param value defines the target value at the end of the interpolation
  89540. * @param duration deines the time it will take for the property to interpolate to the value.
  89541. * @param condition defines the trigger related conditions
  89542. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  89543. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  89544. */
  89545. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  89546. /** @hidden */
  89547. _prepare(): void;
  89548. /**
  89549. * Execute the action starts the value interpolation.
  89550. */
  89551. execute(): void;
  89552. /**
  89553. * Serializes the actions and its related information.
  89554. * @param parent defines the object to serialize in
  89555. * @returns the serialized object
  89556. */
  89557. serialize(parent: any): any;
  89558. }
  89559. }
  89560. declare module BABYLON {
  89561. /**
  89562. * Options allowed during the creation of a sound track.
  89563. */
  89564. export interface ISoundTrackOptions {
  89565. /**
  89566. * The volume the sound track should take during creation
  89567. */
  89568. volume?: number;
  89569. /**
  89570. * Define if the sound track is the main sound track of the scene
  89571. */
  89572. mainTrack?: boolean;
  89573. }
  89574. /**
  89575. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  89576. * It will be also used in a future release to apply effects on a specific track.
  89577. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89578. */
  89579. export class SoundTrack {
  89580. /**
  89581. * The unique identifier of the sound track in the scene.
  89582. */
  89583. id: number;
  89584. /**
  89585. * The list of sounds included in the sound track.
  89586. */
  89587. soundCollection: Array<Sound>;
  89588. private _outputAudioNode;
  89589. private _scene;
  89590. private _isMainTrack;
  89591. private _connectedAnalyser;
  89592. private _options;
  89593. private _isInitialized;
  89594. /**
  89595. * Creates a new sound track.
  89596. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  89597. * @param scene Define the scene the sound track belongs to
  89598. * @param options
  89599. */
  89600. constructor(scene: Scene, options?: ISoundTrackOptions);
  89601. private _initializeSoundTrackAudioGraph;
  89602. /**
  89603. * Release the sound track and its associated resources
  89604. */
  89605. dispose(): void;
  89606. /**
  89607. * Adds a sound to this sound track
  89608. * @param sound define the cound to add
  89609. * @ignoreNaming
  89610. */
  89611. AddSound(sound: Sound): void;
  89612. /**
  89613. * Removes a sound to this sound track
  89614. * @param sound define the cound to remove
  89615. * @ignoreNaming
  89616. */
  89617. RemoveSound(sound: Sound): void;
  89618. /**
  89619. * Set a global volume for the full sound track.
  89620. * @param newVolume Define the new volume of the sound track
  89621. */
  89622. setVolume(newVolume: number): void;
  89623. /**
  89624. * Switch the panning model to HRTF:
  89625. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  89626. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89627. */
  89628. switchPanningModelToHRTF(): void;
  89629. /**
  89630. * Switch the panning model to Equal Power:
  89631. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  89632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  89633. */
  89634. switchPanningModelToEqualPower(): void;
  89635. /**
  89636. * Connect the sound track to an audio analyser allowing some amazing
  89637. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89639. * @param analyser The analyser to connect to the engine
  89640. */
  89641. connectToAnalyser(analyser: Analyser): void;
  89642. }
  89643. }
  89644. declare module BABYLON {
  89645. interface AbstractScene {
  89646. /**
  89647. * The list of sounds used in the scene.
  89648. */
  89649. sounds: Nullable<Array<Sound>>;
  89650. }
  89651. interface Scene {
  89652. /**
  89653. * @hidden
  89654. * Backing field
  89655. */
  89656. _mainSoundTrack: SoundTrack;
  89657. /**
  89658. * The main sound track played by the scene.
  89659. * It cotains your primary collection of sounds.
  89660. */
  89661. mainSoundTrack: SoundTrack;
  89662. /**
  89663. * The list of sound tracks added to the scene
  89664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89665. */
  89666. soundTracks: Nullable<Array<SoundTrack>>;
  89667. /**
  89668. * Gets a sound using a given name
  89669. * @param name defines the name to search for
  89670. * @return the found sound or null if not found at all.
  89671. */
  89672. getSoundByName(name: string): Nullable<Sound>;
  89673. /**
  89674. * Gets or sets if audio support is enabled
  89675. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89676. */
  89677. audioEnabled: boolean;
  89678. /**
  89679. * Gets or sets if audio will be output to headphones
  89680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89681. */
  89682. headphone: boolean;
  89683. }
  89684. /**
  89685. * Defines the sound scene component responsible to manage any sounds
  89686. * in a given scene.
  89687. */
  89688. export class AudioSceneComponent implements ISceneSerializableComponent {
  89689. /**
  89690. * The component name helpfull to identify the component in the list of scene components.
  89691. */
  89692. readonly name: string;
  89693. /**
  89694. * The scene the component belongs to.
  89695. */
  89696. scene: Scene;
  89697. private _audioEnabled;
  89698. /**
  89699. * Gets whether audio is enabled or not.
  89700. * Please use related enable/disable method to switch state.
  89701. */
  89702. readonly audioEnabled: boolean;
  89703. private _headphone;
  89704. /**
  89705. * Gets whether audio is outputing to headphone or not.
  89706. * Please use the according Switch methods to change output.
  89707. */
  89708. readonly headphone: boolean;
  89709. /**
  89710. * Creates a new instance of the component for the given scene
  89711. * @param scene Defines the scene to register the component in
  89712. */
  89713. constructor(scene: Scene);
  89714. /**
  89715. * Registers the component in a given scene
  89716. */
  89717. register(): void;
  89718. /**
  89719. * Rebuilds the elements related to this component in case of
  89720. * context lost for instance.
  89721. */
  89722. rebuild(): void;
  89723. /**
  89724. * Serializes the component data to the specified json object
  89725. * @param serializationObject The object to serialize to
  89726. */
  89727. serialize(serializationObject: any): void;
  89728. /**
  89729. * Adds all the element from the container to the scene
  89730. * @param container the container holding the elements
  89731. */
  89732. addFromContainer(container: AbstractScene): void;
  89733. /**
  89734. * Removes all the elements in the container from the scene
  89735. * @param container contains the elements to remove
  89736. */
  89737. removeFromContainer(container: AbstractScene): void;
  89738. /**
  89739. * Disposes the component and the associated ressources.
  89740. */
  89741. dispose(): void;
  89742. /**
  89743. * Disables audio in the associated scene.
  89744. */
  89745. disableAudio(): void;
  89746. /**
  89747. * Enables audio in the associated scene.
  89748. */
  89749. enableAudio(): void;
  89750. /**
  89751. * Switch audio to headphone output.
  89752. */
  89753. switchAudioModeForHeadphones(): void;
  89754. /**
  89755. * Switch audio to normal speakers.
  89756. */
  89757. switchAudioModeForNormalSpeakers(): void;
  89758. private _afterRender;
  89759. }
  89760. }
  89761. declare module BABYLON {
  89762. /**
  89763. * Wraps one or more Sound objects and selects one with random weight for playback.
  89764. */
  89765. export class WeightedSound {
  89766. /** When true a Sound will be selected and played when the current playing Sound completes. */
  89767. loop: boolean;
  89768. private _coneInnerAngle;
  89769. private _coneOuterAngle;
  89770. private _volume;
  89771. /** A Sound is currently playing. */
  89772. isPlaying: boolean;
  89773. /** A Sound is currently paused. */
  89774. isPaused: boolean;
  89775. private _sounds;
  89776. private _weights;
  89777. private _currentIndex?;
  89778. /**
  89779. * Creates a new WeightedSound from the list of sounds given.
  89780. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  89781. * @param sounds Array of Sounds that will be selected from.
  89782. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  89783. */
  89784. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  89785. /**
  89786. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  89787. */
  89788. /**
  89789. * The size of cone in degress for a directional sound in which there will be no attenuation.
  89790. */
  89791. directionalConeInnerAngle: number;
  89792. /**
  89793. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89794. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89795. */
  89796. /**
  89797. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  89798. * Listener angles between innerAngle and outerAngle will falloff linearly.
  89799. */
  89800. directionalConeOuterAngle: number;
  89801. /**
  89802. * Playback volume.
  89803. */
  89804. /**
  89805. * Playback volume.
  89806. */
  89807. volume: number;
  89808. private _onended;
  89809. /**
  89810. * Suspend playback
  89811. */
  89812. pause(): void;
  89813. /**
  89814. * Stop playback
  89815. */
  89816. stop(): void;
  89817. /**
  89818. * Start playback.
  89819. * @param startOffset Position the clip head at a specific time in seconds.
  89820. */
  89821. play(startOffset?: number): void;
  89822. }
  89823. }
  89824. declare module BABYLON {
  89825. /**
  89826. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  89827. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  89828. */
  89829. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  89830. /**
  89831. * Gets the name of the behavior.
  89832. */
  89833. readonly name: string;
  89834. /**
  89835. * The easing function used by animations
  89836. */
  89837. static EasingFunction: BackEase;
  89838. /**
  89839. * The easing mode used by animations
  89840. */
  89841. static EasingMode: number;
  89842. /**
  89843. * The duration of the animation, in milliseconds
  89844. */
  89845. transitionDuration: number;
  89846. /**
  89847. * Length of the distance animated by the transition when lower radius is reached
  89848. */
  89849. lowerRadiusTransitionRange: number;
  89850. /**
  89851. * Length of the distance animated by the transition when upper radius is reached
  89852. */
  89853. upperRadiusTransitionRange: number;
  89854. private _autoTransitionRange;
  89855. /**
  89856. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89857. */
  89858. /**
  89859. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  89860. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  89861. */
  89862. autoTransitionRange: boolean;
  89863. private _attachedCamera;
  89864. private _onAfterCheckInputsObserver;
  89865. private _onMeshTargetChangedObserver;
  89866. /**
  89867. * Initializes the behavior.
  89868. */
  89869. init(): void;
  89870. /**
  89871. * Attaches the behavior to its arc rotate camera.
  89872. * @param camera Defines the camera to attach the behavior to
  89873. */
  89874. attach(camera: ArcRotateCamera): void;
  89875. /**
  89876. * Detaches the behavior from its current arc rotate camera.
  89877. */
  89878. detach(): void;
  89879. private _radiusIsAnimating;
  89880. private _radiusBounceTransition;
  89881. private _animatables;
  89882. private _cachedWheelPrecision;
  89883. /**
  89884. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  89885. * @param radiusLimit The limit to check against.
  89886. * @return Bool to indicate if at limit.
  89887. */
  89888. private _isRadiusAtLimit;
  89889. /**
  89890. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  89891. * @param radiusDelta The delta by which to animate to. Can be negative.
  89892. */
  89893. private _applyBoundRadiusAnimation;
  89894. /**
  89895. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  89896. */
  89897. protected _clearAnimationLocks(): void;
  89898. /**
  89899. * Stops and removes all animations that have been applied to the camera
  89900. */
  89901. stopAllAnimations(): void;
  89902. }
  89903. }
  89904. declare module BABYLON {
  89905. /**
  89906. * 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.
  89907. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  89908. */
  89909. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  89910. /**
  89911. * Gets the name of the behavior.
  89912. */
  89913. readonly name: string;
  89914. private _mode;
  89915. private _radiusScale;
  89916. private _positionScale;
  89917. private _defaultElevation;
  89918. private _elevationReturnTime;
  89919. private _elevationReturnWaitTime;
  89920. private _zoomStopsAnimation;
  89921. private _framingTime;
  89922. /**
  89923. * The easing function used by animations
  89924. */
  89925. static EasingFunction: ExponentialEase;
  89926. /**
  89927. * The easing mode used by animations
  89928. */
  89929. static EasingMode: number;
  89930. /**
  89931. * Sets the current mode used by the behavior
  89932. */
  89933. /**
  89934. * Gets current mode used by the behavior.
  89935. */
  89936. mode: number;
  89937. /**
  89938. * Sets the scale applied to the radius (1 by default)
  89939. */
  89940. /**
  89941. * Gets the scale applied to the radius
  89942. */
  89943. radiusScale: number;
  89944. /**
  89945. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  89946. */
  89947. /**
  89948. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  89949. */
  89950. positionScale: number;
  89951. /**
  89952. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  89953. * behaviour is triggered, in radians.
  89954. */
  89955. /**
  89956. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  89957. * behaviour is triggered, in radians.
  89958. */
  89959. defaultElevation: number;
  89960. /**
  89961. * Sets the time (in milliseconds) taken to return to the default beta position.
  89962. * Negative value indicates camera should not return to default.
  89963. */
  89964. /**
  89965. * Gets the time (in milliseconds) taken to return to the default beta position.
  89966. * Negative value indicates camera should not return to default.
  89967. */
  89968. elevationReturnTime: number;
  89969. /**
  89970. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  89971. */
  89972. /**
  89973. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  89974. */
  89975. elevationReturnWaitTime: number;
  89976. /**
  89977. * Sets the flag that indicates if user zooming should stop animation.
  89978. */
  89979. /**
  89980. * Gets the flag that indicates if user zooming should stop animation.
  89981. */
  89982. zoomStopsAnimation: boolean;
  89983. /**
  89984. * Sets the transition time when framing the mesh, in milliseconds
  89985. */
  89986. /**
  89987. * Gets the transition time when framing the mesh, in milliseconds
  89988. */
  89989. framingTime: number;
  89990. /**
  89991. * Define if the behavior should automatically change the configured
  89992. * camera limits and sensibilities.
  89993. */
  89994. autoCorrectCameraLimitsAndSensibility: boolean;
  89995. private _onPrePointerObservableObserver;
  89996. private _onAfterCheckInputsObserver;
  89997. private _onMeshTargetChangedObserver;
  89998. private _attachedCamera;
  89999. private _isPointerDown;
  90000. private _lastInteractionTime;
  90001. /**
  90002. * Initializes the behavior.
  90003. */
  90004. init(): void;
  90005. /**
  90006. * Attaches the behavior to its arc rotate camera.
  90007. * @param camera Defines the camera to attach the behavior to
  90008. */
  90009. attach(camera: ArcRotateCamera): void;
  90010. /**
  90011. * Detaches the behavior from its current arc rotate camera.
  90012. */
  90013. detach(): void;
  90014. private _animatables;
  90015. private _betaIsAnimating;
  90016. private _betaTransition;
  90017. private _radiusTransition;
  90018. private _vectorTransition;
  90019. /**
  90020. * Targets the given mesh and updates zoom level accordingly.
  90021. * @param mesh The mesh to target.
  90022. * @param radius Optional. If a cached radius position already exists, overrides default.
  90023. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90024. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90025. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90026. */
  90027. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90028. /**
  90029. * Targets the given mesh with its children and updates zoom level accordingly.
  90030. * @param mesh The mesh to target.
  90031. * @param radius Optional. If a cached radius position already exists, overrides default.
  90032. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90033. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90034. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90035. */
  90036. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90037. /**
  90038. * Targets the given meshes with their children and updates zoom level accordingly.
  90039. * @param meshes The mesh to target.
  90040. * @param radius Optional. If a cached radius position already exists, overrides default.
  90041. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  90042. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90043. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90044. */
  90045. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90046. /**
  90047. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  90048. * @param minimumWorld Determines the smaller position of the bounding box extend
  90049. * @param maximumWorld Determines the bigger position of the bounding box extend
  90050. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  90051. * @param onAnimationEnd Callback triggered at the end of the framing animation
  90052. */
  90053. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  90054. /**
  90055. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  90056. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  90057. * frustum width.
  90058. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  90059. * to fully enclose the mesh in the viewing frustum.
  90060. */
  90061. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  90062. /**
  90063. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  90064. * is automatically returned to its default position (expected to be above ground plane).
  90065. */
  90066. private _maintainCameraAboveGround;
  90067. /**
  90068. * Returns the frustum slope based on the canvas ratio and camera FOV
  90069. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  90070. */
  90071. private _getFrustumSlope;
  90072. /**
  90073. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  90074. */
  90075. private _clearAnimationLocks;
  90076. /**
  90077. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90078. */
  90079. private _applyUserInteraction;
  90080. /**
  90081. * Stops and removes all animations that have been applied to the camera
  90082. */
  90083. stopAllAnimations(): void;
  90084. /**
  90085. * Gets a value indicating if the user is moving the camera
  90086. */
  90087. readonly isUserIsMoving: boolean;
  90088. /**
  90089. * The camera can move all the way towards the mesh.
  90090. */
  90091. static IgnoreBoundsSizeMode: number;
  90092. /**
  90093. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  90094. */
  90095. static FitFrustumSidesMode: number;
  90096. }
  90097. }
  90098. declare module BABYLON {
  90099. /**
  90100. * Manage the pointers inputs to control an arc rotate camera.
  90101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90102. */
  90103. export class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  90104. /**
  90105. * Defines the camera the input is attached to.
  90106. */
  90107. camera: ArcRotateCamera;
  90108. /**
  90109. * Defines the buttons associated with the input to handle camera move.
  90110. */
  90111. buttons: number[];
  90112. /**
  90113. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90114. */
  90115. angularSensibilityX: number;
  90116. /**
  90117. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90118. */
  90119. angularSensibilityY: number;
  90120. /**
  90121. * Defines the pointer pinch precision or how fast is the camera zooming.
  90122. */
  90123. pinchPrecision: number;
  90124. /**
  90125. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  90126. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90127. */
  90128. pinchDeltaPercentage: number;
  90129. /**
  90130. * Defines the pointer panning sensibility or how fast is the camera moving.
  90131. */
  90132. panningSensibility: number;
  90133. /**
  90134. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  90135. */
  90136. multiTouchPanning: boolean;
  90137. /**
  90138. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  90139. */
  90140. multiTouchPanAndZoom: boolean;
  90141. /**
  90142. * Revers pinch action direction.
  90143. */
  90144. pinchInwards: boolean;
  90145. private _isPanClick;
  90146. private _pointerInput;
  90147. private _observer;
  90148. private _onMouseMove;
  90149. private _onGestureStart;
  90150. private _onGesture;
  90151. private _MSGestureHandler;
  90152. private _onLostFocus;
  90153. private _onContextMenu;
  90154. /**
  90155. * Attach the input controls to a specific dom element to get the input from.
  90156. * @param element Defines the element the controls should be listened from
  90157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90158. */
  90159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90160. /**
  90161. * Detach the current controls from the specified dom element.
  90162. * @param element Defines the element to stop listening the inputs from
  90163. */
  90164. detachControl(element: Nullable<HTMLElement>): void;
  90165. /**
  90166. * Gets the class name of the current intput.
  90167. * @returns the class name
  90168. */
  90169. getClassName(): string;
  90170. /**
  90171. * Get the friendly name associated with the input class.
  90172. * @returns the input friendly name
  90173. */
  90174. getSimpleName(): string;
  90175. }
  90176. }
  90177. declare module BABYLON {
  90178. /**
  90179. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  90180. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90181. */
  90182. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  90183. /**
  90184. * Defines the camera the input is attached to.
  90185. */
  90186. camera: ArcRotateCamera;
  90187. /**
  90188. * Defines the list of key codes associated with the up action (increase alpha)
  90189. */
  90190. keysUp: number[];
  90191. /**
  90192. * Defines the list of key codes associated with the down action (decrease alpha)
  90193. */
  90194. keysDown: number[];
  90195. /**
  90196. * Defines the list of key codes associated with the left action (increase beta)
  90197. */
  90198. keysLeft: number[];
  90199. /**
  90200. * Defines the list of key codes associated with the right action (decrease beta)
  90201. */
  90202. keysRight: number[];
  90203. /**
  90204. * Defines the list of key codes associated with the reset action.
  90205. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  90206. */
  90207. keysReset: number[];
  90208. /**
  90209. * Defines the panning sensibility of the inputs.
  90210. * (How fast is the camera paning)
  90211. */
  90212. panningSensibility: number;
  90213. /**
  90214. * Defines the zooming sensibility of the inputs.
  90215. * (How fast is the camera zooming)
  90216. */
  90217. zoomingSensibility: number;
  90218. /**
  90219. * Defines wether maintaining the alt key down switch the movement mode from
  90220. * orientation to zoom.
  90221. */
  90222. useAltToZoom: boolean;
  90223. /**
  90224. * Rotation speed of the camera
  90225. */
  90226. angularSpeed: number;
  90227. private _keys;
  90228. private _ctrlPressed;
  90229. private _altPressed;
  90230. private _onCanvasBlurObserver;
  90231. private _onKeyboardObserver;
  90232. private _engine;
  90233. private _scene;
  90234. /**
  90235. * Attach the input controls to a specific dom element to get the input from.
  90236. * @param element Defines the element the controls should be listened from
  90237. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90238. */
  90239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90240. /**
  90241. * Detach the current controls from the specified dom element.
  90242. * @param element Defines the element to stop listening the inputs from
  90243. */
  90244. detachControl(element: Nullable<HTMLElement>): void;
  90245. /**
  90246. * Update the current camera state depending on the inputs that have been used this frame.
  90247. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  90248. */
  90249. checkInputs(): void;
  90250. /**
  90251. * Gets the class name of the current intput.
  90252. * @returns the class name
  90253. */
  90254. getClassName(): string;
  90255. /**
  90256. * Get the friendly name associated with the input class.
  90257. * @returns the input friendly name
  90258. */
  90259. getSimpleName(): string;
  90260. }
  90261. }
  90262. declare module BABYLON {
  90263. /**
  90264. * Manage the mouse wheel inputs to control an arc rotate camera.
  90265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90266. */
  90267. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  90268. /**
  90269. * Defines the camera the input is attached to.
  90270. */
  90271. camera: ArcRotateCamera;
  90272. /**
  90273. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90274. */
  90275. wheelPrecision: number;
  90276. /**
  90277. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  90278. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  90279. */
  90280. wheelDeltaPercentage: number;
  90281. private _wheel;
  90282. private _observer;
  90283. /**
  90284. * Attach the input controls to a specific dom element to get the input from.
  90285. * @param element Defines the element the controls should be listened from
  90286. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90287. */
  90288. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  90289. /**
  90290. * Detach the current controls from the specified dom element.
  90291. * @param element Defines the element to stop listening the inputs from
  90292. */
  90293. detachControl(element: Nullable<HTMLElement>): void;
  90294. /**
  90295. * Gets the class name of the current intput.
  90296. * @returns the class name
  90297. */
  90298. getClassName(): string;
  90299. /**
  90300. * Get the friendly name associated with the input class.
  90301. * @returns the input friendly name
  90302. */
  90303. getSimpleName(): string;
  90304. }
  90305. }
  90306. declare module BABYLON {
  90307. /**
  90308. * Default Inputs manager for the ArcRotateCamera.
  90309. * It groups all the default supported inputs for ease of use.
  90310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  90311. */
  90312. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  90313. /**
  90314. * Instantiates a new ArcRotateCameraInputsManager.
  90315. * @param camera Defines the camera the inputs belong to
  90316. */
  90317. constructor(camera: ArcRotateCamera);
  90318. /**
  90319. * Add mouse wheel input support to the input manager.
  90320. * @returns the current input manager
  90321. */
  90322. addMouseWheel(): ArcRotateCameraInputsManager;
  90323. /**
  90324. * Add pointers input support to the input manager.
  90325. * @returns the current input manager
  90326. */
  90327. addPointers(): ArcRotateCameraInputsManager;
  90328. /**
  90329. * Add keyboard input support to the input manager.
  90330. * @returns the current input manager
  90331. */
  90332. addKeyboard(): ArcRotateCameraInputsManager;
  90333. }
  90334. }
  90335. declare module BABYLON {
  90336. /**
  90337. * This represents an orbital type of camera.
  90338. *
  90339. * 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.
  90340. * 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.
  90341. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  90342. */
  90343. export class ArcRotateCamera extends TargetCamera {
  90344. /**
  90345. * Defines the rotation angle of the camera along the longitudinal axis.
  90346. */
  90347. alpha: number;
  90348. /**
  90349. * Defines the rotation angle of the camera along the latitudinal axis.
  90350. */
  90351. beta: number;
  90352. /**
  90353. * Defines the radius of the camera from it s target point.
  90354. */
  90355. radius: number;
  90356. protected _target: Vector3;
  90357. protected _targetHost: Nullable<AbstractMesh>;
  90358. /**
  90359. * Defines the target point of the camera.
  90360. * The camera looks towards it form the radius distance.
  90361. */
  90362. target: Vector3;
  90363. /**
  90364. * Current inertia value on the longitudinal axis.
  90365. * The bigger this number the longer it will take for the camera to stop.
  90366. */
  90367. inertialAlphaOffset: number;
  90368. /**
  90369. * Current inertia value on the latitudinal axis.
  90370. * The bigger this number the longer it will take for the camera to stop.
  90371. */
  90372. inertialBetaOffset: number;
  90373. /**
  90374. * Current inertia value on the radius axis.
  90375. * The bigger this number the longer it will take for the camera to stop.
  90376. */
  90377. inertialRadiusOffset: number;
  90378. /**
  90379. * Minimum allowed angle on the longitudinal axis.
  90380. * This can help limiting how the Camera is able to move in the scene.
  90381. */
  90382. lowerAlphaLimit: Nullable<number>;
  90383. /**
  90384. * Maximum allowed angle on the longitudinal axis.
  90385. * This can help limiting how the Camera is able to move in the scene.
  90386. */
  90387. upperAlphaLimit: Nullable<number>;
  90388. /**
  90389. * Minimum allowed angle on the latitudinal axis.
  90390. * This can help limiting how the Camera is able to move in the scene.
  90391. */
  90392. lowerBetaLimit: number;
  90393. /**
  90394. * Maximum allowed angle on the latitudinal axis.
  90395. * This can help limiting how the Camera is able to move in the scene.
  90396. */
  90397. upperBetaLimit: number;
  90398. /**
  90399. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  90400. * This can help limiting how the Camera is able to move in the scene.
  90401. */
  90402. lowerRadiusLimit: Nullable<number>;
  90403. /**
  90404. * Maximum allowed distance of the camera to the target (The camera can not get further).
  90405. * This can help limiting how the Camera is able to move in the scene.
  90406. */
  90407. upperRadiusLimit: Nullable<number>;
  90408. /**
  90409. * Defines the current inertia value used during panning of the camera along the X axis.
  90410. */
  90411. inertialPanningX: number;
  90412. /**
  90413. * Defines the current inertia value used during panning of the camera along the Y axis.
  90414. */
  90415. inertialPanningY: number;
  90416. /**
  90417. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  90418. * Basically if your fingers moves away from more than this distance you will be considered
  90419. * in pinch mode.
  90420. */
  90421. pinchToPanMaxDistance: number;
  90422. /**
  90423. * Defines the maximum distance the camera can pan.
  90424. * This could help keeping the cammera always in your scene.
  90425. */
  90426. panningDistanceLimit: Nullable<number>;
  90427. /**
  90428. * Defines the target of the camera before paning.
  90429. */
  90430. panningOriginTarget: Vector3;
  90431. /**
  90432. * Defines the value of the inertia used during panning.
  90433. * 0 would mean stop inertia and one would mean no decelleration at all.
  90434. */
  90435. panningInertia: number;
  90436. /**
  90437. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  90438. */
  90439. angularSensibilityX: number;
  90440. /**
  90441. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  90442. */
  90443. angularSensibilityY: number;
  90444. /**
  90445. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  90446. */
  90447. pinchPrecision: number;
  90448. /**
  90449. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  90450. * It will be used instead of pinchDeltaPrecision if different from 0.
  90451. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90452. */
  90453. pinchDeltaPercentage: number;
  90454. /**
  90455. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  90456. */
  90457. panningSensibility: number;
  90458. /**
  90459. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  90460. */
  90461. keysUp: number[];
  90462. /**
  90463. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  90464. */
  90465. keysDown: number[];
  90466. /**
  90467. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  90468. */
  90469. keysLeft: number[];
  90470. /**
  90471. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  90472. */
  90473. keysRight: number[];
  90474. /**
  90475. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  90476. */
  90477. wheelPrecision: number;
  90478. /**
  90479. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  90480. * It will be used instead of pinchDeltaPrecision if different from 0.
  90481. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  90482. */
  90483. wheelDeltaPercentage: number;
  90484. /**
  90485. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  90486. */
  90487. zoomOnFactor: number;
  90488. /**
  90489. * Defines a screen offset for the camera position.
  90490. */
  90491. targetScreenOffset: Vector2;
  90492. /**
  90493. * Allows the camera to be completely reversed.
  90494. * If false the camera can not arrive upside down.
  90495. */
  90496. allowUpsideDown: boolean;
  90497. /**
  90498. * Define if double tap/click is used to restore the previously saved state of the camera.
  90499. */
  90500. useInputToRestoreState: boolean;
  90501. /** @hidden */
  90502. _viewMatrix: Matrix;
  90503. /** @hidden */
  90504. _useCtrlForPanning: boolean;
  90505. /** @hidden */
  90506. _panningMouseButton: number;
  90507. /**
  90508. * Defines the input associated to the camera.
  90509. */
  90510. inputs: ArcRotateCameraInputsManager;
  90511. /** @hidden */
  90512. _reset: () => void;
  90513. /**
  90514. * Defines the allowed panning axis.
  90515. */
  90516. panningAxis: Vector3;
  90517. protected _localDirection: Vector3;
  90518. protected _transformedDirection: Vector3;
  90519. private _bouncingBehavior;
  90520. /**
  90521. * Gets the bouncing behavior of the camera if it has been enabled.
  90522. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90523. */
  90524. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  90525. /**
  90526. * Defines if the bouncing behavior of the camera is enabled on the camera.
  90527. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  90528. */
  90529. useBouncingBehavior: boolean;
  90530. private _framingBehavior;
  90531. /**
  90532. * Gets the framing behavior of the camera if it has been enabled.
  90533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90534. */
  90535. readonly framingBehavior: Nullable<FramingBehavior>;
  90536. /**
  90537. * Defines if the framing behavior of the camera is enabled on the camera.
  90538. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  90539. */
  90540. useFramingBehavior: boolean;
  90541. private _autoRotationBehavior;
  90542. /**
  90543. * Gets the auto rotation behavior of the camera if it has been enabled.
  90544. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90545. */
  90546. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  90547. /**
  90548. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  90549. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90550. */
  90551. useAutoRotationBehavior: boolean;
  90552. /**
  90553. * Observable triggered when the mesh target has been changed on the camera.
  90554. */
  90555. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  90556. /**
  90557. * Event raised when the camera is colliding with a mesh.
  90558. */
  90559. onCollide: (collidedMesh: AbstractMesh) => void;
  90560. /**
  90561. * Defines whether the camera should check collision with the objects oh the scene.
  90562. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  90563. */
  90564. checkCollisions: boolean;
  90565. /**
  90566. * Defines the collision radius of the camera.
  90567. * This simulates a sphere around the camera.
  90568. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  90569. */
  90570. collisionRadius: Vector3;
  90571. protected _collider: Collider;
  90572. protected _previousPosition: Vector3;
  90573. protected _collisionVelocity: Vector3;
  90574. protected _newPosition: Vector3;
  90575. protected _previousAlpha: number;
  90576. protected _previousBeta: number;
  90577. protected _previousRadius: number;
  90578. protected _collisionTriggered: boolean;
  90579. protected _targetBoundingCenter: Nullable<Vector3>;
  90580. private _computationVector;
  90581. private _tempAxisVector;
  90582. private _tempAxisRotationMatrix;
  90583. /**
  90584. * Instantiates a new ArcRotateCamera in a given scene
  90585. * @param name Defines the name of the camera
  90586. * @param alpha Defines the camera rotation along the logitudinal axis
  90587. * @param beta Defines the camera rotation along the latitudinal axis
  90588. * @param radius Defines the camera distance from its target
  90589. * @param target Defines the camera target
  90590. * @param scene Defines the scene the camera belongs to
  90591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  90592. */
  90593. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  90594. /** @hidden */
  90595. _initCache(): void;
  90596. /** @hidden */
  90597. _updateCache(ignoreParentClass?: boolean): void;
  90598. protected _getTargetPosition(): Vector3;
  90599. private _storedAlpha;
  90600. private _storedBeta;
  90601. private _storedRadius;
  90602. private _storedTarget;
  90603. /**
  90604. * Stores the current state of the camera (alpha, beta, radius and target)
  90605. * @returns the camera itself
  90606. */
  90607. storeState(): Camera;
  90608. /**
  90609. * @hidden
  90610. * Restored camera state. You must call storeState() first
  90611. */
  90612. _restoreStateValues(): boolean;
  90613. /** @hidden */
  90614. _isSynchronizedViewMatrix(): boolean;
  90615. /**
  90616. * Attached controls to the current camera.
  90617. * @param element Defines the element the controls should be listened from
  90618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  90619. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  90620. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  90621. */
  90622. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  90623. /**
  90624. * Detach the current controls from the camera.
  90625. * The camera will stop reacting to inputs.
  90626. * @param element Defines the element to stop listening the inputs from
  90627. */
  90628. detachControl(element: HTMLElement): void;
  90629. /** @hidden */
  90630. _checkInputs(): void;
  90631. protected _checkLimits(): void;
  90632. /**
  90633. * Rebuilds angles (alpha, beta) and radius from the give position and target.
  90634. */
  90635. rebuildAnglesAndRadius(): void;
  90636. /**
  90637. * Use a position to define the current camera related information like aplha, beta and radius
  90638. * @param position Defines the position to set the camera at
  90639. */
  90640. setPosition(position: Vector3): void;
  90641. /**
  90642. * Defines the target the camera should look at.
  90643. * This will automatically adapt alpha beta and radius to fit within the new target.
  90644. * @param target Defines the new target as a Vector or a mesh
  90645. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  90646. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  90647. */
  90648. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  90649. /** @hidden */
  90650. _getViewMatrix(): Matrix;
  90651. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  90652. /**
  90653. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  90654. * @param meshes Defines the mesh to zoom on
  90655. * @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)
  90656. */
  90657. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  90658. /**
  90659. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  90660. * The target will be changed but the radius
  90661. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  90662. * @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)
  90663. */
  90664. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  90665. min: Vector3;
  90666. max: Vector3;
  90667. distance: number;
  90668. }, doNotUpdateMaxZ?: boolean): void;
  90669. /**
  90670. * @override
  90671. * Override Camera.createRigCamera
  90672. */
  90673. createRigCamera(name: string, cameraIndex: number): Camera;
  90674. /**
  90675. * @hidden
  90676. * @override
  90677. * Override Camera._updateRigCameras
  90678. */
  90679. _updateRigCameras(): void;
  90680. /**
  90681. * Destroy the camera and release the current resources hold by it.
  90682. */
  90683. dispose(): void;
  90684. /**
  90685. * Gets the current object class name.
  90686. * @return the class name
  90687. */
  90688. getClassName(): string;
  90689. }
  90690. }
  90691. declare module BABYLON {
  90692. /**
  90693. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  90694. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  90695. */
  90696. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  90697. /**
  90698. * Gets the name of the behavior.
  90699. */
  90700. readonly name: string;
  90701. private _zoomStopsAnimation;
  90702. private _idleRotationSpeed;
  90703. private _idleRotationWaitTime;
  90704. private _idleRotationSpinupTime;
  90705. /**
  90706. * Sets the flag that indicates if user zooming should stop animation.
  90707. */
  90708. /**
  90709. * Gets the flag that indicates if user zooming should stop animation.
  90710. */
  90711. zoomStopsAnimation: boolean;
  90712. /**
  90713. * Sets the default speed at which the camera rotates around the model.
  90714. */
  90715. /**
  90716. * Gets the default speed at which the camera rotates around the model.
  90717. */
  90718. idleRotationSpeed: number;
  90719. /**
  90720. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  90721. */
  90722. /**
  90723. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  90724. */
  90725. idleRotationWaitTime: number;
  90726. /**
  90727. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90728. */
  90729. /**
  90730. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  90731. */
  90732. idleRotationSpinupTime: number;
  90733. /**
  90734. * Gets a value indicating if the camera is currently rotating because of this behavior
  90735. */
  90736. readonly rotationInProgress: boolean;
  90737. private _onPrePointerObservableObserver;
  90738. private _onAfterCheckInputsObserver;
  90739. private _attachedCamera;
  90740. private _isPointerDown;
  90741. private _lastFrameTime;
  90742. private _lastInteractionTime;
  90743. private _cameraRotationSpeed;
  90744. /**
  90745. * Initializes the behavior.
  90746. */
  90747. init(): void;
  90748. /**
  90749. * Attaches the behavior to its arc rotate camera.
  90750. * @param camera Defines the camera to attach the behavior to
  90751. */
  90752. attach(camera: ArcRotateCamera): void;
  90753. /**
  90754. * Detaches the behavior from its current arc rotate camera.
  90755. */
  90756. detach(): void;
  90757. /**
  90758. * Returns true if user is scrolling.
  90759. * @return true if user is scrolling.
  90760. */
  90761. private _userIsZooming;
  90762. private _lastFrameRadius;
  90763. private _shouldAnimationStopForInteraction;
  90764. /**
  90765. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  90766. */
  90767. private _applyUserInteraction;
  90768. private _userIsMoving;
  90769. }
  90770. }
  90771. declare module BABYLON {
  90772. /**
  90773. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  90774. */
  90775. export class AttachToBoxBehavior implements Behavior<Mesh> {
  90776. private ui;
  90777. /**
  90778. * The name of the behavior
  90779. */
  90780. name: string;
  90781. /**
  90782. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  90783. */
  90784. distanceAwayFromFace: number;
  90785. /**
  90786. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  90787. */
  90788. distanceAwayFromBottomOfFace: number;
  90789. private _faceVectors;
  90790. private _target;
  90791. private _scene;
  90792. private _onRenderObserver;
  90793. private _tmpMatrix;
  90794. private _tmpVector;
  90795. /**
  90796. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  90797. * @param ui The transform node that should be attched to the mesh
  90798. */
  90799. constructor(ui: TransformNode);
  90800. /**
  90801. * Initializes the behavior
  90802. */
  90803. init(): void;
  90804. private _closestFace;
  90805. private _zeroVector;
  90806. private _lookAtTmpMatrix;
  90807. private _lookAtToRef;
  90808. /**
  90809. * Attaches the AttachToBoxBehavior to the passed in mesh
  90810. * @param target The mesh that the specified node will be attached to
  90811. */
  90812. attach(target: Mesh): void;
  90813. /**
  90814. * Detaches the behavior from the mesh
  90815. */
  90816. detach(): void;
  90817. }
  90818. }
  90819. declare module BABYLON {
  90820. /**
  90821. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  90822. */
  90823. export class FadeInOutBehavior implements Behavior<Mesh> {
  90824. /**
  90825. * Time in milliseconds to delay before fading in (Default: 0)
  90826. */
  90827. delay: number;
  90828. /**
  90829. * Time in milliseconds for the mesh to fade in (Default: 300)
  90830. */
  90831. fadeInTime: number;
  90832. private _millisecondsPerFrame;
  90833. private _hovered;
  90834. private _hoverValue;
  90835. private _ownerNode;
  90836. /**
  90837. * Instatiates the FadeInOutBehavior
  90838. */
  90839. constructor();
  90840. /**
  90841. * The name of the behavior
  90842. */
  90843. readonly name: string;
  90844. /**
  90845. * Initializes the behavior
  90846. */
  90847. init(): void;
  90848. /**
  90849. * Attaches the fade behavior on the passed in mesh
  90850. * @param ownerNode The mesh that will be faded in/out once attached
  90851. */
  90852. attach(ownerNode: Mesh): void;
  90853. /**
  90854. * Detaches the behavior from the mesh
  90855. */
  90856. detach(): void;
  90857. /**
  90858. * Triggers the mesh to begin fading in or out
  90859. * @param value if the object should fade in or out (true to fade in)
  90860. */
  90861. fadeIn(value: boolean): void;
  90862. private _update;
  90863. private _setAllVisibility;
  90864. }
  90865. }
  90866. declare module BABYLON {
  90867. /**
  90868. * Class containing a set of static utilities functions for managing Pivots
  90869. * @hidden
  90870. */
  90871. export class PivotTools {
  90872. private static _PivotCached;
  90873. private static _OldPivotPoint;
  90874. private static _PivotTranslation;
  90875. private static _PivotTmpVector;
  90876. /** @hidden */
  90877. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  90878. /** @hidden */
  90879. static _RestorePivotPoint(mesh: AbstractMesh): void;
  90880. }
  90881. }
  90882. declare module BABYLON {
  90883. /**
  90884. * Class containing static functions to help procedurally build meshes
  90885. */
  90886. export class PlaneBuilder {
  90887. /**
  90888. * Creates a plane mesh
  90889. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  90890. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  90891. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  90892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  90893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  90894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  90895. * @param name defines the name of the mesh
  90896. * @param options defines the options used to create the mesh
  90897. * @param scene defines the hosting scene
  90898. * @returns the plane mesh
  90899. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  90900. */
  90901. static CreatePlane(name: string, options: {
  90902. size?: number;
  90903. width?: number;
  90904. height?: number;
  90905. sideOrientation?: number;
  90906. frontUVs?: Vector4;
  90907. backUVs?: Vector4;
  90908. updatable?: boolean;
  90909. sourcePlane?: Plane;
  90910. }, scene: Scene): Mesh;
  90911. }
  90912. }
  90913. declare module BABYLON {
  90914. /**
  90915. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  90916. */
  90917. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  90918. private static _AnyMouseID;
  90919. private _attachedNode;
  90920. private _dragPlane;
  90921. private _scene;
  90922. private _pointerObserver;
  90923. private _beforeRenderObserver;
  90924. private static _planeScene;
  90925. /**
  90926. * 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)
  90927. */
  90928. maxDragAngle: number;
  90929. /**
  90930. * @hidden
  90931. */
  90932. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  90933. /**
  90934. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  90935. */
  90936. currentDraggingPointerID: number;
  90937. /**
  90938. * The last position where the pointer hit the drag plane in world space
  90939. */
  90940. lastDragPosition: Vector3;
  90941. /**
  90942. * If the behavior is currently in a dragging state
  90943. */
  90944. dragging: boolean;
  90945. /**
  90946. * 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)
  90947. */
  90948. dragDeltaRatio: number;
  90949. /**
  90950. * If the drag plane orientation should be updated during the dragging (Default: true)
  90951. */
  90952. updateDragPlane: boolean;
  90953. private _debugMode;
  90954. private _moving;
  90955. /**
  90956. * Fires each time the attached mesh is dragged with the pointer
  90957. * * delta between last drag position and current drag position in world space
  90958. * * dragDistance along the drag axis
  90959. * * dragPlaneNormal normal of the current drag plane used during the drag
  90960. * * dragPlanePoint in world space where the drag intersects the drag plane
  90961. */
  90962. onDragObservable: Observable<{
  90963. delta: Vector3;
  90964. dragPlanePoint: Vector3;
  90965. dragPlaneNormal: Vector3;
  90966. dragDistance: number;
  90967. pointerId: number;
  90968. }>;
  90969. /**
  90970. * Fires each time a drag begins (eg. mouse down on mesh)
  90971. */
  90972. onDragStartObservable: Observable<{
  90973. dragPlanePoint: Vector3;
  90974. pointerId: number;
  90975. }>;
  90976. /**
  90977. * Fires each time a drag ends (eg. mouse release after drag)
  90978. */
  90979. onDragEndObservable: Observable<{
  90980. dragPlanePoint: Vector3;
  90981. pointerId: number;
  90982. }>;
  90983. /**
  90984. * If the attached mesh should be moved when dragged
  90985. */
  90986. moveAttached: boolean;
  90987. /**
  90988. * If the drag behavior will react to drag events (Default: true)
  90989. */
  90990. enabled: boolean;
  90991. /**
  90992. * If camera controls should be detached during the drag
  90993. */
  90994. detachCameraControls: boolean;
  90995. /**
  90996. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  90997. */
  90998. useObjectOrienationForDragging: boolean;
  90999. private _options;
  91000. /**
  91001. * Creates a pointer drag behavior that can be attached to a mesh
  91002. * @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)
  91003. */
  91004. constructor(options?: {
  91005. dragAxis?: Vector3;
  91006. dragPlaneNormal?: Vector3;
  91007. });
  91008. /**
  91009. * Predicate to determine if it is valid to move the object to a new position when it is moved
  91010. */
  91011. validateDrag: (targetPosition: Vector3) => boolean;
  91012. /**
  91013. * The name of the behavior
  91014. */
  91015. readonly name: string;
  91016. /**
  91017. * Initializes the behavior
  91018. */
  91019. init(): void;
  91020. private _tmpVector;
  91021. private _alternatePickedPoint;
  91022. private _worldDragAxis;
  91023. private _targetPosition;
  91024. private _attachedElement;
  91025. /**
  91026. * Attaches the drag behavior the passed in mesh
  91027. * @param ownerNode The mesh that will be dragged around once attached
  91028. */
  91029. attach(ownerNode: AbstractMesh): void;
  91030. /**
  91031. * Force relase the drag action by code.
  91032. */
  91033. releaseDrag(): void;
  91034. private _startDragRay;
  91035. private _lastPointerRay;
  91036. /**
  91037. * Simulates the start of a pointer drag event on the behavior
  91038. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  91039. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  91040. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  91041. */
  91042. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  91043. private _startDrag;
  91044. private _dragDelta;
  91045. private _moveDrag;
  91046. private _pickWithRayOnDragPlane;
  91047. private _pointA;
  91048. private _pointB;
  91049. private _pointC;
  91050. private _lineA;
  91051. private _lineB;
  91052. private _localAxis;
  91053. private _lookAt;
  91054. private _updateDragPlanePosition;
  91055. /**
  91056. * Detaches the behavior from the mesh
  91057. */
  91058. detach(): void;
  91059. }
  91060. }
  91061. declare module BABYLON {
  91062. /**
  91063. * A behavior that when attached to a mesh will allow the mesh to be scaled
  91064. */
  91065. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  91066. private _dragBehaviorA;
  91067. private _dragBehaviorB;
  91068. private _startDistance;
  91069. private _initialScale;
  91070. private _targetScale;
  91071. private _ownerNode;
  91072. private _sceneRenderObserver;
  91073. /**
  91074. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  91075. */
  91076. constructor();
  91077. /**
  91078. * The name of the behavior
  91079. */
  91080. readonly name: string;
  91081. /**
  91082. * Initializes the behavior
  91083. */
  91084. init(): void;
  91085. private _getCurrentDistance;
  91086. /**
  91087. * Attaches the scale behavior the passed in mesh
  91088. * @param ownerNode The mesh that will be scaled around once attached
  91089. */
  91090. attach(ownerNode: Mesh): void;
  91091. /**
  91092. * Detaches the behavior from the mesh
  91093. */
  91094. detach(): void;
  91095. }
  91096. }
  91097. declare module BABYLON {
  91098. /**
  91099. * 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
  91100. */
  91101. export class SixDofDragBehavior implements Behavior<Mesh> {
  91102. private static _virtualScene;
  91103. private _ownerNode;
  91104. private _sceneRenderObserver;
  91105. private _scene;
  91106. private _targetPosition;
  91107. private _virtualOriginMesh;
  91108. private _virtualDragMesh;
  91109. private _pointerObserver;
  91110. private _moving;
  91111. private _startingOrientation;
  91112. /**
  91113. * 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)
  91114. */
  91115. private zDragFactor;
  91116. /**
  91117. * If the object should rotate to face the drag origin
  91118. */
  91119. rotateDraggedObject: boolean;
  91120. /**
  91121. * If the behavior is currently in a dragging state
  91122. */
  91123. dragging: boolean;
  91124. /**
  91125. * 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)
  91126. */
  91127. dragDeltaRatio: number;
  91128. /**
  91129. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  91130. */
  91131. currentDraggingPointerID: number;
  91132. /**
  91133. * If camera controls should be detached during the drag
  91134. */
  91135. detachCameraControls: boolean;
  91136. /**
  91137. * Fires each time a drag starts
  91138. */
  91139. onDragStartObservable: Observable<{}>;
  91140. /**
  91141. * Fires each time a drag ends (eg. mouse release after drag)
  91142. */
  91143. onDragEndObservable: Observable<{}>;
  91144. /**
  91145. * 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
  91146. */
  91147. constructor();
  91148. /**
  91149. * The name of the behavior
  91150. */
  91151. readonly name: string;
  91152. /**
  91153. * Initializes the behavior
  91154. */
  91155. init(): void;
  91156. /**
  91157. * Attaches the scale behavior the passed in mesh
  91158. * @param ownerNode The mesh that will be scaled around once attached
  91159. */
  91160. attach(ownerNode: Mesh): void;
  91161. /**
  91162. * Detaches the behavior from the mesh
  91163. */
  91164. detach(): void;
  91165. }
  91166. }
  91167. declare module BABYLON {
  91168. /**
  91169. * Class used to apply inverse kinematics to bones
  91170. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  91171. */
  91172. export class BoneIKController {
  91173. private static _tmpVecs;
  91174. private static _tmpQuat;
  91175. private static _tmpMats;
  91176. /**
  91177. * Gets or sets the target mesh
  91178. */
  91179. targetMesh: AbstractMesh;
  91180. /** Gets or sets the mesh used as pole */
  91181. poleTargetMesh: AbstractMesh;
  91182. /**
  91183. * Gets or sets the bone used as pole
  91184. */
  91185. poleTargetBone: Nullable<Bone>;
  91186. /**
  91187. * Gets or sets the target position
  91188. */
  91189. targetPosition: Vector3;
  91190. /**
  91191. * Gets or sets the pole target position
  91192. */
  91193. poleTargetPosition: Vector3;
  91194. /**
  91195. * Gets or sets the pole target local offset
  91196. */
  91197. poleTargetLocalOffset: Vector3;
  91198. /**
  91199. * Gets or sets the pole angle
  91200. */
  91201. poleAngle: number;
  91202. /**
  91203. * Gets or sets the mesh associated with the controller
  91204. */
  91205. mesh: AbstractMesh;
  91206. /**
  91207. * 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)
  91208. */
  91209. slerpAmount: number;
  91210. private _bone1Quat;
  91211. private _bone1Mat;
  91212. private _bone2Ang;
  91213. private _bone1;
  91214. private _bone2;
  91215. private _bone1Length;
  91216. private _bone2Length;
  91217. private _maxAngle;
  91218. private _maxReach;
  91219. private _rightHandedSystem;
  91220. private _bendAxis;
  91221. private _slerping;
  91222. private _adjustRoll;
  91223. /**
  91224. * Gets or sets maximum allowed angle
  91225. */
  91226. maxAngle: number;
  91227. /**
  91228. * Creates a new BoneIKController
  91229. * @param mesh defines the mesh to control
  91230. * @param bone defines the bone to control
  91231. * @param options defines options to set up the controller
  91232. */
  91233. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  91234. targetMesh?: AbstractMesh;
  91235. poleTargetMesh?: AbstractMesh;
  91236. poleTargetBone?: Bone;
  91237. poleTargetLocalOffset?: Vector3;
  91238. poleAngle?: number;
  91239. bendAxis?: Vector3;
  91240. maxAngle?: number;
  91241. slerpAmount?: number;
  91242. });
  91243. private _setMaxAngle;
  91244. /**
  91245. * Force the controller to update the bones
  91246. */
  91247. update(): void;
  91248. }
  91249. }
  91250. declare module BABYLON {
  91251. /**
  91252. * Class used to make a bone look toward a point in space
  91253. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  91254. */
  91255. export class BoneLookController {
  91256. private static _tmpVecs;
  91257. private static _tmpQuat;
  91258. private static _tmpMats;
  91259. /**
  91260. * The target Vector3 that the bone will look at
  91261. */
  91262. target: Vector3;
  91263. /**
  91264. * The mesh that the bone is attached to
  91265. */
  91266. mesh: AbstractMesh;
  91267. /**
  91268. * The bone that will be looking to the target
  91269. */
  91270. bone: Bone;
  91271. /**
  91272. * The up axis of the coordinate system that is used when the bone is rotated
  91273. */
  91274. upAxis: Vector3;
  91275. /**
  91276. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  91277. */
  91278. upAxisSpace: Space;
  91279. /**
  91280. * Used to make an adjustment to the yaw of the bone
  91281. */
  91282. adjustYaw: number;
  91283. /**
  91284. * Used to make an adjustment to the pitch of the bone
  91285. */
  91286. adjustPitch: number;
  91287. /**
  91288. * Used to make an adjustment to the roll of the bone
  91289. */
  91290. adjustRoll: number;
  91291. /**
  91292. * 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)
  91293. */
  91294. slerpAmount: number;
  91295. private _minYaw;
  91296. private _maxYaw;
  91297. private _minPitch;
  91298. private _maxPitch;
  91299. private _minYawSin;
  91300. private _minYawCos;
  91301. private _maxYawSin;
  91302. private _maxYawCos;
  91303. private _midYawConstraint;
  91304. private _minPitchTan;
  91305. private _maxPitchTan;
  91306. private _boneQuat;
  91307. private _slerping;
  91308. private _transformYawPitch;
  91309. private _transformYawPitchInv;
  91310. private _firstFrameSkipped;
  91311. private _yawRange;
  91312. private _fowardAxis;
  91313. /**
  91314. * Gets or sets the minimum yaw angle that the bone can look to
  91315. */
  91316. minYaw: number;
  91317. /**
  91318. * Gets or sets the maximum yaw angle that the bone can look to
  91319. */
  91320. maxYaw: number;
  91321. /**
  91322. * Gets or sets the minimum pitch angle that the bone can look to
  91323. */
  91324. minPitch: number;
  91325. /**
  91326. * Gets or sets the maximum pitch angle that the bone can look to
  91327. */
  91328. maxPitch: number;
  91329. /**
  91330. * Create a BoneLookController
  91331. * @param mesh the mesh that the bone belongs to
  91332. * @param bone the bone that will be looking to the target
  91333. * @param target the target Vector3 to look at
  91334. * @param options optional settings:
  91335. * * maxYaw: the maximum angle the bone will yaw to
  91336. * * minYaw: the minimum angle the bone will yaw to
  91337. * * maxPitch: the maximum angle the bone will pitch to
  91338. * * minPitch: the minimum angle the bone will yaw to
  91339. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  91340. * * upAxis: the up axis of the coordinate system
  91341. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  91342. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  91343. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  91344. * * adjustYaw: used to make an adjustment to the yaw of the bone
  91345. * * adjustPitch: used to make an adjustment to the pitch of the bone
  91346. * * adjustRoll: used to make an adjustment to the roll of the bone
  91347. **/
  91348. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  91349. maxYaw?: number;
  91350. minYaw?: number;
  91351. maxPitch?: number;
  91352. minPitch?: number;
  91353. slerpAmount?: number;
  91354. upAxis?: Vector3;
  91355. upAxisSpace?: Space;
  91356. yawAxis?: Vector3;
  91357. pitchAxis?: Vector3;
  91358. adjustYaw?: number;
  91359. adjustPitch?: number;
  91360. adjustRoll?: number;
  91361. });
  91362. /**
  91363. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  91364. */
  91365. update(): void;
  91366. private _getAngleDiff;
  91367. private _getAngleBetween;
  91368. private _isAngleBetween;
  91369. }
  91370. }
  91371. declare module BABYLON {
  91372. /**
  91373. * Manage the gamepad inputs to control an arc rotate camera.
  91374. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91375. */
  91376. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  91377. /**
  91378. * Defines the camera the input is attached to.
  91379. */
  91380. camera: ArcRotateCamera;
  91381. /**
  91382. * Defines the gamepad the input is gathering event from.
  91383. */
  91384. gamepad: Nullable<Gamepad>;
  91385. /**
  91386. * Defines the gamepad rotation sensiblity.
  91387. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91388. */
  91389. gamepadRotationSensibility: number;
  91390. /**
  91391. * Defines the gamepad move sensiblity.
  91392. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91393. */
  91394. gamepadMoveSensibility: number;
  91395. private _onGamepadConnectedObserver;
  91396. private _onGamepadDisconnectedObserver;
  91397. /**
  91398. * Attach the input controls to a specific dom element to get the input from.
  91399. * @param element Defines the element the controls should be listened from
  91400. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91401. */
  91402. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91403. /**
  91404. * Detach the current controls from the specified dom element.
  91405. * @param element Defines the element to stop listening the inputs from
  91406. */
  91407. detachControl(element: Nullable<HTMLElement>): void;
  91408. /**
  91409. * Update the current camera state depending on the inputs that have been used this frame.
  91410. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91411. */
  91412. checkInputs(): void;
  91413. /**
  91414. * Gets the class name of the current intput.
  91415. * @returns the class name
  91416. */
  91417. getClassName(): string;
  91418. /**
  91419. * Get the friendly name associated with the input class.
  91420. * @returns the input friendly name
  91421. */
  91422. getSimpleName(): string;
  91423. }
  91424. }
  91425. declare module BABYLON {
  91426. interface ArcRotateCameraInputsManager {
  91427. /**
  91428. * Add orientation input support to the input manager.
  91429. * @returns the current input manager
  91430. */
  91431. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  91432. }
  91433. /**
  91434. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  91435. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91436. */
  91437. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  91438. /**
  91439. * Defines the camera the input is attached to.
  91440. */
  91441. camera: ArcRotateCamera;
  91442. /**
  91443. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  91444. */
  91445. alphaCorrection: number;
  91446. /**
  91447. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  91448. */
  91449. gammaCorrection: number;
  91450. private _alpha;
  91451. private _gamma;
  91452. private _dirty;
  91453. private _deviceOrientationHandler;
  91454. /**
  91455. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  91456. */
  91457. constructor();
  91458. /**
  91459. * Attach the input controls to a specific dom element to get the input from.
  91460. * @param element Defines the element the controls should be listened from
  91461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91462. */
  91463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91464. /** @hidden */
  91465. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  91466. /**
  91467. * Update the current camera state depending on the inputs that have been used this frame.
  91468. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91469. */
  91470. checkInputs(): void;
  91471. /**
  91472. * Detach the current controls from the specified dom element.
  91473. * @param element Defines the element to stop listening the inputs from
  91474. */
  91475. detachControl(element: Nullable<HTMLElement>): void;
  91476. /**
  91477. * Gets the class name of the current intput.
  91478. * @returns the class name
  91479. */
  91480. getClassName(): string;
  91481. /**
  91482. * Get the friendly name associated with the input class.
  91483. * @returns the input friendly name
  91484. */
  91485. getSimpleName(): string;
  91486. }
  91487. }
  91488. declare module BABYLON {
  91489. /**
  91490. * Listen to mouse events to control the camera.
  91491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91492. */
  91493. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  91494. /**
  91495. * Defines the camera the input is attached to.
  91496. */
  91497. camera: FlyCamera;
  91498. /**
  91499. * Defines if touch is enabled. (Default is true.)
  91500. */
  91501. touchEnabled: boolean;
  91502. /**
  91503. * Defines the buttons associated with the input to handle camera rotation.
  91504. */
  91505. buttons: number[];
  91506. /**
  91507. * Assign buttons for Yaw control.
  91508. */
  91509. buttonsYaw: number[];
  91510. /**
  91511. * Assign buttons for Pitch control.
  91512. */
  91513. buttonsPitch: number[];
  91514. /**
  91515. * Assign buttons for Roll control.
  91516. */
  91517. buttonsRoll: number[];
  91518. /**
  91519. * Detect if any button is being pressed while mouse is moved.
  91520. * -1 = Mouse locked.
  91521. * 0 = Left button.
  91522. * 1 = Middle Button.
  91523. * 2 = Right Button.
  91524. */
  91525. activeButton: number;
  91526. /**
  91527. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  91528. * Higher values reduce its sensitivity.
  91529. */
  91530. angularSensibility: number;
  91531. private _mousemoveCallback;
  91532. private _observer;
  91533. private _rollObserver;
  91534. private previousPosition;
  91535. private noPreventDefault;
  91536. private element;
  91537. /**
  91538. * Listen to mouse events to control the camera.
  91539. * @param touchEnabled Define if touch is enabled. (Default is true.)
  91540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91541. */
  91542. constructor(touchEnabled?: boolean);
  91543. /**
  91544. * Attach the mouse control to the HTML DOM element.
  91545. * @param element Defines the element that listens to the input events.
  91546. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  91547. */
  91548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91549. /**
  91550. * Detach the current controls from the specified dom element.
  91551. * @param element Defines the element to stop listening the inputs from
  91552. */
  91553. detachControl(element: Nullable<HTMLElement>): void;
  91554. /**
  91555. * Gets the class name of the current input.
  91556. * @returns the class name.
  91557. */
  91558. getClassName(): string;
  91559. /**
  91560. * Get the friendly name associated with the input class.
  91561. * @returns the input's friendly name.
  91562. */
  91563. getSimpleName(): string;
  91564. private _pointerInput;
  91565. private _onMouseMove;
  91566. /**
  91567. * Rotate camera by mouse offset.
  91568. */
  91569. private rotateCamera;
  91570. }
  91571. }
  91572. declare module BABYLON {
  91573. /**
  91574. * Default Inputs manager for the FlyCamera.
  91575. * It groups all the default supported inputs for ease of use.
  91576. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91577. */
  91578. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  91579. /**
  91580. * Instantiates a new FlyCameraInputsManager.
  91581. * @param camera Defines the camera the inputs belong to.
  91582. */
  91583. constructor(camera: FlyCamera);
  91584. /**
  91585. * Add keyboard input support to the input manager.
  91586. * @returns the new FlyCameraKeyboardMoveInput().
  91587. */
  91588. addKeyboard(): FlyCameraInputsManager;
  91589. /**
  91590. * Add mouse input support to the input manager.
  91591. * @param touchEnabled Enable touch screen support.
  91592. * @returns the new FlyCameraMouseInput().
  91593. */
  91594. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  91595. }
  91596. }
  91597. declare module BABYLON {
  91598. /**
  91599. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91600. * such as in a 3D Space Shooter or a Flight Simulator.
  91601. */
  91602. export class FlyCamera extends TargetCamera {
  91603. /**
  91604. * Define the collision ellipsoid of the camera.
  91605. * This is helpful for simulating a camera body, like a player's body.
  91606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91607. */
  91608. ellipsoid: Vector3;
  91609. /**
  91610. * Define an offset for the position of the ellipsoid around the camera.
  91611. * This can be helpful if the camera is attached away from the player's body center,
  91612. * such as at its head.
  91613. */
  91614. ellipsoidOffset: Vector3;
  91615. /**
  91616. * Enable or disable collisions of the camera with the rest of the scene objects.
  91617. */
  91618. checkCollisions: boolean;
  91619. /**
  91620. * Enable or disable gravity on the camera.
  91621. */
  91622. applyGravity: boolean;
  91623. /**
  91624. * Define the current direction the camera is moving to.
  91625. */
  91626. cameraDirection: Vector3;
  91627. /**
  91628. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  91629. * This overrides and empties cameraRotation.
  91630. */
  91631. rotationQuaternion: Quaternion;
  91632. /**
  91633. * Track Roll to maintain the wanted Rolling when looking around.
  91634. */
  91635. _trackRoll: number;
  91636. /**
  91637. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  91638. */
  91639. rollCorrect: number;
  91640. /**
  91641. * Mimic a banked turn, Rolling the camera when Yawing.
  91642. * It's recommended to use rollCorrect = 10 for faster banking correction.
  91643. */
  91644. bankedTurn: boolean;
  91645. /**
  91646. * Limit in radians for how much Roll banking will add. (Default: 90°)
  91647. */
  91648. bankedTurnLimit: number;
  91649. /**
  91650. * Value of 0 disables the banked Roll.
  91651. * Value of 1 is equal to the Yaw angle in radians.
  91652. */
  91653. bankedTurnMultiplier: number;
  91654. /**
  91655. * The inputs manager loads all the input sources, such as keyboard and mouse.
  91656. */
  91657. inputs: FlyCameraInputsManager;
  91658. /**
  91659. * Gets the input sensibility for mouse input.
  91660. * Higher values reduce sensitivity.
  91661. */
  91662. /**
  91663. * Sets the input sensibility for a mouse input.
  91664. * Higher values reduce sensitivity.
  91665. */
  91666. angularSensibility: number;
  91667. /**
  91668. * Get the keys for camera movement forward.
  91669. */
  91670. /**
  91671. * Set the keys for camera movement forward.
  91672. */
  91673. keysForward: number[];
  91674. /**
  91675. * Get the keys for camera movement backward.
  91676. */
  91677. keysBackward: number[];
  91678. /**
  91679. * Get the keys for camera movement up.
  91680. */
  91681. /**
  91682. * Set the keys for camera movement up.
  91683. */
  91684. keysUp: number[];
  91685. /**
  91686. * Get the keys for camera movement down.
  91687. */
  91688. /**
  91689. * Set the keys for camera movement down.
  91690. */
  91691. keysDown: number[];
  91692. /**
  91693. * Get the keys for camera movement left.
  91694. */
  91695. /**
  91696. * Set the keys for camera movement left.
  91697. */
  91698. keysLeft: number[];
  91699. /**
  91700. * Set the keys for camera movement right.
  91701. */
  91702. /**
  91703. * Set the keys for camera movement right.
  91704. */
  91705. keysRight: number[];
  91706. /**
  91707. * Event raised when the camera collides with a mesh in the scene.
  91708. */
  91709. onCollide: (collidedMesh: AbstractMesh) => void;
  91710. private _collider;
  91711. private _needMoveForGravity;
  91712. private _oldPosition;
  91713. private _diffPosition;
  91714. private _newPosition;
  91715. /** @hidden */
  91716. _localDirection: Vector3;
  91717. /** @hidden */
  91718. _transformedDirection: Vector3;
  91719. /**
  91720. * Instantiates a FlyCamera.
  91721. * This is a flying camera, designed for 3D movement and rotation in all directions,
  91722. * such as in a 3D Space Shooter or a Flight Simulator.
  91723. * @param name Define the name of the camera in the scene.
  91724. * @param position Define the starting position of the camera in the scene.
  91725. * @param scene Define the scene the camera belongs to.
  91726. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  91727. */
  91728. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91729. /**
  91730. * Attach a control to the HTML DOM element.
  91731. * @param element Defines the element that listens to the input events.
  91732. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  91733. */
  91734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91735. /**
  91736. * Detach a control from the HTML DOM element.
  91737. * The camera will stop reacting to that input.
  91738. * @param element Defines the element that listens to the input events.
  91739. */
  91740. detachControl(element: HTMLElement): void;
  91741. private _collisionMask;
  91742. /**
  91743. * Get the mask that the camera ignores in collision events.
  91744. */
  91745. /**
  91746. * Set the mask that the camera ignores in collision events.
  91747. */
  91748. collisionMask: number;
  91749. /** @hidden */
  91750. _collideWithWorld(displacement: Vector3): void;
  91751. /** @hidden */
  91752. private _onCollisionPositionChange;
  91753. /** @hidden */
  91754. _checkInputs(): void;
  91755. /** @hidden */
  91756. _decideIfNeedsToMove(): boolean;
  91757. /** @hidden */
  91758. _updatePosition(): void;
  91759. /**
  91760. * Restore the Roll to its target value at the rate specified.
  91761. * @param rate - Higher means slower restoring.
  91762. * @hidden
  91763. */
  91764. restoreRoll(rate: number): void;
  91765. /**
  91766. * Destroy the camera and release the current resources held by it.
  91767. */
  91768. dispose(): void;
  91769. /**
  91770. * Get the current object class name.
  91771. * @returns the class name.
  91772. */
  91773. getClassName(): string;
  91774. }
  91775. }
  91776. declare module BABYLON {
  91777. /**
  91778. * Listen to keyboard events to control the camera.
  91779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91780. */
  91781. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  91782. /**
  91783. * Defines the camera the input is attached to.
  91784. */
  91785. camera: FlyCamera;
  91786. /**
  91787. * The list of keyboard keys used to control the forward move of the camera.
  91788. */
  91789. keysForward: number[];
  91790. /**
  91791. * The list of keyboard keys used to control the backward move of the camera.
  91792. */
  91793. keysBackward: number[];
  91794. /**
  91795. * The list of keyboard keys used to control the forward move of the camera.
  91796. */
  91797. keysUp: number[];
  91798. /**
  91799. * The list of keyboard keys used to control the backward move of the camera.
  91800. */
  91801. keysDown: number[];
  91802. /**
  91803. * The list of keyboard keys used to control the right strafe move of the camera.
  91804. */
  91805. keysRight: number[];
  91806. /**
  91807. * The list of keyboard keys used to control the left strafe move of the camera.
  91808. */
  91809. keysLeft: number[];
  91810. private _keys;
  91811. private _onCanvasBlurObserver;
  91812. private _onKeyboardObserver;
  91813. private _engine;
  91814. private _scene;
  91815. /**
  91816. * Attach the input controls to a specific dom element to get the input from.
  91817. * @param element Defines the element the controls should be listened from
  91818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91819. */
  91820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91821. /**
  91822. * Detach the current controls from the specified dom element.
  91823. * @param element Defines the element to stop listening the inputs from
  91824. */
  91825. detachControl(element: Nullable<HTMLElement>): void;
  91826. /**
  91827. * Gets the class name of the current intput.
  91828. * @returns the class name
  91829. */
  91830. getClassName(): string;
  91831. /** @hidden */
  91832. _onLostFocus(e: FocusEvent): void;
  91833. /**
  91834. * Get the friendly name associated with the input class.
  91835. * @returns the input friendly name
  91836. */
  91837. getSimpleName(): string;
  91838. /**
  91839. * Update the current camera state depending on the inputs that have been used this frame.
  91840. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91841. */
  91842. checkInputs(): void;
  91843. }
  91844. }
  91845. declare module BABYLON {
  91846. interface FreeCameraInputsManager {
  91847. /**
  91848. * Add orientation input support to the input manager.
  91849. * @returns the current input manager
  91850. */
  91851. addDeviceOrientation(): FreeCameraInputsManager;
  91852. }
  91853. /**
  91854. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  91855. * Screen rotation is taken into account.
  91856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91857. */
  91858. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  91859. private _camera;
  91860. private _screenOrientationAngle;
  91861. private _constantTranform;
  91862. private _screenQuaternion;
  91863. private _alpha;
  91864. private _beta;
  91865. private _gamma;
  91866. /**
  91867. * Instantiates a new input
  91868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91869. */
  91870. constructor();
  91871. /**
  91872. * Define the camera controlled by the input.
  91873. */
  91874. camera: FreeCamera;
  91875. /**
  91876. * Attach the input controls to a specific dom element to get the input from.
  91877. * @param element Defines the element the controls should be listened from
  91878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91879. */
  91880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91881. private _orientationChanged;
  91882. private _deviceOrientation;
  91883. /**
  91884. * Detach the current controls from the specified dom element.
  91885. * @param element Defines the element to stop listening the inputs from
  91886. */
  91887. detachControl(element: Nullable<HTMLElement>): void;
  91888. /**
  91889. * Update the current camera state depending on the inputs that have been used this frame.
  91890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91891. */
  91892. checkInputs(): void;
  91893. /**
  91894. * Gets the class name of the current intput.
  91895. * @returns the class name
  91896. */
  91897. getClassName(): string;
  91898. /**
  91899. * Get the friendly name associated with the input class.
  91900. * @returns the input friendly name
  91901. */
  91902. getSimpleName(): string;
  91903. }
  91904. }
  91905. declare module BABYLON {
  91906. /**
  91907. * Manage the gamepad inputs to control a free camera.
  91908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91909. */
  91910. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  91911. /**
  91912. * Define the camera the input is attached to.
  91913. */
  91914. camera: FreeCamera;
  91915. /**
  91916. * Define the Gamepad controlling the input
  91917. */
  91918. gamepad: Nullable<Gamepad>;
  91919. /**
  91920. * Defines the gamepad rotation sensiblity.
  91921. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  91922. */
  91923. gamepadAngularSensibility: number;
  91924. /**
  91925. * Defines the gamepad move sensiblity.
  91926. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  91927. */
  91928. gamepadMoveSensibility: number;
  91929. private _onGamepadConnectedObserver;
  91930. private _onGamepadDisconnectedObserver;
  91931. private _cameraTransform;
  91932. private _deltaTransform;
  91933. private _vector3;
  91934. private _vector2;
  91935. /**
  91936. * Attach the input controls to a specific dom element to get the input from.
  91937. * @param element Defines the element the controls should be listened from
  91938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91939. */
  91940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91941. /**
  91942. * Detach the current controls from the specified dom element.
  91943. * @param element Defines the element to stop listening the inputs from
  91944. */
  91945. detachControl(element: Nullable<HTMLElement>): void;
  91946. /**
  91947. * Update the current camera state depending on the inputs that have been used this frame.
  91948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91949. */
  91950. checkInputs(): void;
  91951. /**
  91952. * Gets the class name of the current intput.
  91953. * @returns the class name
  91954. */
  91955. getClassName(): string;
  91956. /**
  91957. * Get the friendly name associated with the input class.
  91958. * @returns the input friendly name
  91959. */
  91960. getSimpleName(): string;
  91961. }
  91962. }
  91963. declare module BABYLON {
  91964. /**
  91965. * Defines the potential axis of a Joystick
  91966. */
  91967. export enum JoystickAxis {
  91968. /** X axis */
  91969. X = 0,
  91970. /** Y axis */
  91971. Y = 1,
  91972. /** Z axis */
  91973. Z = 2
  91974. }
  91975. /**
  91976. * Class used to define virtual joystick (used in touch mode)
  91977. */
  91978. export class VirtualJoystick {
  91979. /**
  91980. * Gets or sets a boolean indicating that left and right values must be inverted
  91981. */
  91982. reverseLeftRight: boolean;
  91983. /**
  91984. * Gets or sets a boolean indicating that up and down values must be inverted
  91985. */
  91986. reverseUpDown: boolean;
  91987. /**
  91988. * Gets the offset value for the position (ie. the change of the position value)
  91989. */
  91990. deltaPosition: Vector3;
  91991. /**
  91992. * Gets a boolean indicating if the virtual joystick was pressed
  91993. */
  91994. pressed: boolean;
  91995. /**
  91996. * Canvas the virtual joystick will render onto, default z-index of this is 5
  91997. */
  91998. static Canvas: Nullable<HTMLCanvasElement>;
  91999. private static _globalJoystickIndex;
  92000. private static vjCanvasContext;
  92001. private static vjCanvasWidth;
  92002. private static vjCanvasHeight;
  92003. private static halfWidth;
  92004. private _action;
  92005. private _axisTargetedByLeftAndRight;
  92006. private _axisTargetedByUpAndDown;
  92007. private _joystickSensibility;
  92008. private _inversedSensibility;
  92009. private _joystickPointerID;
  92010. private _joystickColor;
  92011. private _joystickPointerPos;
  92012. private _joystickPreviousPointerPos;
  92013. private _joystickPointerStartPos;
  92014. private _deltaJoystickVector;
  92015. private _leftJoystick;
  92016. private _touches;
  92017. private _onPointerDownHandlerRef;
  92018. private _onPointerMoveHandlerRef;
  92019. private _onPointerUpHandlerRef;
  92020. private _onResize;
  92021. /**
  92022. * Creates a new virtual joystick
  92023. * @param leftJoystick defines that the joystick is for left hand (false by default)
  92024. */
  92025. constructor(leftJoystick?: boolean);
  92026. /**
  92027. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  92028. * @param newJoystickSensibility defines the new sensibility
  92029. */
  92030. setJoystickSensibility(newJoystickSensibility: number): void;
  92031. private _onPointerDown;
  92032. private _onPointerMove;
  92033. private _onPointerUp;
  92034. /**
  92035. * Change the color of the virtual joystick
  92036. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  92037. */
  92038. setJoystickColor(newColor: string): void;
  92039. /**
  92040. * Defines a callback to call when the joystick is touched
  92041. * @param action defines the callback
  92042. */
  92043. setActionOnTouch(action: () => any): void;
  92044. /**
  92045. * Defines which axis you'd like to control for left & right
  92046. * @param axis defines the axis to use
  92047. */
  92048. setAxisForLeftRight(axis: JoystickAxis): void;
  92049. /**
  92050. * Defines which axis you'd like to control for up & down
  92051. * @param axis defines the axis to use
  92052. */
  92053. setAxisForUpDown(axis: JoystickAxis): void;
  92054. private _drawVirtualJoystick;
  92055. /**
  92056. * Release internal HTML canvas
  92057. */
  92058. releaseCanvas(): void;
  92059. }
  92060. }
  92061. declare module BABYLON {
  92062. interface FreeCameraInputsManager {
  92063. /**
  92064. * Add virtual joystick input support to the input manager.
  92065. * @returns the current input manager
  92066. */
  92067. addVirtualJoystick(): FreeCameraInputsManager;
  92068. }
  92069. /**
  92070. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  92071. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92072. */
  92073. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  92074. /**
  92075. * Defines the camera the input is attached to.
  92076. */
  92077. camera: FreeCamera;
  92078. private _leftjoystick;
  92079. private _rightjoystick;
  92080. /**
  92081. * Gets the left stick of the virtual joystick.
  92082. * @returns The virtual Joystick
  92083. */
  92084. getLeftJoystick(): VirtualJoystick;
  92085. /**
  92086. * Gets the right stick of the virtual joystick.
  92087. * @returns The virtual Joystick
  92088. */
  92089. getRightJoystick(): VirtualJoystick;
  92090. /**
  92091. * Update the current camera state depending on the inputs that have been used this frame.
  92092. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92093. */
  92094. checkInputs(): void;
  92095. /**
  92096. * Attach the input controls to a specific dom element to get the input from.
  92097. * @param element Defines the element the controls should be listened from
  92098. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92099. */
  92100. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92101. /**
  92102. * Detach the current controls from the specified dom element.
  92103. * @param element Defines the element to stop listening the inputs from
  92104. */
  92105. detachControl(element: Nullable<HTMLElement>): void;
  92106. /**
  92107. * Gets the class name of the current intput.
  92108. * @returns the class name
  92109. */
  92110. getClassName(): string;
  92111. /**
  92112. * Get the friendly name associated with the input class.
  92113. * @returns the input friendly name
  92114. */
  92115. getSimpleName(): string;
  92116. }
  92117. }
  92118. declare module BABYLON {
  92119. /**
  92120. * This represents a FPS type of camera controlled by touch.
  92121. * This is like a universal camera minus the Gamepad controls.
  92122. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92123. */
  92124. export class TouchCamera extends FreeCamera {
  92125. /**
  92126. * Defines the touch sensibility for rotation.
  92127. * The higher the faster.
  92128. */
  92129. touchAngularSensibility: number;
  92130. /**
  92131. * Defines the touch sensibility for move.
  92132. * The higher the faster.
  92133. */
  92134. touchMoveSensibility: number;
  92135. /**
  92136. * Instantiates a new touch camera.
  92137. * This represents a FPS type of camera controlled by touch.
  92138. * This is like a universal camera minus the Gamepad controls.
  92139. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92140. * @param name Define the name of the camera in the scene
  92141. * @param position Define the start position of the camera in the scene
  92142. * @param scene Define the scene the camera belongs to
  92143. */
  92144. constructor(name: string, position: Vector3, scene: Scene);
  92145. /**
  92146. * Gets the current object class name.
  92147. * @return the class name
  92148. */
  92149. getClassName(): string;
  92150. /** @hidden */
  92151. _setupInputs(): void;
  92152. }
  92153. }
  92154. declare module BABYLON {
  92155. /**
  92156. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  92157. * being tilted forward or back and left or right.
  92158. */
  92159. export class DeviceOrientationCamera extends FreeCamera {
  92160. private _initialQuaternion;
  92161. private _quaternionCache;
  92162. /**
  92163. * Creates a new device orientation camera
  92164. * @param name The name of the camera
  92165. * @param position The start position camera
  92166. * @param scene The scene the camera belongs to
  92167. */
  92168. constructor(name: string, position: Vector3, scene: Scene);
  92169. /**
  92170. * Gets the current instance class name ("DeviceOrientationCamera").
  92171. * This helps avoiding instanceof at run time.
  92172. * @returns the class name
  92173. */
  92174. getClassName(): string;
  92175. /**
  92176. * @hidden
  92177. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  92178. */
  92179. _checkInputs(): void;
  92180. /**
  92181. * Reset the camera to its default orientation on the specified axis only.
  92182. * @param axis The axis to reset
  92183. */
  92184. resetToCurrentRotation(axis?: Axis): void;
  92185. }
  92186. }
  92187. declare module BABYLON {
  92188. /**
  92189. * Manage the keyboard inputs to control the movement of a follow camera.
  92190. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92191. */
  92192. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  92193. /**
  92194. * Defines the camera the input is attached to.
  92195. */
  92196. camera: FollowCamera;
  92197. /**
  92198. * Defines the list of key codes associated with the up action (increase heightOffset)
  92199. */
  92200. keysHeightOffsetIncr: number[];
  92201. /**
  92202. * Defines the list of key codes associated with the down action (decrease heightOffset)
  92203. */
  92204. keysHeightOffsetDecr: number[];
  92205. /**
  92206. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  92207. */
  92208. keysHeightOffsetModifierAlt: boolean;
  92209. /**
  92210. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  92211. */
  92212. keysHeightOffsetModifierCtrl: boolean;
  92213. /**
  92214. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  92215. */
  92216. keysHeightOffsetModifierShift: boolean;
  92217. /**
  92218. * Defines the list of key codes associated with the left action (increase rotationOffset)
  92219. */
  92220. keysRotationOffsetIncr: number[];
  92221. /**
  92222. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  92223. */
  92224. keysRotationOffsetDecr: number[];
  92225. /**
  92226. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  92227. */
  92228. keysRotationOffsetModifierAlt: boolean;
  92229. /**
  92230. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  92231. */
  92232. keysRotationOffsetModifierCtrl: boolean;
  92233. /**
  92234. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  92235. */
  92236. keysRotationOffsetModifierShift: boolean;
  92237. /**
  92238. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  92239. */
  92240. keysRadiusIncr: number[];
  92241. /**
  92242. * Defines the list of key codes associated with the zoom-out action (increase radius)
  92243. */
  92244. keysRadiusDecr: number[];
  92245. /**
  92246. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  92247. */
  92248. keysRadiusModifierAlt: boolean;
  92249. /**
  92250. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  92251. */
  92252. keysRadiusModifierCtrl: boolean;
  92253. /**
  92254. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  92255. */
  92256. keysRadiusModifierShift: boolean;
  92257. /**
  92258. * Defines the rate of change of heightOffset.
  92259. */
  92260. heightSensibility: number;
  92261. /**
  92262. * Defines the rate of change of rotationOffset.
  92263. */
  92264. rotationSensibility: number;
  92265. /**
  92266. * Defines the rate of change of radius.
  92267. */
  92268. radiusSensibility: number;
  92269. private _keys;
  92270. private _ctrlPressed;
  92271. private _altPressed;
  92272. private _shiftPressed;
  92273. private _onCanvasBlurObserver;
  92274. private _onKeyboardObserver;
  92275. private _engine;
  92276. private _scene;
  92277. /**
  92278. * Attach the input controls to a specific dom element to get the input from.
  92279. * @param element Defines the element the controls should be listened from
  92280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92281. */
  92282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92283. /**
  92284. * Detach the current controls from the specified dom element.
  92285. * @param element Defines the element to stop listening the inputs from
  92286. */
  92287. detachControl(element: Nullable<HTMLElement>): void;
  92288. /**
  92289. * Update the current camera state depending on the inputs that have been used this frame.
  92290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92291. */
  92292. checkInputs(): void;
  92293. /**
  92294. * Gets the class name of the current input.
  92295. * @returns the class name
  92296. */
  92297. getClassName(): string;
  92298. /**
  92299. * Get the friendly name associated with the input class.
  92300. * @returns the input friendly name
  92301. */
  92302. getSimpleName(): string;
  92303. /**
  92304. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92305. * allow modification of the heightOffset value.
  92306. */
  92307. private _modifierHeightOffset;
  92308. /**
  92309. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92310. * allow modification of the rotationOffset value.
  92311. */
  92312. private _modifierRotationOffset;
  92313. /**
  92314. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  92315. * allow modification of the radius value.
  92316. */
  92317. private _modifierRadius;
  92318. }
  92319. }
  92320. declare module BABYLON {
  92321. /**
  92322. * Manage the mouse wheel inputs to control a follow camera.
  92323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92324. */
  92325. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  92326. /**
  92327. * Defines the camera the input is attached to.
  92328. */
  92329. camera: FollowCamera;
  92330. /**
  92331. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  92332. */
  92333. axisControlRadius: boolean;
  92334. /**
  92335. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  92336. */
  92337. axisControlHeight: boolean;
  92338. /**
  92339. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  92340. */
  92341. axisControlRotation: boolean;
  92342. /**
  92343. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  92344. * relation to mouseWheel events.
  92345. */
  92346. wheelPrecision: number;
  92347. /**
  92348. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  92349. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  92350. */
  92351. wheelDeltaPercentage: number;
  92352. private _wheel;
  92353. private _observer;
  92354. /**
  92355. * Attach the input controls to a specific dom element to get the input from.
  92356. * @param element Defines the element the controls should be listened from
  92357. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92358. */
  92359. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92360. /**
  92361. * Detach the current controls from the specified dom element.
  92362. * @param element Defines the element to stop listening the inputs from
  92363. */
  92364. detachControl(element: Nullable<HTMLElement>): void;
  92365. /**
  92366. * Gets the class name of the current intput.
  92367. * @returns the class name
  92368. */
  92369. getClassName(): string;
  92370. /**
  92371. * Get the friendly name associated with the input class.
  92372. * @returns the input friendly name
  92373. */
  92374. getSimpleName(): string;
  92375. }
  92376. }
  92377. declare module BABYLON {
  92378. /**
  92379. * Default Inputs manager for the FollowCamera.
  92380. * It groups all the default supported inputs for ease of use.
  92381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92382. */
  92383. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  92384. /**
  92385. * Instantiates a new FollowCameraInputsManager.
  92386. * @param camera Defines the camera the inputs belong to
  92387. */
  92388. constructor(camera: FollowCamera);
  92389. /**
  92390. * Add keyboard input support to the input manager.
  92391. * @returns the current input manager
  92392. */
  92393. addKeyboard(): FollowCameraInputsManager;
  92394. /**
  92395. * Add mouse wheel input support to the input manager.
  92396. * @returns the current input manager
  92397. */
  92398. addMouseWheel(): FollowCameraInputsManager;
  92399. /**
  92400. * Add pointers input support to the input manager.
  92401. * @returns the current input manager
  92402. */
  92403. addPointers(): FollowCameraInputsManager;
  92404. /**
  92405. * Add orientation input support to the input manager.
  92406. * @returns the current input manager
  92407. */
  92408. addVRDeviceOrientation(): FollowCameraInputsManager;
  92409. }
  92410. }
  92411. declare module BABYLON {
  92412. /**
  92413. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  92414. * an arc rotate version arcFollowCamera are available.
  92415. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92416. */
  92417. export class FollowCamera extends TargetCamera {
  92418. /**
  92419. * Distance the follow camera should follow an object at
  92420. */
  92421. radius: number;
  92422. /**
  92423. * Minimum allowed distance of the camera to the axis of rotation
  92424. * (The camera can not get closer).
  92425. * This can help limiting how the Camera is able to move in the scene.
  92426. */
  92427. lowerRadiusLimit: Nullable<number>;
  92428. /**
  92429. * Maximum allowed distance of the camera to the axis of rotation
  92430. * (The camera can not get further).
  92431. * This can help limiting how the Camera is able to move in the scene.
  92432. */
  92433. upperRadiusLimit: Nullable<number>;
  92434. /**
  92435. * Define a rotation offset between the camera and the object it follows
  92436. */
  92437. rotationOffset: number;
  92438. /**
  92439. * Minimum allowed angle to camera position relative to target object.
  92440. * This can help limiting how the Camera is able to move in the scene.
  92441. */
  92442. lowerRotationOffsetLimit: Nullable<number>;
  92443. /**
  92444. * Maximum allowed angle to camera position relative to target object.
  92445. * This can help limiting how the Camera is able to move in the scene.
  92446. */
  92447. upperRotationOffsetLimit: Nullable<number>;
  92448. /**
  92449. * Define a height offset between the camera and the object it follows.
  92450. * It can help following an object from the top (like a car chaing a plane)
  92451. */
  92452. heightOffset: number;
  92453. /**
  92454. * Minimum allowed height of camera position relative to target object.
  92455. * This can help limiting how the Camera is able to move in the scene.
  92456. */
  92457. lowerHeightOffsetLimit: Nullable<number>;
  92458. /**
  92459. * Maximum allowed height of camera position relative to target object.
  92460. * This can help limiting how the Camera is able to move in the scene.
  92461. */
  92462. upperHeightOffsetLimit: Nullable<number>;
  92463. /**
  92464. * Define how fast the camera can accelerate to follow it s target.
  92465. */
  92466. cameraAcceleration: number;
  92467. /**
  92468. * Define the speed limit of the camera following an object.
  92469. */
  92470. maxCameraSpeed: number;
  92471. /**
  92472. * Define the target of the camera.
  92473. */
  92474. lockedTarget: Nullable<AbstractMesh>;
  92475. /**
  92476. * Defines the input associated with the camera.
  92477. */
  92478. inputs: FollowCameraInputsManager;
  92479. /**
  92480. * Instantiates the follow camera.
  92481. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92482. * @param name Define the name of the camera in the scene
  92483. * @param position Define the position of the camera
  92484. * @param scene Define the scene the camera belong to
  92485. * @param lockedTarget Define the target of the camera
  92486. */
  92487. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  92488. private _follow;
  92489. /**
  92490. * Attached controls to the current camera.
  92491. * @param element Defines the element the controls should be listened from
  92492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92493. */
  92494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92495. /**
  92496. * Detach the current controls from the camera.
  92497. * The camera will stop reacting to inputs.
  92498. * @param element Defines the element to stop listening the inputs from
  92499. */
  92500. detachControl(element: HTMLElement): void;
  92501. /** @hidden */
  92502. _checkInputs(): void;
  92503. private _checkLimits;
  92504. /**
  92505. * Gets the camera class name.
  92506. * @returns the class name
  92507. */
  92508. getClassName(): string;
  92509. }
  92510. /**
  92511. * Arc Rotate version of the follow camera.
  92512. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  92513. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92514. */
  92515. export class ArcFollowCamera extends TargetCamera {
  92516. /** The longitudinal angle of the camera */
  92517. alpha: number;
  92518. /** The latitudinal angle of the camera */
  92519. beta: number;
  92520. /** The radius of the camera from its target */
  92521. radius: number;
  92522. /** Define the camera target (the messh it should follow) */
  92523. target: Nullable<AbstractMesh>;
  92524. private _cartesianCoordinates;
  92525. /**
  92526. * Instantiates a new ArcFollowCamera
  92527. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  92528. * @param name Define the name of the camera
  92529. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  92530. * @param beta Define the rotation angle of the camera around the elevation axis
  92531. * @param radius Define the radius of the camera from its target point
  92532. * @param target Define the target of the camera
  92533. * @param scene Define the scene the camera belongs to
  92534. */
  92535. constructor(name: string,
  92536. /** The longitudinal angle of the camera */
  92537. alpha: number,
  92538. /** The latitudinal angle of the camera */
  92539. beta: number,
  92540. /** The radius of the camera from its target */
  92541. radius: number,
  92542. /** Define the camera target (the messh it should follow) */
  92543. target: Nullable<AbstractMesh>, scene: Scene);
  92544. private _follow;
  92545. /** @hidden */
  92546. _checkInputs(): void;
  92547. /**
  92548. * Returns the class name of the object.
  92549. * It is mostly used internally for serialization purposes.
  92550. */
  92551. getClassName(): string;
  92552. }
  92553. }
  92554. declare module BABYLON {
  92555. /**
  92556. * 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,
  92557. * which still works and will still be found in many Playgrounds.
  92558. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92559. */
  92560. export class UniversalCamera extends TouchCamera {
  92561. /**
  92562. * Defines the gamepad rotation sensiblity.
  92563. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  92564. */
  92565. gamepadAngularSensibility: number;
  92566. /**
  92567. * Defines the gamepad move sensiblity.
  92568. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  92569. */
  92570. gamepadMoveSensibility: number;
  92571. /**
  92572. * 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,
  92573. * which still works and will still be found in many Playgrounds.
  92574. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92575. * @param name Define the name of the camera in the scene
  92576. * @param position Define the start position of the camera in the scene
  92577. * @param scene Define the scene the camera belongs to
  92578. */
  92579. constructor(name: string, position: Vector3, scene: Scene);
  92580. /**
  92581. * Gets the current object class name.
  92582. * @return the class name
  92583. */
  92584. getClassName(): string;
  92585. }
  92586. }
  92587. declare module BABYLON {
  92588. /**
  92589. * This represents a FPS type of camera. This is only here for back compat purpose.
  92590. * Please use the UniversalCamera instead as both are identical.
  92591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92592. */
  92593. export class GamepadCamera extends UniversalCamera {
  92594. /**
  92595. * Instantiates a new Gamepad Camera
  92596. * This represents a FPS type of camera. This is only here for back compat purpose.
  92597. * Please use the UniversalCamera instead as both are identical.
  92598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92599. * @param name Define the name of the camera in the scene
  92600. * @param position Define the start position of the camera in the scene
  92601. * @param scene Define the scene the camera belongs to
  92602. */
  92603. constructor(name: string, position: Vector3, scene: Scene);
  92604. /**
  92605. * Gets the current object class name.
  92606. * @return the class name
  92607. */
  92608. getClassName(): string;
  92609. }
  92610. }
  92611. declare module BABYLON {
  92612. /** @hidden */
  92613. export var passPixelShader: {
  92614. name: string;
  92615. shader: string;
  92616. };
  92617. }
  92618. declare module BABYLON {
  92619. /** @hidden */
  92620. export var passCubePixelShader: {
  92621. name: string;
  92622. shader: string;
  92623. };
  92624. }
  92625. declare module BABYLON {
  92626. /**
  92627. * PassPostProcess which produces an output the same as it's input
  92628. */
  92629. export class PassPostProcess extends PostProcess {
  92630. /**
  92631. * Creates the PassPostProcess
  92632. * @param name The name of the effect.
  92633. * @param options The required width/height ratio to downsize to before computing the render pass.
  92634. * @param camera The camera to apply the render pass to.
  92635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92636. * @param engine The engine which the post process will be applied. (default: current engine)
  92637. * @param reusable If the post process can be reused on the same frame. (default: false)
  92638. * @param textureType The type of texture to be used when performing the post processing.
  92639. * @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)
  92640. */
  92641. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92642. }
  92643. /**
  92644. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  92645. */
  92646. export class PassCubePostProcess extends PostProcess {
  92647. private _face;
  92648. /**
  92649. * Gets or sets the cube face to display.
  92650. * * 0 is +X
  92651. * * 1 is -X
  92652. * * 2 is +Y
  92653. * * 3 is -Y
  92654. * * 4 is +Z
  92655. * * 5 is -Z
  92656. */
  92657. face: number;
  92658. /**
  92659. * Creates the PassCubePostProcess
  92660. * @param name The name of the effect.
  92661. * @param options The required width/height ratio to downsize to before computing the render pass.
  92662. * @param camera The camera to apply the render pass to.
  92663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92664. * @param engine The engine which the post process will be applied. (default: current engine)
  92665. * @param reusable If the post process can be reused on the same frame. (default: false)
  92666. * @param textureType The type of texture to be used when performing the post processing.
  92667. * @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)
  92668. */
  92669. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  92670. }
  92671. }
  92672. declare module BABYLON {
  92673. /** @hidden */
  92674. export var anaglyphPixelShader: {
  92675. name: string;
  92676. shader: string;
  92677. };
  92678. }
  92679. declare module BABYLON {
  92680. /**
  92681. * Postprocess used to generate anaglyphic rendering
  92682. */
  92683. export class AnaglyphPostProcess extends PostProcess {
  92684. private _passedProcess;
  92685. /**
  92686. * Creates a new AnaglyphPostProcess
  92687. * @param name defines postprocess name
  92688. * @param options defines creation options or target ratio scale
  92689. * @param rigCameras defines cameras using this postprocess
  92690. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  92691. * @param engine defines hosting engine
  92692. * @param reusable defines if the postprocess will be reused multiple times per frame
  92693. */
  92694. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  92695. }
  92696. }
  92697. declare module BABYLON {
  92698. /**
  92699. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  92700. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92701. */
  92702. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  92703. /**
  92704. * Creates a new AnaglyphArcRotateCamera
  92705. * @param name defines camera name
  92706. * @param alpha defines alpha angle (in radians)
  92707. * @param beta defines beta angle (in radians)
  92708. * @param radius defines radius
  92709. * @param target defines camera target
  92710. * @param interaxialDistance defines distance between each color axis
  92711. * @param scene defines the hosting scene
  92712. */
  92713. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  92714. /**
  92715. * Gets camera class name
  92716. * @returns AnaglyphArcRotateCamera
  92717. */
  92718. getClassName(): string;
  92719. }
  92720. }
  92721. declare module BABYLON {
  92722. /**
  92723. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  92724. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92725. */
  92726. export class AnaglyphFreeCamera extends FreeCamera {
  92727. /**
  92728. * Creates a new AnaglyphFreeCamera
  92729. * @param name defines camera name
  92730. * @param position defines initial position
  92731. * @param interaxialDistance defines distance between each color axis
  92732. * @param scene defines the hosting scene
  92733. */
  92734. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92735. /**
  92736. * Gets camera class name
  92737. * @returns AnaglyphFreeCamera
  92738. */
  92739. getClassName(): string;
  92740. }
  92741. }
  92742. declare module BABYLON {
  92743. /**
  92744. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  92745. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92746. */
  92747. export class AnaglyphGamepadCamera extends GamepadCamera {
  92748. /**
  92749. * Creates a new AnaglyphGamepadCamera
  92750. * @param name defines camera name
  92751. * @param position defines initial position
  92752. * @param interaxialDistance defines distance between each color axis
  92753. * @param scene defines the hosting scene
  92754. */
  92755. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92756. /**
  92757. * Gets camera class name
  92758. * @returns AnaglyphGamepadCamera
  92759. */
  92760. getClassName(): string;
  92761. }
  92762. }
  92763. declare module BABYLON {
  92764. /**
  92765. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  92766. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  92767. */
  92768. export class AnaglyphUniversalCamera extends UniversalCamera {
  92769. /**
  92770. * Creates a new AnaglyphUniversalCamera
  92771. * @param name defines camera name
  92772. * @param position defines initial position
  92773. * @param interaxialDistance defines distance between each color axis
  92774. * @param scene defines the hosting scene
  92775. */
  92776. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  92777. /**
  92778. * Gets camera class name
  92779. * @returns AnaglyphUniversalCamera
  92780. */
  92781. getClassName(): string;
  92782. }
  92783. }
  92784. declare module BABYLON {
  92785. /** @hidden */
  92786. export var stereoscopicInterlacePixelShader: {
  92787. name: string;
  92788. shader: string;
  92789. };
  92790. }
  92791. declare module BABYLON {
  92792. /**
  92793. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  92794. */
  92795. export class StereoscopicInterlacePostProcess extends PostProcess {
  92796. private _stepSize;
  92797. private _passedProcess;
  92798. /**
  92799. * Initializes a StereoscopicInterlacePostProcess
  92800. * @param name The name of the effect.
  92801. * @param rigCameras The rig cameras to be appled to the post process
  92802. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  92803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92804. * @param engine The engine which the post process will be applied. (default: current engine)
  92805. * @param reusable If the post process can be reused on the same frame. (default: false)
  92806. */
  92807. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  92808. }
  92809. }
  92810. declare module BABYLON {
  92811. /**
  92812. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  92813. * @see http://doc.babylonjs.com/features/cameras
  92814. */
  92815. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  92816. /**
  92817. * Creates a new StereoscopicArcRotateCamera
  92818. * @param name defines camera name
  92819. * @param alpha defines alpha angle (in radians)
  92820. * @param beta defines beta angle (in radians)
  92821. * @param radius defines radius
  92822. * @param target defines camera target
  92823. * @param interaxialDistance defines distance between each color axis
  92824. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92825. * @param scene defines the hosting scene
  92826. */
  92827. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92828. /**
  92829. * Gets camera class name
  92830. * @returns StereoscopicArcRotateCamera
  92831. */
  92832. getClassName(): string;
  92833. }
  92834. }
  92835. declare module BABYLON {
  92836. /**
  92837. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  92838. * @see http://doc.babylonjs.com/features/cameras
  92839. */
  92840. export class StereoscopicFreeCamera extends FreeCamera {
  92841. /**
  92842. * Creates a new StereoscopicFreeCamera
  92843. * @param name defines camera name
  92844. * @param position defines initial position
  92845. * @param interaxialDistance defines distance between each color axis
  92846. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92847. * @param scene defines the hosting scene
  92848. */
  92849. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92850. /**
  92851. * Gets camera class name
  92852. * @returns StereoscopicFreeCamera
  92853. */
  92854. getClassName(): string;
  92855. }
  92856. }
  92857. declare module BABYLON {
  92858. /**
  92859. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  92860. * @see http://doc.babylonjs.com/features/cameras
  92861. */
  92862. export class StereoscopicGamepadCamera extends GamepadCamera {
  92863. /**
  92864. * Creates a new StereoscopicGamepadCamera
  92865. * @param name defines camera name
  92866. * @param position defines initial position
  92867. * @param interaxialDistance defines distance between each color axis
  92868. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92869. * @param scene defines the hosting scene
  92870. */
  92871. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92872. /**
  92873. * Gets camera class name
  92874. * @returns StereoscopicGamepadCamera
  92875. */
  92876. getClassName(): string;
  92877. }
  92878. }
  92879. declare module BABYLON {
  92880. /**
  92881. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  92882. * @see http://doc.babylonjs.com/features/cameras
  92883. */
  92884. export class StereoscopicUniversalCamera extends UniversalCamera {
  92885. /**
  92886. * Creates a new StereoscopicUniversalCamera
  92887. * @param name defines camera name
  92888. * @param position defines initial position
  92889. * @param interaxialDistance defines distance between each color axis
  92890. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  92891. * @param scene defines the hosting scene
  92892. */
  92893. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  92894. /**
  92895. * Gets camera class name
  92896. * @returns StereoscopicUniversalCamera
  92897. */
  92898. getClassName(): string;
  92899. }
  92900. }
  92901. declare module BABYLON {
  92902. /**
  92903. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92904. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92905. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92906. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92907. */
  92908. export class VirtualJoysticksCamera extends FreeCamera {
  92909. /**
  92910. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  92911. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  92912. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  92913. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  92914. * @param name Define the name of the camera in the scene
  92915. * @param position Define the start position of the camera in the scene
  92916. * @param scene Define the scene the camera belongs to
  92917. */
  92918. constructor(name: string, position: Vector3, scene: Scene);
  92919. /**
  92920. * Gets the current object class name.
  92921. * @return the class name
  92922. */
  92923. getClassName(): string;
  92924. }
  92925. }
  92926. declare module BABYLON {
  92927. /**
  92928. * This represents all the required metrics to create a VR camera.
  92929. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  92930. */
  92931. export class VRCameraMetrics {
  92932. /**
  92933. * Define the horizontal resolution off the screen.
  92934. */
  92935. hResolution: number;
  92936. /**
  92937. * Define the vertical resolution off the screen.
  92938. */
  92939. vResolution: number;
  92940. /**
  92941. * Define the horizontal screen size.
  92942. */
  92943. hScreenSize: number;
  92944. /**
  92945. * Define the vertical screen size.
  92946. */
  92947. vScreenSize: number;
  92948. /**
  92949. * Define the vertical screen center position.
  92950. */
  92951. vScreenCenter: number;
  92952. /**
  92953. * Define the distance of the eyes to the screen.
  92954. */
  92955. eyeToScreenDistance: number;
  92956. /**
  92957. * Define the distance between both lenses
  92958. */
  92959. lensSeparationDistance: number;
  92960. /**
  92961. * Define the distance between both viewer's eyes.
  92962. */
  92963. interpupillaryDistance: number;
  92964. /**
  92965. * Define the distortion factor of the VR postprocess.
  92966. * Please, touch with care.
  92967. */
  92968. distortionK: number[];
  92969. /**
  92970. * Define the chromatic aberration correction factors for the VR post process.
  92971. */
  92972. chromaAbCorrection: number[];
  92973. /**
  92974. * Define the scale factor of the post process.
  92975. * The smaller the better but the slower.
  92976. */
  92977. postProcessScaleFactor: number;
  92978. /**
  92979. * Define an offset for the lens center.
  92980. */
  92981. lensCenterOffset: number;
  92982. /**
  92983. * Define if the current vr camera should compensate the distortion of the lense or not.
  92984. */
  92985. compensateDistortion: boolean;
  92986. /**
  92987. * Gets the rendering aspect ratio based on the provided resolutions.
  92988. */
  92989. readonly aspectRatio: number;
  92990. /**
  92991. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  92992. */
  92993. readonly aspectRatioFov: number;
  92994. /**
  92995. * @hidden
  92996. */
  92997. readonly leftHMatrix: Matrix;
  92998. /**
  92999. * @hidden
  93000. */
  93001. readonly rightHMatrix: Matrix;
  93002. /**
  93003. * @hidden
  93004. */
  93005. readonly leftPreViewMatrix: Matrix;
  93006. /**
  93007. * @hidden
  93008. */
  93009. readonly rightPreViewMatrix: Matrix;
  93010. /**
  93011. * Get the default VRMetrics based on the most generic setup.
  93012. * @returns the default vr metrics
  93013. */
  93014. static GetDefault(): VRCameraMetrics;
  93015. }
  93016. }
  93017. declare module BABYLON {
  93018. /** @hidden */
  93019. export var vrDistortionCorrectionPixelShader: {
  93020. name: string;
  93021. shader: string;
  93022. };
  93023. }
  93024. declare module BABYLON {
  93025. /**
  93026. * VRDistortionCorrectionPostProcess used for mobile VR
  93027. */
  93028. export class VRDistortionCorrectionPostProcess extends PostProcess {
  93029. private _isRightEye;
  93030. private _distortionFactors;
  93031. private _postProcessScaleFactor;
  93032. private _lensCenterOffset;
  93033. private _scaleIn;
  93034. private _scaleFactor;
  93035. private _lensCenter;
  93036. /**
  93037. * Initializes the VRDistortionCorrectionPostProcess
  93038. * @param name The name of the effect.
  93039. * @param camera The camera to apply the render pass to.
  93040. * @param isRightEye If this is for the right eye distortion
  93041. * @param vrMetrics All the required metrics for the VR camera
  93042. */
  93043. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  93044. }
  93045. }
  93046. declare module BABYLON {
  93047. /**
  93048. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  93049. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93050. */
  93051. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  93052. /**
  93053. * Creates a new VRDeviceOrientationArcRotateCamera
  93054. * @param name defines camera name
  93055. * @param alpha defines the camera rotation along the logitudinal axis
  93056. * @param beta defines the camera rotation along the latitudinal axis
  93057. * @param radius defines the camera distance from its target
  93058. * @param target defines the camera target
  93059. * @param scene defines the scene the camera belongs to
  93060. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93061. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93062. */
  93063. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93064. /**
  93065. * Gets camera class name
  93066. * @returns VRDeviceOrientationArcRotateCamera
  93067. */
  93068. getClassName(): string;
  93069. }
  93070. }
  93071. declare module BABYLON {
  93072. /**
  93073. * Camera used to simulate VR rendering (based on FreeCamera)
  93074. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93075. */
  93076. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  93077. /**
  93078. * Creates a new VRDeviceOrientationFreeCamera
  93079. * @param name defines camera name
  93080. * @param position defines the start position of the camera
  93081. * @param scene defines the scene the camera belongs to
  93082. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93083. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93084. */
  93085. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93086. /**
  93087. * Gets camera class name
  93088. * @returns VRDeviceOrientationFreeCamera
  93089. */
  93090. getClassName(): string;
  93091. }
  93092. }
  93093. declare module BABYLON {
  93094. /**
  93095. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  93096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  93097. */
  93098. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  93099. /**
  93100. * Creates a new VRDeviceOrientationGamepadCamera
  93101. * @param name defines camera name
  93102. * @param position defines the start position of the camera
  93103. * @param scene defines the scene the camera belongs to
  93104. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  93105. * @param vrCameraMetrics defines the vr metrics associated to the camera
  93106. */
  93107. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  93108. /**
  93109. * Gets camera class name
  93110. * @returns VRDeviceOrientationGamepadCamera
  93111. */
  93112. getClassName(): string;
  93113. }
  93114. }
  93115. declare module BABYLON {
  93116. /**
  93117. * Defines supported buttons for XBox360 compatible gamepads
  93118. */
  93119. export enum Xbox360Button {
  93120. /** A */
  93121. A = 0,
  93122. /** B */
  93123. B = 1,
  93124. /** X */
  93125. X = 2,
  93126. /** Y */
  93127. Y = 3,
  93128. /** Start */
  93129. Start = 4,
  93130. /** Back */
  93131. Back = 5,
  93132. /** Left button */
  93133. LB = 6,
  93134. /** Right button */
  93135. RB = 7,
  93136. /** Left stick */
  93137. LeftStick = 8,
  93138. /** Right stick */
  93139. RightStick = 9
  93140. }
  93141. /** Defines values for XBox360 DPad */
  93142. export enum Xbox360Dpad {
  93143. /** Up */
  93144. Up = 0,
  93145. /** Down */
  93146. Down = 1,
  93147. /** Left */
  93148. Left = 2,
  93149. /** Right */
  93150. Right = 3
  93151. }
  93152. /**
  93153. * Defines a XBox360 gamepad
  93154. */
  93155. export class Xbox360Pad extends Gamepad {
  93156. private _leftTrigger;
  93157. private _rightTrigger;
  93158. private _onlefttriggerchanged;
  93159. private _onrighttriggerchanged;
  93160. private _onbuttondown;
  93161. private _onbuttonup;
  93162. private _ondpaddown;
  93163. private _ondpadup;
  93164. /** Observable raised when a button is pressed */
  93165. onButtonDownObservable: Observable<Xbox360Button>;
  93166. /** Observable raised when a button is released */
  93167. onButtonUpObservable: Observable<Xbox360Button>;
  93168. /** Observable raised when a pad is pressed */
  93169. onPadDownObservable: Observable<Xbox360Dpad>;
  93170. /** Observable raised when a pad is released */
  93171. onPadUpObservable: Observable<Xbox360Dpad>;
  93172. private _buttonA;
  93173. private _buttonB;
  93174. private _buttonX;
  93175. private _buttonY;
  93176. private _buttonBack;
  93177. private _buttonStart;
  93178. private _buttonLB;
  93179. private _buttonRB;
  93180. private _buttonLeftStick;
  93181. private _buttonRightStick;
  93182. private _dPadUp;
  93183. private _dPadDown;
  93184. private _dPadLeft;
  93185. private _dPadRight;
  93186. private _isXboxOnePad;
  93187. /**
  93188. * Creates a new XBox360 gamepad object
  93189. * @param id defines the id of this gamepad
  93190. * @param index defines its index
  93191. * @param gamepad defines the internal HTML gamepad object
  93192. * @param xboxOne defines if it is a XBox One gamepad
  93193. */
  93194. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  93195. /**
  93196. * Defines the callback to call when left trigger is pressed
  93197. * @param callback defines the callback to use
  93198. */
  93199. onlefttriggerchanged(callback: (value: number) => void): void;
  93200. /**
  93201. * Defines the callback to call when right trigger is pressed
  93202. * @param callback defines the callback to use
  93203. */
  93204. onrighttriggerchanged(callback: (value: number) => void): void;
  93205. /**
  93206. * Gets the left trigger value
  93207. */
  93208. /**
  93209. * Sets the left trigger value
  93210. */
  93211. leftTrigger: number;
  93212. /**
  93213. * Gets the right trigger value
  93214. */
  93215. /**
  93216. * Sets the right trigger value
  93217. */
  93218. rightTrigger: number;
  93219. /**
  93220. * Defines the callback to call when a button is pressed
  93221. * @param callback defines the callback to use
  93222. */
  93223. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  93224. /**
  93225. * Defines the callback to call when a button is released
  93226. * @param callback defines the callback to use
  93227. */
  93228. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  93229. /**
  93230. * Defines the callback to call when a pad is pressed
  93231. * @param callback defines the callback to use
  93232. */
  93233. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  93234. /**
  93235. * Defines the callback to call when a pad is released
  93236. * @param callback defines the callback to use
  93237. */
  93238. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  93239. private _setButtonValue;
  93240. private _setDPadValue;
  93241. /**
  93242. * Gets the value of the `A` button
  93243. */
  93244. /**
  93245. * Sets the value of the `A` button
  93246. */
  93247. buttonA: number;
  93248. /**
  93249. * Gets the value of the `B` button
  93250. */
  93251. /**
  93252. * Sets the value of the `B` button
  93253. */
  93254. buttonB: number;
  93255. /**
  93256. * Gets the value of the `X` button
  93257. */
  93258. /**
  93259. * Sets the value of the `X` button
  93260. */
  93261. buttonX: number;
  93262. /**
  93263. * Gets the value of the `Y` button
  93264. */
  93265. /**
  93266. * Sets the value of the `Y` button
  93267. */
  93268. buttonY: number;
  93269. /**
  93270. * Gets the value of the `Start` button
  93271. */
  93272. /**
  93273. * Sets the value of the `Start` button
  93274. */
  93275. buttonStart: number;
  93276. /**
  93277. * Gets the value of the `Back` button
  93278. */
  93279. /**
  93280. * Sets the value of the `Back` button
  93281. */
  93282. buttonBack: number;
  93283. /**
  93284. * Gets the value of the `Left` button
  93285. */
  93286. /**
  93287. * Sets the value of the `Left` button
  93288. */
  93289. buttonLB: number;
  93290. /**
  93291. * Gets the value of the `Right` button
  93292. */
  93293. /**
  93294. * Sets the value of the `Right` button
  93295. */
  93296. buttonRB: number;
  93297. /**
  93298. * Gets the value of the Left joystick
  93299. */
  93300. /**
  93301. * Sets the value of the Left joystick
  93302. */
  93303. buttonLeftStick: number;
  93304. /**
  93305. * Gets the value of the Right joystick
  93306. */
  93307. /**
  93308. * Sets the value of the Right joystick
  93309. */
  93310. buttonRightStick: number;
  93311. /**
  93312. * Gets the value of D-pad up
  93313. */
  93314. /**
  93315. * Sets the value of D-pad up
  93316. */
  93317. dPadUp: number;
  93318. /**
  93319. * Gets the value of D-pad down
  93320. */
  93321. /**
  93322. * Sets the value of D-pad down
  93323. */
  93324. dPadDown: number;
  93325. /**
  93326. * Gets the value of D-pad left
  93327. */
  93328. /**
  93329. * Sets the value of D-pad left
  93330. */
  93331. dPadLeft: number;
  93332. /**
  93333. * Gets the value of D-pad right
  93334. */
  93335. /**
  93336. * Sets the value of D-pad right
  93337. */
  93338. dPadRight: number;
  93339. /**
  93340. * Force the gamepad to synchronize with device values
  93341. */
  93342. update(): void;
  93343. /**
  93344. * Disposes the gamepad
  93345. */
  93346. dispose(): void;
  93347. }
  93348. }
  93349. declare module BABYLON {
  93350. /**
  93351. * Base class of materials working in push mode in babylon JS
  93352. * @hidden
  93353. */
  93354. export class PushMaterial extends Material {
  93355. protected _activeEffect: Effect;
  93356. protected _normalMatrix: Matrix;
  93357. /**
  93358. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  93359. * This means that the material can keep using a previous shader while a new one is being compiled.
  93360. * This is mostly used when shader parallel compilation is supported (true by default)
  93361. */
  93362. allowShaderHotSwapping: boolean;
  93363. constructor(name: string, scene: Scene);
  93364. getEffect(): Effect;
  93365. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  93366. /**
  93367. * Binds the given world matrix to the active effect
  93368. *
  93369. * @param world the matrix to bind
  93370. */
  93371. bindOnlyWorldMatrix(world: Matrix): void;
  93372. /**
  93373. * Binds the given normal matrix to the active effect
  93374. *
  93375. * @param normalMatrix the matrix to bind
  93376. */
  93377. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  93378. bind(world: Matrix, mesh?: Mesh): void;
  93379. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  93380. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  93381. }
  93382. }
  93383. declare module BABYLON {
  93384. /**
  93385. * This groups all the flags used to control the materials channel.
  93386. */
  93387. export class MaterialFlags {
  93388. private static _DiffuseTextureEnabled;
  93389. /**
  93390. * Are diffuse textures enabled in the application.
  93391. */
  93392. static DiffuseTextureEnabled: boolean;
  93393. private static _AmbientTextureEnabled;
  93394. /**
  93395. * Are ambient textures enabled in the application.
  93396. */
  93397. static AmbientTextureEnabled: boolean;
  93398. private static _OpacityTextureEnabled;
  93399. /**
  93400. * Are opacity textures enabled in the application.
  93401. */
  93402. static OpacityTextureEnabled: boolean;
  93403. private static _ReflectionTextureEnabled;
  93404. /**
  93405. * Are reflection textures enabled in the application.
  93406. */
  93407. static ReflectionTextureEnabled: boolean;
  93408. private static _EmissiveTextureEnabled;
  93409. /**
  93410. * Are emissive textures enabled in the application.
  93411. */
  93412. static EmissiveTextureEnabled: boolean;
  93413. private static _SpecularTextureEnabled;
  93414. /**
  93415. * Are specular textures enabled in the application.
  93416. */
  93417. static SpecularTextureEnabled: boolean;
  93418. private static _BumpTextureEnabled;
  93419. /**
  93420. * Are bump textures enabled in the application.
  93421. */
  93422. static BumpTextureEnabled: boolean;
  93423. private static _LightmapTextureEnabled;
  93424. /**
  93425. * Are lightmap textures enabled in the application.
  93426. */
  93427. static LightmapTextureEnabled: boolean;
  93428. private static _RefractionTextureEnabled;
  93429. /**
  93430. * Are refraction textures enabled in the application.
  93431. */
  93432. static RefractionTextureEnabled: boolean;
  93433. private static _ColorGradingTextureEnabled;
  93434. /**
  93435. * Are color grading textures enabled in the application.
  93436. */
  93437. static ColorGradingTextureEnabled: boolean;
  93438. private static _FresnelEnabled;
  93439. /**
  93440. * Are fresnels enabled in the application.
  93441. */
  93442. static FresnelEnabled: boolean;
  93443. }
  93444. }
  93445. declare module BABYLON {
  93446. /** @hidden */
  93447. export var defaultFragmentDeclaration: {
  93448. name: string;
  93449. shader: string;
  93450. };
  93451. }
  93452. declare module BABYLON {
  93453. /** @hidden */
  93454. export var defaultUboDeclaration: {
  93455. name: string;
  93456. shader: string;
  93457. };
  93458. }
  93459. declare module BABYLON {
  93460. /** @hidden */
  93461. export var lightFragmentDeclaration: {
  93462. name: string;
  93463. shader: string;
  93464. };
  93465. }
  93466. declare module BABYLON {
  93467. /** @hidden */
  93468. export var lightUboDeclaration: {
  93469. name: string;
  93470. shader: string;
  93471. };
  93472. }
  93473. declare module BABYLON {
  93474. /** @hidden */
  93475. export var lightsFragmentFunctions: {
  93476. name: string;
  93477. shader: string;
  93478. };
  93479. }
  93480. declare module BABYLON {
  93481. /** @hidden */
  93482. export var shadowsFragmentFunctions: {
  93483. name: string;
  93484. shader: string;
  93485. };
  93486. }
  93487. declare module BABYLON {
  93488. /** @hidden */
  93489. export var fresnelFunction: {
  93490. name: string;
  93491. shader: string;
  93492. };
  93493. }
  93494. declare module BABYLON {
  93495. /** @hidden */
  93496. export var reflectionFunction: {
  93497. name: string;
  93498. shader: string;
  93499. };
  93500. }
  93501. declare module BABYLON {
  93502. /** @hidden */
  93503. export var bumpFragmentFunctions: {
  93504. name: string;
  93505. shader: string;
  93506. };
  93507. }
  93508. declare module BABYLON {
  93509. /** @hidden */
  93510. export var logDepthDeclaration: {
  93511. name: string;
  93512. shader: string;
  93513. };
  93514. }
  93515. declare module BABYLON {
  93516. /** @hidden */
  93517. export var bumpFragment: {
  93518. name: string;
  93519. shader: string;
  93520. };
  93521. }
  93522. declare module BABYLON {
  93523. /** @hidden */
  93524. export var depthPrePass: {
  93525. name: string;
  93526. shader: string;
  93527. };
  93528. }
  93529. declare module BABYLON {
  93530. /** @hidden */
  93531. export var lightFragment: {
  93532. name: string;
  93533. shader: string;
  93534. };
  93535. }
  93536. declare module BABYLON {
  93537. /** @hidden */
  93538. export var logDepthFragment: {
  93539. name: string;
  93540. shader: string;
  93541. };
  93542. }
  93543. declare module BABYLON {
  93544. /** @hidden */
  93545. export var defaultPixelShader: {
  93546. name: string;
  93547. shader: string;
  93548. };
  93549. }
  93550. declare module BABYLON {
  93551. /** @hidden */
  93552. export var defaultVertexDeclaration: {
  93553. name: string;
  93554. shader: string;
  93555. };
  93556. }
  93557. declare module BABYLON {
  93558. /** @hidden */
  93559. export var bumpVertexDeclaration: {
  93560. name: string;
  93561. shader: string;
  93562. };
  93563. }
  93564. declare module BABYLON {
  93565. /** @hidden */
  93566. export var bumpVertex: {
  93567. name: string;
  93568. shader: string;
  93569. };
  93570. }
  93571. declare module BABYLON {
  93572. /** @hidden */
  93573. export var fogVertex: {
  93574. name: string;
  93575. shader: string;
  93576. };
  93577. }
  93578. declare module BABYLON {
  93579. /** @hidden */
  93580. export var shadowsVertex: {
  93581. name: string;
  93582. shader: string;
  93583. };
  93584. }
  93585. declare module BABYLON {
  93586. /** @hidden */
  93587. export var pointCloudVertex: {
  93588. name: string;
  93589. shader: string;
  93590. };
  93591. }
  93592. declare module BABYLON {
  93593. /** @hidden */
  93594. export var logDepthVertex: {
  93595. name: string;
  93596. shader: string;
  93597. };
  93598. }
  93599. declare module BABYLON {
  93600. /** @hidden */
  93601. export var defaultVertexShader: {
  93602. name: string;
  93603. shader: string;
  93604. };
  93605. }
  93606. declare module BABYLON {
  93607. /** @hidden */
  93608. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  93609. MAINUV1: boolean;
  93610. MAINUV2: boolean;
  93611. DIFFUSE: boolean;
  93612. DIFFUSEDIRECTUV: number;
  93613. AMBIENT: boolean;
  93614. AMBIENTDIRECTUV: number;
  93615. OPACITY: boolean;
  93616. OPACITYDIRECTUV: number;
  93617. OPACITYRGB: boolean;
  93618. REFLECTION: boolean;
  93619. EMISSIVE: boolean;
  93620. EMISSIVEDIRECTUV: number;
  93621. SPECULAR: boolean;
  93622. SPECULARDIRECTUV: number;
  93623. BUMP: boolean;
  93624. BUMPDIRECTUV: number;
  93625. PARALLAX: boolean;
  93626. PARALLAXOCCLUSION: boolean;
  93627. SPECULAROVERALPHA: boolean;
  93628. CLIPPLANE: boolean;
  93629. CLIPPLANE2: boolean;
  93630. CLIPPLANE3: boolean;
  93631. CLIPPLANE4: boolean;
  93632. ALPHATEST: boolean;
  93633. DEPTHPREPASS: boolean;
  93634. ALPHAFROMDIFFUSE: boolean;
  93635. POINTSIZE: boolean;
  93636. FOG: boolean;
  93637. SPECULARTERM: boolean;
  93638. DIFFUSEFRESNEL: boolean;
  93639. OPACITYFRESNEL: boolean;
  93640. REFLECTIONFRESNEL: boolean;
  93641. REFRACTIONFRESNEL: boolean;
  93642. EMISSIVEFRESNEL: boolean;
  93643. FRESNEL: boolean;
  93644. NORMAL: boolean;
  93645. UV1: boolean;
  93646. UV2: boolean;
  93647. VERTEXCOLOR: boolean;
  93648. VERTEXALPHA: boolean;
  93649. NUM_BONE_INFLUENCERS: number;
  93650. BonesPerMesh: number;
  93651. BONETEXTURE: boolean;
  93652. INSTANCES: boolean;
  93653. GLOSSINESS: boolean;
  93654. ROUGHNESS: boolean;
  93655. EMISSIVEASILLUMINATION: boolean;
  93656. LINKEMISSIVEWITHDIFFUSE: boolean;
  93657. REFLECTIONFRESNELFROMSPECULAR: boolean;
  93658. LIGHTMAP: boolean;
  93659. LIGHTMAPDIRECTUV: number;
  93660. OBJECTSPACE_NORMALMAP: boolean;
  93661. USELIGHTMAPASSHADOWMAP: boolean;
  93662. REFLECTIONMAP_3D: boolean;
  93663. REFLECTIONMAP_SPHERICAL: boolean;
  93664. REFLECTIONMAP_PLANAR: boolean;
  93665. REFLECTIONMAP_CUBIC: boolean;
  93666. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  93667. REFLECTIONMAP_PROJECTION: boolean;
  93668. REFLECTIONMAP_SKYBOX: boolean;
  93669. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  93670. REFLECTIONMAP_EXPLICIT: boolean;
  93671. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  93672. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  93673. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  93674. INVERTCUBICMAP: boolean;
  93675. LOGARITHMICDEPTH: boolean;
  93676. REFRACTION: boolean;
  93677. REFRACTIONMAP_3D: boolean;
  93678. REFLECTIONOVERALPHA: boolean;
  93679. TWOSIDEDLIGHTING: boolean;
  93680. SHADOWFLOAT: boolean;
  93681. MORPHTARGETS: boolean;
  93682. MORPHTARGETS_NORMAL: boolean;
  93683. MORPHTARGETS_TANGENT: boolean;
  93684. NUM_MORPH_INFLUENCERS: number;
  93685. NONUNIFORMSCALING: boolean;
  93686. PREMULTIPLYALPHA: boolean;
  93687. IMAGEPROCESSING: boolean;
  93688. VIGNETTE: boolean;
  93689. VIGNETTEBLENDMODEMULTIPLY: boolean;
  93690. VIGNETTEBLENDMODEOPAQUE: boolean;
  93691. TONEMAPPING: boolean;
  93692. TONEMAPPING_ACES: boolean;
  93693. CONTRAST: boolean;
  93694. COLORCURVES: boolean;
  93695. COLORGRADING: boolean;
  93696. COLORGRADING3D: boolean;
  93697. SAMPLER3DGREENDEPTH: boolean;
  93698. SAMPLER3DBGRMAP: boolean;
  93699. IMAGEPROCESSINGPOSTPROCESS: boolean;
  93700. /**
  93701. * If the reflection texture on this material is in linear color space
  93702. * @hidden
  93703. */
  93704. IS_REFLECTION_LINEAR: boolean;
  93705. /**
  93706. * If the refraction texture on this material is in linear color space
  93707. * @hidden
  93708. */
  93709. IS_REFRACTION_LINEAR: boolean;
  93710. EXPOSURE: boolean;
  93711. constructor();
  93712. setReflectionMode(modeToEnable: string): void;
  93713. }
  93714. /**
  93715. * This is the default material used in Babylon. It is the best trade off between quality
  93716. * and performances.
  93717. * @see http://doc.babylonjs.com/babylon101/materials
  93718. */
  93719. export class StandardMaterial extends PushMaterial {
  93720. private _diffuseTexture;
  93721. /**
  93722. * The basic texture of the material as viewed under a light.
  93723. */
  93724. diffuseTexture: Nullable<BaseTexture>;
  93725. private _ambientTexture;
  93726. /**
  93727. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  93728. */
  93729. ambientTexture: Nullable<BaseTexture>;
  93730. private _opacityTexture;
  93731. /**
  93732. * Define the transparency of the material from a texture.
  93733. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  93734. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  93735. */
  93736. opacityTexture: Nullable<BaseTexture>;
  93737. private _reflectionTexture;
  93738. /**
  93739. * Define the texture used to display the reflection.
  93740. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93741. */
  93742. reflectionTexture: Nullable<BaseTexture>;
  93743. private _emissiveTexture;
  93744. /**
  93745. * Define texture of the material as if self lit.
  93746. * This will be mixed in the final result even in the absence of light.
  93747. */
  93748. emissiveTexture: Nullable<BaseTexture>;
  93749. private _specularTexture;
  93750. /**
  93751. * Define how the color and intensity of the highlight given by the light in the material.
  93752. */
  93753. specularTexture: Nullable<BaseTexture>;
  93754. private _bumpTexture;
  93755. /**
  93756. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  93757. * 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.
  93758. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  93759. */
  93760. bumpTexture: Nullable<BaseTexture>;
  93761. private _lightmapTexture;
  93762. /**
  93763. * Complex lighting can be computationally expensive to compute at runtime.
  93764. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  93765. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  93766. */
  93767. lightmapTexture: Nullable<BaseTexture>;
  93768. private _refractionTexture;
  93769. /**
  93770. * Define the texture used to display the refraction.
  93771. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93772. */
  93773. refractionTexture: Nullable<BaseTexture>;
  93774. /**
  93775. * The color of the material lit by the environmental background lighting.
  93776. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  93777. */
  93778. ambientColor: Color3;
  93779. /**
  93780. * The basic color of the material as viewed under a light.
  93781. */
  93782. diffuseColor: Color3;
  93783. /**
  93784. * Define how the color and intensity of the highlight given by the light in the material.
  93785. */
  93786. specularColor: Color3;
  93787. /**
  93788. * Define the color of the material as if self lit.
  93789. * This will be mixed in the final result even in the absence of light.
  93790. */
  93791. emissiveColor: Color3;
  93792. /**
  93793. * Defines how sharp are the highlights in the material.
  93794. * The bigger the value the sharper giving a more glossy feeling to the result.
  93795. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  93796. */
  93797. specularPower: number;
  93798. private _useAlphaFromDiffuseTexture;
  93799. /**
  93800. * Does the transparency come from the diffuse texture alpha channel.
  93801. */
  93802. useAlphaFromDiffuseTexture: boolean;
  93803. private _useEmissiveAsIllumination;
  93804. /**
  93805. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  93806. */
  93807. useEmissiveAsIllumination: boolean;
  93808. private _linkEmissiveWithDiffuse;
  93809. /**
  93810. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  93811. * the emissive level when the final color is close to one.
  93812. */
  93813. linkEmissiveWithDiffuse: boolean;
  93814. private _useSpecularOverAlpha;
  93815. /**
  93816. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  93817. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  93818. */
  93819. useSpecularOverAlpha: boolean;
  93820. private _useReflectionOverAlpha;
  93821. /**
  93822. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  93823. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  93824. */
  93825. useReflectionOverAlpha: boolean;
  93826. private _disableLighting;
  93827. /**
  93828. * Does lights from the scene impacts this material.
  93829. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  93830. */
  93831. disableLighting: boolean;
  93832. private _useObjectSpaceNormalMap;
  93833. /**
  93834. * Allows using an object space normal map (instead of tangent space).
  93835. */
  93836. useObjectSpaceNormalMap: boolean;
  93837. private _useParallax;
  93838. /**
  93839. * Is parallax enabled or not.
  93840. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93841. */
  93842. useParallax: boolean;
  93843. private _useParallaxOcclusion;
  93844. /**
  93845. * Is parallax occlusion enabled or not.
  93846. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  93847. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  93848. */
  93849. useParallaxOcclusion: boolean;
  93850. /**
  93851. * 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.
  93852. */
  93853. parallaxScaleBias: number;
  93854. private _roughness;
  93855. /**
  93856. * Helps to define how blurry the reflections should appears in the material.
  93857. */
  93858. roughness: number;
  93859. /**
  93860. * In case of refraction, define the value of the indice of refraction.
  93861. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93862. */
  93863. indexOfRefraction: number;
  93864. /**
  93865. * Invert the refraction texture alongside the y axis.
  93866. * It can be useful with procedural textures or probe for instance.
  93867. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  93868. */
  93869. invertRefractionY: boolean;
  93870. /**
  93871. * Defines the alpha limits in alpha test mode.
  93872. */
  93873. alphaCutOff: number;
  93874. private _useLightmapAsShadowmap;
  93875. /**
  93876. * In case of light mapping, define whether the map contains light or shadow informations.
  93877. */
  93878. useLightmapAsShadowmap: boolean;
  93879. private _diffuseFresnelParameters;
  93880. /**
  93881. * Define the diffuse fresnel parameters of the material.
  93882. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93883. */
  93884. diffuseFresnelParameters: FresnelParameters;
  93885. private _opacityFresnelParameters;
  93886. /**
  93887. * Define the opacity fresnel parameters of the material.
  93888. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93889. */
  93890. opacityFresnelParameters: FresnelParameters;
  93891. private _reflectionFresnelParameters;
  93892. /**
  93893. * Define the reflection fresnel parameters of the material.
  93894. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93895. */
  93896. reflectionFresnelParameters: FresnelParameters;
  93897. private _refractionFresnelParameters;
  93898. /**
  93899. * Define the refraction fresnel parameters of the material.
  93900. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93901. */
  93902. refractionFresnelParameters: FresnelParameters;
  93903. private _emissiveFresnelParameters;
  93904. /**
  93905. * Define the emissive fresnel parameters of the material.
  93906. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93907. */
  93908. emissiveFresnelParameters: FresnelParameters;
  93909. private _useReflectionFresnelFromSpecular;
  93910. /**
  93911. * If true automatically deducts the fresnels values from the material specularity.
  93912. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  93913. */
  93914. useReflectionFresnelFromSpecular: boolean;
  93915. private _useGlossinessFromSpecularMapAlpha;
  93916. /**
  93917. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  93918. */
  93919. useGlossinessFromSpecularMapAlpha: boolean;
  93920. private _maxSimultaneousLights;
  93921. /**
  93922. * Defines the maximum number of lights that can be used in the material
  93923. */
  93924. maxSimultaneousLights: number;
  93925. private _invertNormalMapX;
  93926. /**
  93927. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  93928. */
  93929. invertNormalMapX: boolean;
  93930. private _invertNormalMapY;
  93931. /**
  93932. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  93933. */
  93934. invertNormalMapY: boolean;
  93935. private _twoSidedLighting;
  93936. /**
  93937. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  93938. */
  93939. twoSidedLighting: boolean;
  93940. /**
  93941. * Default configuration related to image processing available in the standard Material.
  93942. */
  93943. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  93944. /**
  93945. * Gets the image processing configuration used either in this material.
  93946. */
  93947. /**
  93948. * Sets the Default image processing configuration used either in the this material.
  93949. *
  93950. * If sets to null, the scene one is in use.
  93951. */
  93952. imageProcessingConfiguration: ImageProcessingConfiguration;
  93953. /**
  93954. * Keep track of the image processing observer to allow dispose and replace.
  93955. */
  93956. private _imageProcessingObserver;
  93957. /**
  93958. * Attaches a new image processing configuration to the Standard Material.
  93959. * @param configuration
  93960. */
  93961. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93962. /**
  93963. * Gets wether the color curves effect is enabled.
  93964. */
  93965. /**
  93966. * Sets wether the color curves effect is enabled.
  93967. */
  93968. cameraColorCurvesEnabled: boolean;
  93969. /**
  93970. * Gets wether the color grading effect is enabled.
  93971. */
  93972. /**
  93973. * Gets wether the color grading effect is enabled.
  93974. */
  93975. cameraColorGradingEnabled: boolean;
  93976. /**
  93977. * Gets wether tonemapping is enabled or not.
  93978. */
  93979. /**
  93980. * Sets wether tonemapping is enabled or not
  93981. */
  93982. cameraToneMappingEnabled: boolean;
  93983. /**
  93984. * The camera exposure used on this material.
  93985. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  93986. * This corresponds to a photographic exposure.
  93987. */
  93988. /**
  93989. * The camera exposure used on this material.
  93990. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  93991. * This corresponds to a photographic exposure.
  93992. */
  93993. cameraExposure: number;
  93994. /**
  93995. * Gets The camera contrast used on this material.
  93996. */
  93997. /**
  93998. * Sets The camera contrast used on this material.
  93999. */
  94000. cameraContrast: number;
  94001. /**
  94002. * Gets the Color Grading 2D Lookup Texture.
  94003. */
  94004. /**
  94005. * Sets the Color Grading 2D Lookup Texture.
  94006. */
  94007. cameraColorGradingTexture: Nullable<BaseTexture>;
  94008. /**
  94009. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94010. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94011. * 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;
  94012. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94013. */
  94014. /**
  94015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  94016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  94017. * 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;
  94018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  94019. */
  94020. cameraColorCurves: Nullable<ColorCurves>;
  94021. /**
  94022. * Custom callback helping to override the default shader used in the material.
  94023. */
  94024. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  94025. protected _renderTargets: SmartArray<RenderTargetTexture>;
  94026. protected _worldViewProjectionMatrix: Matrix;
  94027. protected _globalAmbientColor: Color3;
  94028. protected _useLogarithmicDepth: boolean;
  94029. /**
  94030. * Instantiates a new standard material.
  94031. * This is the default material used in Babylon. It is the best trade off between quality
  94032. * and performances.
  94033. * @see http://doc.babylonjs.com/babylon101/materials
  94034. * @param name Define the name of the material in the scene
  94035. * @param scene Define the scene the material belong to
  94036. */
  94037. constructor(name: string, scene: Scene);
  94038. /**
  94039. * Gets a boolean indicating that current material needs to register RTT
  94040. */
  94041. readonly hasRenderTargetTextures: boolean;
  94042. /**
  94043. * Gets the current class name of the material e.g. "StandardMaterial"
  94044. * Mainly use in serialization.
  94045. * @returns the class name
  94046. */
  94047. getClassName(): string;
  94048. /**
  94049. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  94050. * You can try switching to logarithmic depth.
  94051. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  94052. */
  94053. useLogarithmicDepth: boolean;
  94054. /**
  94055. * Specifies if the material will require alpha blending
  94056. * @returns a boolean specifying if alpha blending is needed
  94057. */
  94058. needAlphaBlending(): boolean;
  94059. /**
  94060. * Specifies if this material should be rendered in alpha test mode
  94061. * @returns a boolean specifying if an alpha test is needed.
  94062. */
  94063. needAlphaTesting(): boolean;
  94064. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  94065. /**
  94066. * Get the texture used for alpha test purpose.
  94067. * @returns the diffuse texture in case of the standard material.
  94068. */
  94069. getAlphaTestTexture(): Nullable<BaseTexture>;
  94070. /**
  94071. * Get if the submesh is ready to be used and all its information available.
  94072. * Child classes can use it to update shaders
  94073. * @param mesh defines the mesh to check
  94074. * @param subMesh defines which submesh to check
  94075. * @param useInstances specifies that instances should be used
  94076. * @returns a boolean indicating that the submesh is ready or not
  94077. */
  94078. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94079. /**
  94080. * Builds the material UBO layouts.
  94081. * Used internally during the effect preparation.
  94082. */
  94083. buildUniformLayout(): void;
  94084. /**
  94085. * Unbinds the material from the mesh
  94086. */
  94087. unbind(): void;
  94088. /**
  94089. * Binds the submesh to this material by preparing the effect and shader to draw
  94090. * @param world defines the world transformation matrix
  94091. * @param mesh defines the mesh containing the submesh
  94092. * @param subMesh defines the submesh to bind the material to
  94093. */
  94094. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94095. /**
  94096. * Get the list of animatables in the material.
  94097. * @returns the list of animatables object used in the material
  94098. */
  94099. getAnimatables(): IAnimatable[];
  94100. /**
  94101. * Gets the active textures from the material
  94102. * @returns an array of textures
  94103. */
  94104. getActiveTextures(): BaseTexture[];
  94105. /**
  94106. * Specifies if the material uses a texture
  94107. * @param texture defines the texture to check against the material
  94108. * @returns a boolean specifying if the material uses the texture
  94109. */
  94110. hasTexture(texture: BaseTexture): boolean;
  94111. /**
  94112. * Disposes the material
  94113. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94114. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94115. */
  94116. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  94117. /**
  94118. * Makes a duplicate of the material, and gives it a new name
  94119. * @param name defines the new name for the duplicated material
  94120. * @returns the cloned material
  94121. */
  94122. clone(name: string): StandardMaterial;
  94123. /**
  94124. * Serializes this material in a JSON representation
  94125. * @returns the serialized material object
  94126. */
  94127. serialize(): any;
  94128. /**
  94129. * Creates a standard material from parsed material data
  94130. * @param source defines the JSON representation of the material
  94131. * @param scene defines the hosting scene
  94132. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94133. * @returns a new standard material
  94134. */
  94135. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  94136. /**
  94137. * Are diffuse textures enabled in the application.
  94138. */
  94139. static DiffuseTextureEnabled: boolean;
  94140. /**
  94141. * Are ambient textures enabled in the application.
  94142. */
  94143. static AmbientTextureEnabled: boolean;
  94144. /**
  94145. * Are opacity textures enabled in the application.
  94146. */
  94147. static OpacityTextureEnabled: boolean;
  94148. /**
  94149. * Are reflection textures enabled in the application.
  94150. */
  94151. static ReflectionTextureEnabled: boolean;
  94152. /**
  94153. * Are emissive textures enabled in the application.
  94154. */
  94155. static EmissiveTextureEnabled: boolean;
  94156. /**
  94157. * Are specular textures enabled in the application.
  94158. */
  94159. static SpecularTextureEnabled: boolean;
  94160. /**
  94161. * Are bump textures enabled in the application.
  94162. */
  94163. static BumpTextureEnabled: boolean;
  94164. /**
  94165. * Are lightmap textures enabled in the application.
  94166. */
  94167. static LightmapTextureEnabled: boolean;
  94168. /**
  94169. * Are refraction textures enabled in the application.
  94170. */
  94171. static RefractionTextureEnabled: boolean;
  94172. /**
  94173. * Are color grading textures enabled in the application.
  94174. */
  94175. static ColorGradingTextureEnabled: boolean;
  94176. /**
  94177. * Are fresnels enabled in the application.
  94178. */
  94179. static FresnelEnabled: boolean;
  94180. }
  94181. }
  94182. declare module BABYLON {
  94183. /**
  94184. * A class extending Texture allowing drawing on a texture
  94185. * @see http://doc.babylonjs.com/how_to/dynamictexture
  94186. */
  94187. export class DynamicTexture extends Texture {
  94188. private _generateMipMaps;
  94189. private _canvas;
  94190. private _context;
  94191. private _engine;
  94192. /**
  94193. * Creates a DynamicTexture
  94194. * @param name defines the name of the texture
  94195. * @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
  94196. * @param scene defines the scene where you want the texture
  94197. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  94198. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  94199. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  94200. */
  94201. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  94202. /**
  94203. * Get the current class name of the texture useful for serialization or dynamic coding.
  94204. * @returns "DynamicTexture"
  94205. */
  94206. getClassName(): string;
  94207. /**
  94208. * Gets the current state of canRescale
  94209. */
  94210. readonly canRescale: boolean;
  94211. private _recreate;
  94212. /**
  94213. * Scales the texture
  94214. * @param ratio the scale factor to apply to both width and height
  94215. */
  94216. scale(ratio: number): void;
  94217. /**
  94218. * Resizes the texture
  94219. * @param width the new width
  94220. * @param height the new height
  94221. */
  94222. scaleTo(width: number, height: number): void;
  94223. /**
  94224. * Gets the context of the canvas used by the texture
  94225. * @returns the canvas context of the dynamic texture
  94226. */
  94227. getContext(): CanvasRenderingContext2D;
  94228. /**
  94229. * Clears the texture
  94230. */
  94231. clear(): void;
  94232. /**
  94233. * Updates the texture
  94234. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94235. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  94236. */
  94237. update(invertY?: boolean, premulAlpha?: boolean): void;
  94238. /**
  94239. * Draws text onto the texture
  94240. * @param text defines the text to be drawn
  94241. * @param x defines the placement of the text from the left
  94242. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  94243. * @param font defines the font to be used with font-style, font-size, font-name
  94244. * @param color defines the color used for the text
  94245. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  94246. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  94247. * @param update defines whether texture is immediately update (default is true)
  94248. */
  94249. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  94250. /**
  94251. * Clones the texture
  94252. * @returns the clone of the texture.
  94253. */
  94254. clone(): DynamicTexture;
  94255. /**
  94256. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  94257. * @returns a serialized dynamic texture object
  94258. */
  94259. serialize(): any;
  94260. /** @hidden */
  94261. _rebuild(): void;
  94262. }
  94263. }
  94264. declare module BABYLON {
  94265. /** @hidden */
  94266. export var imageProcessingPixelShader: {
  94267. name: string;
  94268. shader: string;
  94269. };
  94270. }
  94271. declare module BABYLON {
  94272. /**
  94273. * ImageProcessingPostProcess
  94274. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  94275. */
  94276. export class ImageProcessingPostProcess extends PostProcess {
  94277. /**
  94278. * Default configuration related to image processing available in the PBR Material.
  94279. */
  94280. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94281. /**
  94282. * Gets the image processing configuration used either in this material.
  94283. */
  94284. /**
  94285. * Sets the Default image processing configuration used either in the this material.
  94286. *
  94287. * If sets to null, the scene one is in use.
  94288. */
  94289. imageProcessingConfiguration: ImageProcessingConfiguration;
  94290. /**
  94291. * Keep track of the image processing observer to allow dispose and replace.
  94292. */
  94293. private _imageProcessingObserver;
  94294. /**
  94295. * Attaches a new image processing configuration to the PBR Material.
  94296. * @param configuration
  94297. */
  94298. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  94299. /**
  94300. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94301. */
  94302. /**
  94303. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  94304. */
  94305. colorCurves: Nullable<ColorCurves>;
  94306. /**
  94307. * Gets wether the color curves effect is enabled.
  94308. */
  94309. /**
  94310. * Sets wether the color curves effect is enabled.
  94311. */
  94312. colorCurvesEnabled: boolean;
  94313. /**
  94314. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94315. */
  94316. /**
  94317. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  94318. */
  94319. colorGradingTexture: Nullable<BaseTexture>;
  94320. /**
  94321. * Gets wether the color grading effect is enabled.
  94322. */
  94323. /**
  94324. * Gets wether the color grading effect is enabled.
  94325. */
  94326. colorGradingEnabled: boolean;
  94327. /**
  94328. * Gets exposure used in the effect.
  94329. */
  94330. /**
  94331. * Sets exposure used in the effect.
  94332. */
  94333. exposure: number;
  94334. /**
  94335. * Gets wether tonemapping is enabled or not.
  94336. */
  94337. /**
  94338. * Sets wether tonemapping is enabled or not
  94339. */
  94340. toneMappingEnabled: boolean;
  94341. /**
  94342. * Gets contrast used in the effect.
  94343. */
  94344. /**
  94345. * Sets contrast used in the effect.
  94346. */
  94347. contrast: number;
  94348. /**
  94349. * Gets Vignette stretch size.
  94350. */
  94351. /**
  94352. * Sets Vignette stretch size.
  94353. */
  94354. vignetteStretch: number;
  94355. /**
  94356. * Gets Vignette centre X Offset.
  94357. */
  94358. /**
  94359. * Sets Vignette centre X Offset.
  94360. */
  94361. vignetteCentreX: number;
  94362. /**
  94363. * Gets Vignette centre Y Offset.
  94364. */
  94365. /**
  94366. * Sets Vignette centre Y Offset.
  94367. */
  94368. vignetteCentreY: number;
  94369. /**
  94370. * Gets Vignette weight or intensity of the vignette effect.
  94371. */
  94372. /**
  94373. * Sets Vignette weight or intensity of the vignette effect.
  94374. */
  94375. vignetteWeight: number;
  94376. /**
  94377. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94378. * if vignetteEnabled is set to true.
  94379. */
  94380. /**
  94381. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  94382. * if vignetteEnabled is set to true.
  94383. */
  94384. vignetteColor: Color4;
  94385. /**
  94386. * Gets Camera field of view used by the Vignette effect.
  94387. */
  94388. /**
  94389. * Sets Camera field of view used by the Vignette effect.
  94390. */
  94391. vignetteCameraFov: number;
  94392. /**
  94393. * Gets the vignette blend mode allowing different kind of effect.
  94394. */
  94395. /**
  94396. * Sets the vignette blend mode allowing different kind of effect.
  94397. */
  94398. vignetteBlendMode: number;
  94399. /**
  94400. * Gets wether the vignette effect is enabled.
  94401. */
  94402. /**
  94403. * Sets wether the vignette effect is enabled.
  94404. */
  94405. vignetteEnabled: boolean;
  94406. private _fromLinearSpace;
  94407. /**
  94408. * Gets wether the input of the processing is in Gamma or Linear Space.
  94409. */
  94410. /**
  94411. * Sets wether the input of the processing is in Gamma or Linear Space.
  94412. */
  94413. fromLinearSpace: boolean;
  94414. /**
  94415. * Defines cache preventing GC.
  94416. */
  94417. private _defines;
  94418. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  94419. /**
  94420. * "ImageProcessingPostProcess"
  94421. * @returns "ImageProcessingPostProcess"
  94422. */
  94423. getClassName(): string;
  94424. protected _updateParameters(): void;
  94425. dispose(camera?: Camera): void;
  94426. }
  94427. }
  94428. declare module BABYLON {
  94429. /**
  94430. * Class containing static functions to help procedurally build meshes
  94431. */
  94432. export class GroundBuilder {
  94433. /**
  94434. * Creates a ground mesh
  94435. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  94436. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  94437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94438. * @param name defines the name of the mesh
  94439. * @param options defines the options used to create the mesh
  94440. * @param scene defines the hosting scene
  94441. * @returns the ground mesh
  94442. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  94443. */
  94444. static CreateGround(name: string, options: {
  94445. width?: number;
  94446. height?: number;
  94447. subdivisions?: number;
  94448. subdivisionsX?: number;
  94449. subdivisionsY?: number;
  94450. updatable?: boolean;
  94451. }, scene: any): Mesh;
  94452. /**
  94453. * Creates a tiled ground mesh
  94454. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  94455. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  94456. * * 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
  94457. * * 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
  94458. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94459. * @param name defines the name of the mesh
  94460. * @param options defines the options used to create the mesh
  94461. * @param scene defines the hosting scene
  94462. * @returns the tiled ground mesh
  94463. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  94464. */
  94465. static CreateTiledGround(name: string, options: {
  94466. xmin: number;
  94467. zmin: number;
  94468. xmax: number;
  94469. zmax: number;
  94470. subdivisions?: {
  94471. w: number;
  94472. h: number;
  94473. };
  94474. precision?: {
  94475. w: number;
  94476. h: number;
  94477. };
  94478. updatable?: boolean;
  94479. }, scene: Scene): Mesh;
  94480. /**
  94481. * Creates a ground mesh from a height map
  94482. * * The parameter `url` sets the URL of the height map image resource.
  94483. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  94484. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  94485. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  94486. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  94487. * * 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.
  94488. * * 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).
  94489. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  94490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94491. * @param name defines the name of the mesh
  94492. * @param url defines the url to the height map
  94493. * @param options defines the options used to create the mesh
  94494. * @param scene defines the hosting scene
  94495. * @returns the ground mesh
  94496. * @see https://doc.babylonjs.com/babylon101/height_map
  94497. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  94498. */
  94499. static CreateGroundFromHeightMap(name: string, url: string, options: {
  94500. width?: number;
  94501. height?: number;
  94502. subdivisions?: number;
  94503. minHeight?: number;
  94504. maxHeight?: number;
  94505. colorFilter?: Color3;
  94506. alphaFilter?: number;
  94507. updatable?: boolean;
  94508. onReady?: (mesh: GroundMesh) => void;
  94509. }, scene: Scene): GroundMesh;
  94510. }
  94511. }
  94512. declare module BABYLON {
  94513. /**
  94514. * Class containing static functions to help procedurally build meshes
  94515. */
  94516. export class TorusBuilder {
  94517. /**
  94518. * Creates a torus mesh
  94519. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  94520. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  94521. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  94522. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94523. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94524. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94525. * @param name defines the name of the mesh
  94526. * @param options defines the options used to create the mesh
  94527. * @param scene defines the hosting scene
  94528. * @returns the torus mesh
  94529. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  94530. */
  94531. static CreateTorus(name: string, options: {
  94532. diameter?: number;
  94533. thickness?: number;
  94534. tessellation?: number;
  94535. updatable?: boolean;
  94536. sideOrientation?: number;
  94537. frontUVs?: Vector4;
  94538. backUVs?: Vector4;
  94539. }, scene: any): Mesh;
  94540. }
  94541. }
  94542. declare module BABYLON {
  94543. /**
  94544. * Class containing static functions to help procedurally build meshes
  94545. */
  94546. export class CylinderBuilder {
  94547. /**
  94548. * Creates a cylinder or a cone mesh
  94549. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  94550. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  94551. * * 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.
  94552. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  94553. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  94554. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  94555. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  94556. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  94557. * * 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).
  94558. * * 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
  94559. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  94560. * * 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
  94561. * * 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.
  94562. * * If `enclose` is false, a ring surface is one element.
  94563. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  94564. * * 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
  94565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94566. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94567. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  94568. * @param name defines the name of the mesh
  94569. * @param options defines the options used to create the mesh
  94570. * @param scene defines the hosting scene
  94571. * @returns the cylinder mesh
  94572. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  94573. */
  94574. static CreateCylinder(name: string, options: {
  94575. height?: number;
  94576. diameterTop?: number;
  94577. diameterBottom?: number;
  94578. diameter?: number;
  94579. tessellation?: number;
  94580. subdivisions?: number;
  94581. arc?: number;
  94582. faceColors?: Color4[];
  94583. faceUV?: Vector4[];
  94584. updatable?: boolean;
  94585. hasRings?: boolean;
  94586. enclose?: boolean;
  94587. sideOrientation?: number;
  94588. frontUVs?: Vector4;
  94589. backUVs?: Vector4;
  94590. }, scene: any): Mesh;
  94591. }
  94592. }
  94593. declare module BABYLON {
  94594. /**
  94595. * Options to modify the vr teleportation behavior.
  94596. */
  94597. export interface VRTeleportationOptions {
  94598. /**
  94599. * The name of the mesh which should be used as the teleportation floor. (default: null)
  94600. */
  94601. floorMeshName?: string;
  94602. /**
  94603. * A list of meshes to be used as the teleportation floor. (default: empty)
  94604. */
  94605. floorMeshes?: Mesh[];
  94606. }
  94607. /**
  94608. * Options to modify the vr experience helper's behavior.
  94609. */
  94610. export interface VRExperienceHelperOptions extends WebVROptions {
  94611. /**
  94612. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  94613. */
  94614. createDeviceOrientationCamera?: boolean;
  94615. /**
  94616. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  94617. */
  94618. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  94619. /**
  94620. * Uses the main button on the controller to toggle the laser casted. (default: true)
  94621. */
  94622. laserToggle?: boolean;
  94623. /**
  94624. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  94625. */
  94626. floorMeshes?: Mesh[];
  94627. }
  94628. /**
  94629. * Helps to quickly add VR support to an existing scene.
  94630. * See http://doc.babylonjs.com/how_to/webvr_helper
  94631. */
  94632. export class VRExperienceHelper {
  94633. /** Options to modify the vr experience helper's behavior. */
  94634. webVROptions: VRExperienceHelperOptions;
  94635. private _scene;
  94636. private _position;
  94637. private _btnVR;
  94638. private _btnVRDisplayed;
  94639. private _webVRsupported;
  94640. private _webVRready;
  94641. private _webVRrequesting;
  94642. private _webVRpresenting;
  94643. private _hasEnteredVR;
  94644. private _fullscreenVRpresenting;
  94645. private _canvas;
  94646. private _webVRCamera;
  94647. private _vrDeviceOrientationCamera;
  94648. private _deviceOrientationCamera;
  94649. private _existingCamera;
  94650. private _onKeyDown;
  94651. private _onVrDisplayPresentChange;
  94652. private _onVRDisplayChanged;
  94653. private _onVRRequestPresentStart;
  94654. private _onVRRequestPresentComplete;
  94655. /**
  94656. * Observable raised when entering VR.
  94657. */
  94658. onEnteringVRObservable: Observable<VRExperienceHelper>;
  94659. /**
  94660. * Observable raised when exiting VR.
  94661. */
  94662. onExitingVRObservable: Observable<VRExperienceHelper>;
  94663. /**
  94664. * Observable raised when controller mesh is loaded.
  94665. */
  94666. onControllerMeshLoadedObservable: Observable<WebVRController>;
  94667. /** Return this.onEnteringVRObservable
  94668. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  94669. */
  94670. readonly onEnteringVR: Observable<VRExperienceHelper>;
  94671. /** Return this.onExitingVRObservable
  94672. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  94673. */
  94674. readonly onExitingVR: Observable<VRExperienceHelper>;
  94675. /** Return this.onControllerMeshLoadedObservable
  94676. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  94677. */
  94678. readonly onControllerMeshLoaded: Observable<WebVRController>;
  94679. private _rayLength;
  94680. private _useCustomVRButton;
  94681. private _teleportationRequested;
  94682. private _teleportActive;
  94683. private _floorMeshName;
  94684. private _floorMeshesCollection;
  94685. private _rotationAllowed;
  94686. private _teleportBackwardsVector;
  94687. private _teleportationTarget;
  94688. private _isDefaultTeleportationTarget;
  94689. private _postProcessMove;
  94690. private _teleportationFillColor;
  94691. private _teleportationBorderColor;
  94692. private _rotationAngle;
  94693. private _haloCenter;
  94694. private _cameraGazer;
  94695. private _padSensibilityUp;
  94696. private _padSensibilityDown;
  94697. private _leftController;
  94698. private _rightController;
  94699. /**
  94700. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  94701. */
  94702. onNewMeshSelected: Observable<AbstractMesh>;
  94703. /**
  94704. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  94705. */
  94706. onNewMeshPicked: Observable<PickingInfo>;
  94707. private _circleEase;
  94708. /**
  94709. * Observable raised before camera teleportation
  94710. */
  94711. onBeforeCameraTeleport: Observable<Vector3>;
  94712. /**
  94713. * Observable raised after camera teleportation
  94714. */
  94715. onAfterCameraTeleport: Observable<Vector3>;
  94716. /**
  94717. * Observable raised when current selected mesh gets unselected
  94718. */
  94719. onSelectedMeshUnselected: Observable<AbstractMesh>;
  94720. private _raySelectionPredicate;
  94721. /**
  94722. * To be optionaly changed by user to define custom ray selection
  94723. */
  94724. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  94725. /**
  94726. * To be optionaly changed by user to define custom selection logic (after ray selection)
  94727. */
  94728. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  94729. /**
  94730. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  94731. */
  94732. teleportationEnabled: boolean;
  94733. private _defaultHeight;
  94734. private _teleportationInitialized;
  94735. private _interactionsEnabled;
  94736. private _interactionsRequested;
  94737. private _displayGaze;
  94738. private _displayLaserPointer;
  94739. /**
  94740. * The mesh used to display where the user is going to teleport.
  94741. */
  94742. /**
  94743. * Sets the mesh to be used to display where the user is going to teleport.
  94744. */
  94745. teleportationTarget: Mesh;
  94746. /**
  94747. * 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
  94748. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  94749. * See http://doc.babylonjs.com/resources/baking_transformations
  94750. */
  94751. gazeTrackerMesh: Mesh;
  94752. /**
  94753. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  94754. */
  94755. updateGazeTrackerScale: boolean;
  94756. /**
  94757. * If the gaze trackers color should be updated when selecting meshes
  94758. */
  94759. updateGazeTrackerColor: boolean;
  94760. /**
  94761. * The gaze tracking mesh corresponding to the left controller
  94762. */
  94763. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  94764. /**
  94765. * The gaze tracking mesh corresponding to the right controller
  94766. */
  94767. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  94768. /**
  94769. * If the ray of the gaze should be displayed.
  94770. */
  94771. /**
  94772. * Sets if the ray of the gaze should be displayed.
  94773. */
  94774. displayGaze: boolean;
  94775. /**
  94776. * If the ray of the LaserPointer should be displayed.
  94777. */
  94778. /**
  94779. * Sets if the ray of the LaserPointer should be displayed.
  94780. */
  94781. displayLaserPointer: boolean;
  94782. /**
  94783. * The deviceOrientationCamera used as the camera when not in VR.
  94784. */
  94785. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  94786. /**
  94787. * Based on the current WebVR support, returns the current VR camera used.
  94788. */
  94789. readonly currentVRCamera: Nullable<Camera>;
  94790. /**
  94791. * The webVRCamera which is used when in VR.
  94792. */
  94793. readonly webVRCamera: WebVRFreeCamera;
  94794. /**
  94795. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  94796. */
  94797. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  94798. private readonly _teleportationRequestInitiated;
  94799. /**
  94800. * Instantiates a VRExperienceHelper.
  94801. * Helps to quickly add VR support to an existing scene.
  94802. * @param scene The scene the VRExperienceHelper belongs to.
  94803. * @param webVROptions Options to modify the vr experience helper's behavior.
  94804. */
  94805. constructor(scene: Scene,
  94806. /** Options to modify the vr experience helper's behavior. */
  94807. webVROptions?: VRExperienceHelperOptions);
  94808. private _onDefaultMeshLoaded;
  94809. private _onResize;
  94810. private _onFullscreenChange;
  94811. /**
  94812. * Gets a value indicating if we are currently in VR mode.
  94813. */
  94814. readonly isInVRMode: boolean;
  94815. private onVrDisplayPresentChange;
  94816. private onVRDisplayChanged;
  94817. private moveButtonToBottomRight;
  94818. private displayVRButton;
  94819. private updateButtonVisibility;
  94820. private _cachedAngularSensibility;
  94821. /**
  94822. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  94823. * Otherwise, will use the fullscreen API.
  94824. */
  94825. enterVR(): void;
  94826. /**
  94827. * Attempt to exit VR, or fullscreen.
  94828. */
  94829. exitVR(): void;
  94830. /**
  94831. * The position of the vr experience helper.
  94832. */
  94833. /**
  94834. * Sets the position of the vr experience helper.
  94835. */
  94836. position: Vector3;
  94837. /**
  94838. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  94839. */
  94840. enableInteractions(): void;
  94841. private readonly _noControllerIsActive;
  94842. private beforeRender;
  94843. private _isTeleportationFloor;
  94844. /**
  94845. * Adds a floor mesh to be used for teleportation.
  94846. * @param floorMesh the mesh to be used for teleportation.
  94847. */
  94848. addFloorMesh(floorMesh: Mesh): void;
  94849. /**
  94850. * Removes a floor mesh from being used for teleportation.
  94851. * @param floorMesh the mesh to be removed.
  94852. */
  94853. removeFloorMesh(floorMesh: Mesh): void;
  94854. /**
  94855. * Enables interactions and teleportation using the VR controllers and gaze.
  94856. * @param vrTeleportationOptions options to modify teleportation behavior.
  94857. */
  94858. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  94859. private _onNewGamepadConnected;
  94860. private _tryEnableInteractionOnController;
  94861. private _onNewGamepadDisconnected;
  94862. private _enableInteractionOnController;
  94863. private _checkTeleportWithRay;
  94864. private _checkRotate;
  94865. private _checkTeleportBackwards;
  94866. private _enableTeleportationOnController;
  94867. private _createTeleportationCircles;
  94868. private _displayTeleportationTarget;
  94869. private _hideTeleportationTarget;
  94870. private _rotateCamera;
  94871. private _moveTeleportationSelectorTo;
  94872. private _workingVector;
  94873. private _workingQuaternion;
  94874. private _workingMatrix;
  94875. /**
  94876. * Teleports the users feet to the desired location
  94877. * @param location The location where the user's feet should be placed
  94878. */
  94879. teleportCamera(location: Vector3): void;
  94880. private _convertNormalToDirectionOfRay;
  94881. private _castRayAndSelectObject;
  94882. private _notifySelectedMeshUnselected;
  94883. /**
  94884. * Sets the color of the laser ray from the vr controllers.
  94885. * @param color new color for the ray.
  94886. */
  94887. changeLaserColor(color: Color3): void;
  94888. /**
  94889. * Sets the color of the ray from the vr headsets gaze.
  94890. * @param color new color for the ray.
  94891. */
  94892. changeGazeColor(color: Color3): void;
  94893. /**
  94894. * Exits VR and disposes of the vr experience helper
  94895. */
  94896. dispose(): void;
  94897. /**
  94898. * Gets the name of the VRExperienceHelper class
  94899. * @returns "VRExperienceHelper"
  94900. */
  94901. getClassName(): string;
  94902. }
  94903. }
  94904. declare module BABYLON {
  94905. /**
  94906. * Manages an XRSession
  94907. * @see https://doc.babylonjs.com/how_to/webxr
  94908. */
  94909. export class WebXRSessionManager implements IDisposable {
  94910. private scene;
  94911. /**
  94912. * Fires every time a new xrFrame arrives which can be used to update the camera
  94913. */
  94914. onXRFrameObservable: Observable<any>;
  94915. /**
  94916. * Fires when the xr session is ended either by the device or manually done
  94917. */
  94918. onXRSessionEnded: Observable<any>;
  94919. /** @hidden */
  94920. _xrSession: XRSession;
  94921. /** @hidden */
  94922. _frameOfReference: XRFrameOfReference;
  94923. /** @hidden */
  94924. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  94925. /** @hidden */
  94926. _currentXRFrame: Nullable<XRFrame>;
  94927. private _xrNavigator;
  94928. private _xrDevice;
  94929. private _tmpMatrix;
  94930. /**
  94931. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  94932. * @param scene The scene which the session should be created for
  94933. */
  94934. constructor(scene: Scene);
  94935. /**
  94936. * Initializes the manager
  94937. * After initialization enterXR can be called to start an XR session
  94938. * @returns Promise which resolves after it is initialized
  94939. */
  94940. initializeAsync(): Promise<void>;
  94941. /**
  94942. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  94943. * @param sessionCreationOptions xr options to create the session with
  94944. * @param frameOfReferenceType option to configure how the xr pose is expressed
  94945. * @returns Promise which resolves after it enters XR
  94946. */
  94947. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  94948. /**
  94949. * Stops the xrSession and restores the renderloop
  94950. * @returns Promise which resolves after it exits XR
  94951. */
  94952. exitXRAsync(): Promise<void>;
  94953. /**
  94954. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  94955. * @param ray ray to cast into the environment
  94956. * @returns Promise which resolves with a collision point in the environment if it exists
  94957. */
  94958. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  94959. /**
  94960. * Checks if a session would be supported for the creation options specified
  94961. * @param options creation options to check if they are supported
  94962. * @returns true if supported
  94963. */
  94964. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  94965. /**
  94966. * @hidden
  94967. * Converts the render layer of xrSession to a render target
  94968. * @param session session to create render target for
  94969. * @param scene scene the new render target should be created for
  94970. */
  94971. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  94972. /**
  94973. * Disposes of the session manager
  94974. */
  94975. dispose(): void;
  94976. }
  94977. }
  94978. declare module BABYLON {
  94979. /**
  94980. * WebXR Camera which holds the views for the xrSession
  94981. * @see https://doc.babylonjs.com/how_to/webxr
  94982. */
  94983. export class WebXRCamera extends FreeCamera {
  94984. private static _TmpMatrix;
  94985. /**
  94986. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  94987. * @param name the name of the camera
  94988. * @param scene the scene to add the camera to
  94989. */
  94990. constructor(name: string, scene: Scene);
  94991. private _updateNumberOfRigCameras;
  94992. /** @hidden */
  94993. _updateForDualEyeDebugging(pupilDistance?: number): void;
  94994. /**
  94995. * Updates the cameras position from the current pose information of the XR session
  94996. * @param xrSessionManager the session containing pose information
  94997. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  94998. */
  94999. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  95000. }
  95001. }
  95002. declare module BABYLON {
  95003. /**
  95004. * States of the webXR experience
  95005. */
  95006. export enum WebXRState {
  95007. /**
  95008. * Transitioning to being in XR mode
  95009. */
  95010. ENTERING_XR = 0,
  95011. /**
  95012. * Transitioning to non XR mode
  95013. */
  95014. EXITING_XR = 1,
  95015. /**
  95016. * In XR mode and presenting
  95017. */
  95018. IN_XR = 2,
  95019. /**
  95020. * Not entered XR mode
  95021. */
  95022. NOT_IN_XR = 3
  95023. }
  95024. /**
  95025. * Helper class used to enable XR
  95026. * @see https://doc.babylonjs.com/how_to/webxr
  95027. */
  95028. export class WebXRExperienceHelper implements IDisposable {
  95029. private scene;
  95030. /**
  95031. * 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
  95032. */
  95033. container: AbstractMesh;
  95034. /**
  95035. * Camera used to render xr content
  95036. */
  95037. camera: WebXRCamera;
  95038. /**
  95039. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  95040. */
  95041. state: WebXRState;
  95042. private _setState;
  95043. private static _TmpVector;
  95044. /**
  95045. * Fires when the state of the experience helper has changed
  95046. */
  95047. onStateChangedObservable: Observable<WebXRState>;
  95048. /** @hidden */
  95049. _sessionManager: WebXRSessionManager;
  95050. private _nonVRCamera;
  95051. private _originalSceneAutoClear;
  95052. private _supported;
  95053. /**
  95054. * Creates the experience helper
  95055. * @param scene the scene to attach the experience helper to
  95056. * @returns a promise for the experience helper
  95057. */
  95058. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  95059. /**
  95060. * Creates a WebXRExperienceHelper
  95061. * @param scene The scene the helper should be created in
  95062. */
  95063. private constructor();
  95064. /**
  95065. * Exits XR mode and returns the scene to its original state
  95066. * @returns promise that resolves after xr mode has exited
  95067. */
  95068. exitXRAsync(): Promise<void>;
  95069. /**
  95070. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  95071. * @param sessionCreationOptions options for the XR session
  95072. * @param frameOfReference frame of reference of the XR session
  95073. * @returns promise that resolves after xr mode has entered
  95074. */
  95075. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  95076. /**
  95077. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  95078. * @param ray ray to cast into the environment
  95079. * @returns Promise which resolves with a collision point in the environment if it exists
  95080. */
  95081. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  95082. /**
  95083. * Updates the global position of the camera by moving the camera's container
  95084. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  95085. * @param position The desired global position of the camera
  95086. */
  95087. setPositionOfCameraUsingContainer(position: Vector3): void;
  95088. /**
  95089. * Rotates the xr camera by rotating the camera's container around the camera's position
  95090. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  95091. * @param rotation the desired quaternion rotation to apply to the camera
  95092. */
  95093. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  95094. /**
  95095. * Checks if the creation options are supported by the xr session
  95096. * @param options creation options
  95097. * @returns true if supported
  95098. */
  95099. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  95100. /**
  95101. * Disposes of the experience helper
  95102. */
  95103. dispose(): void;
  95104. }
  95105. }
  95106. declare module BABYLON {
  95107. /**
  95108. * Button which can be used to enter a different mode of XR
  95109. */
  95110. export class WebXREnterExitUIButton {
  95111. /** button element */
  95112. element: HTMLElement;
  95113. /** XR initialization options for the button */
  95114. initializationOptions: XRSessionCreationOptions;
  95115. /**
  95116. * Creates a WebXREnterExitUIButton
  95117. * @param element button element
  95118. * @param initializationOptions XR initialization options for the button
  95119. */
  95120. constructor(
  95121. /** button element */
  95122. element: HTMLElement,
  95123. /** XR initialization options for the button */
  95124. initializationOptions: XRSessionCreationOptions);
  95125. /**
  95126. * Overwritable function which can be used to update the button's visuals when the state changes
  95127. * @param activeButton the current active button in the UI
  95128. */
  95129. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  95130. }
  95131. /**
  95132. * Options to create the webXR UI
  95133. */
  95134. export class WebXREnterExitUIOptions {
  95135. /**
  95136. * Context to enter xr with
  95137. */
  95138. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  95139. /**
  95140. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  95141. */
  95142. customButtons?: Array<WebXREnterExitUIButton>;
  95143. }
  95144. /**
  95145. * UI to allow the user to enter/exit XR mode
  95146. */
  95147. export class WebXREnterExitUI implements IDisposable {
  95148. private scene;
  95149. private _overlay;
  95150. private _buttons;
  95151. private _activeButton;
  95152. /**
  95153. * Fired every time the active button is changed.
  95154. *
  95155. * When xr is entered via a button that launches xr that button will be the callback parameter
  95156. *
  95157. * When exiting xr the callback parameter will be null)
  95158. */
  95159. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  95160. /**
  95161. * Creates UI to allow the user to enter/exit XR mode
  95162. * @param scene the scene to add the ui to
  95163. * @param helper the xr experience helper to enter/exit xr with
  95164. * @param options options to configure the UI
  95165. * @returns the created ui
  95166. */
  95167. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  95168. private constructor();
  95169. private _updateButtons;
  95170. /**
  95171. * Disposes of the object
  95172. */
  95173. dispose(): void;
  95174. }
  95175. }
  95176. declare module BABYLON {
  95177. /**
  95178. * Represents an XR input
  95179. */
  95180. export class WebXRController {
  95181. /**
  95182. * 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
  95183. */
  95184. grip?: AbstractMesh;
  95185. /**
  95186. * Pointer which can be used to select objects or attach a visible laser to
  95187. */
  95188. pointer: AbstractMesh;
  95189. /**
  95190. * Creates the controller
  95191. * @see https://doc.babylonjs.com/how_to/webxr
  95192. * @param scene the scene which the controller should be associated to
  95193. */
  95194. constructor(scene: Scene);
  95195. /**
  95196. * Disposes of the object
  95197. */
  95198. dispose(): void;
  95199. }
  95200. /**
  95201. * XR input used to track XR inputs such as controllers/rays
  95202. */
  95203. export class WebXRInput implements IDisposable {
  95204. private helper;
  95205. /**
  95206. * XR controllers being tracked
  95207. */
  95208. controllers: Array<WebXRController>;
  95209. private _tmpMatrix;
  95210. private _frameObserver;
  95211. /**
  95212. * Initializes the WebXRInput
  95213. * @param helper experience helper which the input should be created for
  95214. */
  95215. constructor(helper: WebXRExperienceHelper);
  95216. /**
  95217. * Disposes of the object
  95218. */
  95219. dispose(): void;
  95220. }
  95221. }
  95222. declare module BABYLON {
  95223. /**
  95224. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  95225. */
  95226. export class WebXRManagedOutputCanvas implements IDisposable {
  95227. private _canvas;
  95228. /**
  95229. * xrpresent context of the canvas which can be used to display/mirror xr content
  95230. */
  95231. canvasContext: Nullable<WebGLRenderingContext>;
  95232. /**
  95233. * Initializes the canvas to be added/removed upon entering/exiting xr
  95234. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  95235. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  95236. */
  95237. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  95238. /**
  95239. * Disposes of the object
  95240. */
  95241. dispose(): void;
  95242. private _setManagedOutputCanvas;
  95243. private _addCanvas;
  95244. private _removeCanvas;
  95245. }
  95246. }
  95247. declare module BABYLON {
  95248. /**
  95249. * Contains an array of blocks representing the octree
  95250. */
  95251. export interface IOctreeContainer<T> {
  95252. /**
  95253. * Blocks within the octree
  95254. */
  95255. blocks: Array<OctreeBlock<T>>;
  95256. }
  95257. /**
  95258. * Class used to store a cell in an octree
  95259. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95260. */
  95261. export class OctreeBlock<T> {
  95262. /**
  95263. * Gets the content of the current block
  95264. */
  95265. entries: T[];
  95266. /**
  95267. * Gets the list of block children
  95268. */
  95269. blocks: Array<OctreeBlock<T>>;
  95270. private _depth;
  95271. private _maxDepth;
  95272. private _capacity;
  95273. private _minPoint;
  95274. private _maxPoint;
  95275. private _boundingVectors;
  95276. private _creationFunc;
  95277. /**
  95278. * Creates a new block
  95279. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  95280. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  95281. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95282. * @param depth defines the current depth of this block in the octree
  95283. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  95284. * @param creationFunc defines a callback to call when an element is added to the block
  95285. */
  95286. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  95287. /**
  95288. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  95289. */
  95290. readonly capacity: number;
  95291. /**
  95292. * Gets the minimum vector (in world space) of the block's bounding box
  95293. */
  95294. readonly minPoint: Vector3;
  95295. /**
  95296. * Gets the maximum vector (in world space) of the block's bounding box
  95297. */
  95298. readonly maxPoint: Vector3;
  95299. /**
  95300. * Add a new element to this block
  95301. * @param entry defines the element to add
  95302. */
  95303. addEntry(entry: T): void;
  95304. /**
  95305. * Remove an element from this block
  95306. * @param entry defines the element to remove
  95307. */
  95308. removeEntry(entry: T): void;
  95309. /**
  95310. * Add an array of elements to this block
  95311. * @param entries defines the array of elements to add
  95312. */
  95313. addEntries(entries: T[]): void;
  95314. /**
  95315. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  95316. * @param frustumPlanes defines the frustum planes to test
  95317. * @param selection defines the array to store current content if selection is positive
  95318. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95319. */
  95320. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95321. /**
  95322. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  95323. * @param sphereCenter defines the bounding sphere center
  95324. * @param sphereRadius defines the bounding sphere radius
  95325. * @param selection defines the array to store current content if selection is positive
  95326. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95327. */
  95328. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  95329. /**
  95330. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  95331. * @param ray defines the ray to test with
  95332. * @param selection defines the array to store current content if selection is positive
  95333. */
  95334. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  95335. /**
  95336. * Subdivide the content into child blocks (this block will then be empty)
  95337. */
  95338. createInnerBlocks(): void;
  95339. /**
  95340. * @hidden
  95341. */
  95342. 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;
  95343. }
  95344. }
  95345. declare module BABYLON {
  95346. /**
  95347. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  95348. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95349. */
  95350. export class Octree<T> {
  95351. /** 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.) */
  95352. maxDepth: number;
  95353. /**
  95354. * Blocks within the octree containing objects
  95355. */
  95356. blocks: Array<OctreeBlock<T>>;
  95357. /**
  95358. * Content stored in the octree
  95359. */
  95360. dynamicContent: T[];
  95361. private _maxBlockCapacity;
  95362. private _selectionContent;
  95363. private _creationFunc;
  95364. /**
  95365. * Creates a octree
  95366. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95367. * @param creationFunc function to be used to instatiate the octree
  95368. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  95369. * @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.)
  95370. */
  95371. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  95372. /** 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.) */
  95373. maxDepth?: number);
  95374. /**
  95375. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  95376. * @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);
  95377. * @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);
  95378. * @param entries meshes to be added to the octree blocks
  95379. */
  95380. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  95381. /**
  95382. * Adds a mesh to the octree
  95383. * @param entry Mesh to add to the octree
  95384. */
  95385. addMesh(entry: T): void;
  95386. /**
  95387. * Remove an element from the octree
  95388. * @param entry defines the element to remove
  95389. */
  95390. removeMesh(entry: T): void;
  95391. /**
  95392. * Selects an array of meshes within the frustum
  95393. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  95394. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  95395. * @returns array of meshes within the frustum
  95396. */
  95397. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  95398. /**
  95399. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  95400. * @param sphereCenter defines the bounding sphere center
  95401. * @param sphereRadius defines the bounding sphere radius
  95402. * @param allowDuplicate defines if the selection array can contains duplicated entries
  95403. * @returns an array of objects that intersect the sphere
  95404. */
  95405. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  95406. /**
  95407. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  95408. * @param ray defines the ray to test with
  95409. * @returns array of intersected objects
  95410. */
  95411. intersectsRay(ray: Ray): SmartArray<T>;
  95412. /**
  95413. * Adds a mesh into the octree block if it intersects the block
  95414. */
  95415. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  95416. /**
  95417. * Adds a submesh into the octree block if it intersects the block
  95418. */
  95419. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  95420. }
  95421. }
  95422. declare module BABYLON {
  95423. interface Scene {
  95424. /**
  95425. * @hidden
  95426. * Backing Filed
  95427. */
  95428. _selectionOctree: Octree<AbstractMesh>;
  95429. /**
  95430. * Gets the octree used to boost mesh selection (picking)
  95431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95432. */
  95433. selectionOctree: Octree<AbstractMesh>;
  95434. /**
  95435. * Creates or updates the octree used to boost selection (picking)
  95436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95437. * @param maxCapacity defines the maximum capacity per leaf
  95438. * @param maxDepth defines the maximum depth of the octree
  95439. * @returns an octree of AbstractMesh
  95440. */
  95441. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  95442. }
  95443. interface AbstractMesh {
  95444. /**
  95445. * @hidden
  95446. * Backing Field
  95447. */
  95448. _submeshesOctree: Octree<SubMesh>;
  95449. /**
  95450. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  95451. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  95452. * @param maxCapacity defines the maximum size of each block (64 by default)
  95453. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  95454. * @returns the new octree
  95455. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  95456. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  95457. */
  95458. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  95459. }
  95460. /**
  95461. * Defines the octree scene component responsible to manage any octrees
  95462. * in a given scene.
  95463. */
  95464. export class OctreeSceneComponent {
  95465. /**
  95466. * The component name helpfull to identify the component in the list of scene components.
  95467. */
  95468. readonly name: string;
  95469. /**
  95470. * The scene the component belongs to.
  95471. */
  95472. scene: Scene;
  95473. /**
  95474. * Indicates if the meshes have been checked to make sure they are isEnabled()
  95475. */
  95476. readonly checksIsEnabled: boolean;
  95477. /**
  95478. * Creates a new instance of the component for the given scene
  95479. * @param scene Defines the scene to register the component in
  95480. */
  95481. constructor(scene: Scene);
  95482. /**
  95483. * Registers the component in a given scene
  95484. */
  95485. register(): void;
  95486. /**
  95487. * Return the list of active meshes
  95488. * @returns the list of active meshes
  95489. */
  95490. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95491. /**
  95492. * Return the list of active sub meshes
  95493. * @param mesh The mesh to get the candidates sub meshes from
  95494. * @returns the list of active sub meshes
  95495. */
  95496. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95497. private _tempRay;
  95498. /**
  95499. * Return the list of sub meshes intersecting with a given local ray
  95500. * @param mesh defines the mesh to find the submesh for
  95501. * @param localRay defines the ray in local space
  95502. * @returns the list of intersecting sub meshes
  95503. */
  95504. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  95505. /**
  95506. * Return the list of sub meshes colliding with a collider
  95507. * @param mesh defines the mesh to find the submesh for
  95508. * @param collider defines the collider to evaluate the collision against
  95509. * @returns the list of colliding sub meshes
  95510. */
  95511. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  95512. /**
  95513. * Rebuilds the elements related to this component in case of
  95514. * context lost for instance.
  95515. */
  95516. rebuild(): void;
  95517. /**
  95518. * Disposes the component and the associated ressources.
  95519. */
  95520. dispose(): void;
  95521. }
  95522. }
  95523. declare module BABYLON {
  95524. /**
  95525. * Class containing static functions to help procedurally build meshes
  95526. */
  95527. export class LinesBuilder {
  95528. /**
  95529. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  95530. * * 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
  95531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  95532. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  95533. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  95534. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  95535. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  95536. * * 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
  95537. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  95538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95539. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  95540. * @param name defines the name of the new line system
  95541. * @param options defines the options used to create the line system
  95542. * @param scene defines the hosting scene
  95543. * @returns a new line system mesh
  95544. */
  95545. static CreateLineSystem(name: string, options: {
  95546. lines: Vector3[][];
  95547. updatable?: boolean;
  95548. instance?: Nullable<LinesMesh>;
  95549. colors?: Nullable<Color4[][]>;
  95550. useVertexAlpha?: boolean;
  95551. }, scene: Nullable<Scene>): LinesMesh;
  95552. /**
  95553. * Creates a line mesh
  95554. * 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
  95555. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95556. * * The parameter `points` is an array successive Vector3
  95557. * * 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
  95558. * * The optional parameter `colors` is an array of successive Color4, one per line point
  95559. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  95560. * * When updating an instance, remember that only point positions can change, not the number of points
  95561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95562. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  95563. * @param name defines the name of the new line system
  95564. * @param options defines the options used to create the line system
  95565. * @param scene defines the hosting scene
  95566. * @returns a new line mesh
  95567. */
  95568. static CreateLines(name: string, options: {
  95569. points: Vector3[];
  95570. updatable?: boolean;
  95571. instance?: Nullable<LinesMesh>;
  95572. colors?: Color4[];
  95573. useVertexAlpha?: boolean;
  95574. }, scene?: Nullable<Scene>): LinesMesh;
  95575. /**
  95576. * Creates a dashed line mesh
  95577. * * 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
  95578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  95579. * * The parameter `points` is an array successive Vector3
  95580. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  95581. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  95582. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  95583. * * 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
  95584. * * When updating an instance, remember that only point positions can change, not the number of points
  95585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95586. * @param name defines the name of the mesh
  95587. * @param options defines the options used to create the mesh
  95588. * @param scene defines the hosting scene
  95589. * @returns the dashed line mesh
  95590. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  95591. */
  95592. static CreateDashedLines(name: string, options: {
  95593. points: Vector3[];
  95594. dashSize?: number;
  95595. gapSize?: number;
  95596. dashNb?: number;
  95597. updatable?: boolean;
  95598. instance?: LinesMesh;
  95599. }, scene?: Nullable<Scene>): LinesMesh;
  95600. }
  95601. }
  95602. declare module BABYLON {
  95603. /**
  95604. * Renders a layer on top of an existing scene
  95605. */
  95606. export class UtilityLayerRenderer implements IDisposable {
  95607. /** the original scene that will be rendered on top of */
  95608. originalScene: Scene;
  95609. private _pointerCaptures;
  95610. private _lastPointerEvents;
  95611. private static _DefaultUtilityLayer;
  95612. private static _DefaultKeepDepthUtilityLayer;
  95613. /**
  95614. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  95615. */
  95616. pickUtilitySceneFirst: boolean;
  95617. /**
  95618. * 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)
  95619. */
  95620. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  95621. /**
  95622. * 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)
  95623. */
  95624. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  95625. /**
  95626. * The scene that is rendered on top of the original scene
  95627. */
  95628. utilityLayerScene: Scene;
  95629. /**
  95630. * If the utility layer should automatically be rendered on top of existing scene
  95631. */
  95632. shouldRender: boolean;
  95633. /**
  95634. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  95635. */
  95636. onlyCheckPointerDownEvents: boolean;
  95637. /**
  95638. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  95639. */
  95640. processAllEvents: boolean;
  95641. /**
  95642. * Observable raised when the pointer move from the utility layer scene to the main scene
  95643. */
  95644. onPointerOutObservable: Observable<number>;
  95645. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  95646. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  95647. private _afterRenderObserver;
  95648. private _sceneDisposeObserver;
  95649. private _originalPointerObserver;
  95650. /**
  95651. * Instantiates a UtilityLayerRenderer
  95652. * @param originalScene the original scene that will be rendered on top of
  95653. * @param handleEvents boolean indicating if the utility layer should handle events
  95654. */
  95655. constructor(
  95656. /** the original scene that will be rendered on top of */
  95657. originalScene: Scene, handleEvents?: boolean);
  95658. private _notifyObservers;
  95659. /**
  95660. * Renders the utility layers scene on top of the original scene
  95661. */
  95662. render(): void;
  95663. /**
  95664. * Disposes of the renderer
  95665. */
  95666. dispose(): void;
  95667. private _updateCamera;
  95668. }
  95669. }
  95670. declare module BABYLON {
  95671. /**
  95672. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  95673. */
  95674. export class Gizmo implements IDisposable {
  95675. /** The utility layer the gizmo will be added to */
  95676. gizmoLayer: UtilityLayerRenderer;
  95677. /**
  95678. * The root mesh of the gizmo
  95679. */
  95680. protected _rootMesh: Mesh;
  95681. private _attachedMesh;
  95682. /**
  95683. * Ratio for the scale of the gizmo (Default: 1)
  95684. */
  95685. scaleRatio: number;
  95686. private _tmpMatrix;
  95687. /**
  95688. * If a custom mesh has been set (Default: false)
  95689. */
  95690. protected _customMeshSet: boolean;
  95691. /**
  95692. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  95693. * * When set, interactions will be enabled
  95694. */
  95695. attachedMesh: Nullable<AbstractMesh>;
  95696. /**
  95697. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  95698. * @param mesh The mesh to replace the default mesh of the gizmo
  95699. */
  95700. setCustomMesh(mesh: Mesh): void;
  95701. /**
  95702. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  95703. */
  95704. updateGizmoRotationToMatchAttachedMesh: boolean;
  95705. /**
  95706. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  95707. */
  95708. updateGizmoPositionToMatchAttachedMesh: boolean;
  95709. /**
  95710. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  95711. */
  95712. protected _updateScale: boolean;
  95713. protected _interactionsEnabled: boolean;
  95714. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95715. private _beforeRenderObserver;
  95716. /**
  95717. * Creates a gizmo
  95718. * @param gizmoLayer The utility layer the gizmo will be added to
  95719. */
  95720. constructor(
  95721. /** The utility layer the gizmo will be added to */
  95722. gizmoLayer?: UtilityLayerRenderer);
  95723. private _tempVector;
  95724. /**
  95725. * @hidden
  95726. * Updates the gizmo to match the attached mesh's position/rotation
  95727. */
  95728. protected _update(): void;
  95729. /**
  95730. * Disposes of the gizmo
  95731. */
  95732. dispose(): void;
  95733. }
  95734. }
  95735. declare module BABYLON {
  95736. /**
  95737. * Single axis drag gizmo
  95738. */
  95739. export class AxisDragGizmo extends Gizmo {
  95740. /**
  95741. * Drag behavior responsible for the gizmos dragging interactions
  95742. */
  95743. dragBehavior: PointerDragBehavior;
  95744. private _pointerObserver;
  95745. /**
  95746. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  95747. */
  95748. snapDistance: number;
  95749. /**
  95750. * Event that fires each time the gizmo snaps to a new location.
  95751. * * snapDistance is the the change in distance
  95752. */
  95753. onSnapObservable: Observable<{
  95754. snapDistance: number;
  95755. }>;
  95756. /** @hidden */
  95757. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  95758. /** @hidden */
  95759. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  95760. /**
  95761. * Creates an AxisDragGizmo
  95762. * @param gizmoLayer The utility layer the gizmo will be added to
  95763. * @param dragAxis The axis which the gizmo will be able to drag on
  95764. * @param color The color of the gizmo
  95765. */
  95766. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  95767. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  95768. /**
  95769. * Disposes of the gizmo
  95770. */
  95771. dispose(): void;
  95772. }
  95773. }
  95774. declare module BABYLON.Debug {
  95775. /**
  95776. * The Axes viewer will show 3 axes in a specific point in space
  95777. */
  95778. export class AxesViewer {
  95779. private _xAxis;
  95780. private _yAxis;
  95781. private _zAxis;
  95782. private _scaleLinesFactor;
  95783. private _instanced;
  95784. /**
  95785. * Gets the hosting scene
  95786. */
  95787. scene: Scene;
  95788. /**
  95789. * Gets or sets a number used to scale line length
  95790. */
  95791. scaleLines: number;
  95792. /** Gets the node hierarchy used to render x-axis */
  95793. readonly xAxis: TransformNode;
  95794. /** Gets the node hierarchy used to render y-axis */
  95795. readonly yAxis: TransformNode;
  95796. /** Gets the node hierarchy used to render z-axis */
  95797. readonly zAxis: TransformNode;
  95798. /**
  95799. * Creates a new AxesViewer
  95800. * @param scene defines the hosting scene
  95801. * @param scaleLines defines a number used to scale line length (1 by default)
  95802. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  95803. * @param xAxis defines the node hierarchy used to render the x-axis
  95804. * @param yAxis defines the node hierarchy used to render the y-axis
  95805. * @param zAxis defines the node hierarchy used to render the z-axis
  95806. */
  95807. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  95808. /**
  95809. * Force the viewer to update
  95810. * @param position defines the position of the viewer
  95811. * @param xaxis defines the x axis of the viewer
  95812. * @param yaxis defines the y axis of the viewer
  95813. * @param zaxis defines the z axis of the viewer
  95814. */
  95815. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  95816. /**
  95817. * Creates an instance of this axes viewer.
  95818. * @returns a new axes viewer with instanced meshes
  95819. */
  95820. createInstance(): AxesViewer;
  95821. /** Releases resources */
  95822. dispose(): void;
  95823. private static _SetRenderingGroupId;
  95824. }
  95825. }
  95826. declare module BABYLON.Debug {
  95827. /**
  95828. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  95829. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  95830. */
  95831. export class BoneAxesViewer extends AxesViewer {
  95832. /**
  95833. * Gets or sets the target mesh where to display the axes viewer
  95834. */
  95835. mesh: Nullable<Mesh>;
  95836. /**
  95837. * Gets or sets the target bone where to display the axes viewer
  95838. */
  95839. bone: Nullable<Bone>;
  95840. /** Gets current position */
  95841. pos: Vector3;
  95842. /** Gets direction of X axis */
  95843. xaxis: Vector3;
  95844. /** Gets direction of Y axis */
  95845. yaxis: Vector3;
  95846. /** Gets direction of Z axis */
  95847. zaxis: Vector3;
  95848. /**
  95849. * Creates a new BoneAxesViewer
  95850. * @param scene defines the hosting scene
  95851. * @param bone defines the target bone
  95852. * @param mesh defines the target mesh
  95853. * @param scaleLines defines a scaling factor for line length (1 by default)
  95854. */
  95855. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  95856. /**
  95857. * Force the viewer to update
  95858. */
  95859. update(): void;
  95860. /** Releases resources */
  95861. dispose(): void;
  95862. }
  95863. }
  95864. declare module BABYLON {
  95865. /**
  95866. * Interface used to define scene explorer extensibility option
  95867. */
  95868. export interface IExplorerExtensibilityOption {
  95869. /**
  95870. * Define the option label
  95871. */
  95872. label: string;
  95873. /**
  95874. * Defines the action to execute on click
  95875. */
  95876. action: (entity: any) => void;
  95877. }
  95878. /**
  95879. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  95880. */
  95881. export interface IExplorerExtensibilityGroup {
  95882. /**
  95883. * Defines a predicate to test if a given type mut be extended
  95884. */
  95885. predicate: (entity: any) => boolean;
  95886. /**
  95887. * Gets the list of options added to a type
  95888. */
  95889. entries: IExplorerExtensibilityOption[];
  95890. }
  95891. /**
  95892. * Interface used to define the options to use to create the Inspector
  95893. */
  95894. export interface IInspectorOptions {
  95895. /**
  95896. * Display in overlay mode (default: false)
  95897. */
  95898. overlay?: boolean;
  95899. /**
  95900. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  95901. */
  95902. globalRoot?: HTMLElement;
  95903. /**
  95904. * Display the Scene explorer
  95905. */
  95906. showExplorer?: boolean;
  95907. /**
  95908. * Display the property inspector
  95909. */
  95910. showInspector?: boolean;
  95911. /**
  95912. * Display in embed mode (both panes on the right)
  95913. */
  95914. embedMode?: boolean;
  95915. /**
  95916. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  95917. */
  95918. handleResize?: boolean;
  95919. /**
  95920. * Allow the panes to popup (default: true)
  95921. */
  95922. enablePopup?: boolean;
  95923. /**
  95924. * Allow the panes to be closed by users (default: true)
  95925. */
  95926. enableClose?: boolean;
  95927. /**
  95928. * Optional list of extensibility entries
  95929. */
  95930. explorerExtensibility?: IExplorerExtensibilityGroup[];
  95931. }
  95932. interface Scene {
  95933. /**
  95934. * @hidden
  95935. * Backing field
  95936. */
  95937. _debugLayer: DebugLayer;
  95938. /**
  95939. * Gets the debug layer (aka Inspector) associated with the scene
  95940. * @see http://doc.babylonjs.com/features/playground_debuglayer
  95941. */
  95942. debugLayer: DebugLayer;
  95943. }
  95944. /**
  95945. * The debug layer (aka Inspector) is the go to tool in order to better understand
  95946. * what is happening in your scene
  95947. * @see http://doc.babylonjs.com/features/playground_debuglayer
  95948. */
  95949. export class DebugLayer {
  95950. /**
  95951. * Define the url to get the inspector script from.
  95952. * By default it uses the babylonjs CDN.
  95953. * @ignoreNaming
  95954. */
  95955. static InspectorURL: string;
  95956. private _scene;
  95957. private BJSINSPECTOR;
  95958. /**
  95959. * Observable triggered when a property is changed through the inspector.
  95960. */
  95961. onPropertyChangedObservable: Observable<{
  95962. object: any;
  95963. property: string;
  95964. value: any;
  95965. initialValue: any;
  95966. }>;
  95967. /**
  95968. * Instantiates a new debug layer.
  95969. * The debug layer (aka Inspector) is the go to tool in order to better understand
  95970. * what is happening in your scene
  95971. * @see http://doc.babylonjs.com/features/playground_debuglayer
  95972. * @param scene Defines the scene to inspect
  95973. */
  95974. constructor(scene: Scene);
  95975. /** Creates the inspector window. */
  95976. private _createInspector;
  95977. /** Get the inspector from bundle or global */
  95978. private _getGlobalInspector;
  95979. /**
  95980. * Get if the inspector is visible or not.
  95981. * @returns true if visible otherwise, false
  95982. */
  95983. isVisible(): boolean;
  95984. /**
  95985. * Hide the inspector and close its window.
  95986. */
  95987. hide(): void;
  95988. /**
  95989. * Launch the debugLayer.
  95990. * @param config Define the configuration of the inspector
  95991. */
  95992. show(config?: IInspectorOptions): void;
  95993. }
  95994. }
  95995. declare module BABYLON {
  95996. /**
  95997. * Class containing static functions to help procedurally build meshes
  95998. */
  95999. export class BoxBuilder {
  96000. /**
  96001. * Creates a box mesh
  96002. * * The parameter `size` sets the size (float) of each box side (default 1)
  96003. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  96004. * * 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)
  96005. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  96006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96009. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  96010. * @param name defines the name of the mesh
  96011. * @param options defines the options used to create the mesh
  96012. * @param scene defines the hosting scene
  96013. * @returns the box mesh
  96014. */
  96015. static CreateBox(name: string, options: {
  96016. size?: number;
  96017. width?: number;
  96018. height?: number;
  96019. depth?: number;
  96020. faceUV?: Vector4[];
  96021. faceColors?: Color4[];
  96022. sideOrientation?: number;
  96023. frontUVs?: Vector4;
  96024. backUVs?: Vector4;
  96025. updatable?: boolean;
  96026. }, scene?: Nullable<Scene>): Mesh;
  96027. }
  96028. }
  96029. declare module BABYLON {
  96030. /**
  96031. * Class containing static functions to help procedurally build meshes
  96032. */
  96033. export class SphereBuilder {
  96034. /**
  96035. * Creates a sphere mesh
  96036. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  96037. * * 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`)
  96038. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  96039. * * 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
  96040. * * 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)
  96041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  96042. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  96043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  96044. * @param name defines the name of the mesh
  96045. * @param options defines the options used to create the mesh
  96046. * @param scene defines the hosting scene
  96047. * @returns the sphere mesh
  96048. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  96049. */
  96050. static CreateSphere(name: string, options: {
  96051. segments?: number;
  96052. diameter?: number;
  96053. diameterX?: number;
  96054. diameterY?: number;
  96055. diameterZ?: number;
  96056. arc?: number;
  96057. slice?: number;
  96058. sideOrientation?: number;
  96059. frontUVs?: Vector4;
  96060. backUVs?: Vector4;
  96061. updatable?: boolean;
  96062. }, scene: any): Mesh;
  96063. }
  96064. }
  96065. declare module BABYLON.Debug {
  96066. /**
  96067. * Used to show the physics impostor around the specific mesh
  96068. */
  96069. export class PhysicsViewer {
  96070. /** @hidden */
  96071. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  96072. /** @hidden */
  96073. protected _meshes: Array<Nullable<AbstractMesh>>;
  96074. /** @hidden */
  96075. protected _scene: Nullable<Scene>;
  96076. /** @hidden */
  96077. protected _numMeshes: number;
  96078. /** @hidden */
  96079. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  96080. private _renderFunction;
  96081. private _utilityLayer;
  96082. private _debugBoxMesh;
  96083. private _debugSphereMesh;
  96084. private _debugMaterial;
  96085. /**
  96086. * Creates a new PhysicsViewer
  96087. * @param scene defines the hosting scene
  96088. */
  96089. constructor(scene: Scene);
  96090. /** @hidden */
  96091. protected _updateDebugMeshes(): void;
  96092. /**
  96093. * Renders a specified physic impostor
  96094. * @param impostor defines the impostor to render
  96095. * @returns the new debug mesh used to render the impostor
  96096. */
  96097. showImpostor(impostor: PhysicsImpostor): Nullable<AbstractMesh>;
  96098. /**
  96099. * Hides a specified physic impostor
  96100. * @param impostor defines the impostor to hide
  96101. */
  96102. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  96103. private _getDebugMaterial;
  96104. private _getDebugBoxMesh;
  96105. private _getDebugSphereMesh;
  96106. private _getDebugMesh;
  96107. /** Releases all resources */
  96108. dispose(): void;
  96109. }
  96110. }
  96111. declare module BABYLON {
  96112. /**
  96113. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96114. * in order to better appreciate the issue one might have.
  96115. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96116. */
  96117. export class RayHelper {
  96118. /**
  96119. * Defines the ray we are currently tryin to visualize.
  96120. */
  96121. ray: Nullable<Ray>;
  96122. private _renderPoints;
  96123. private _renderLine;
  96124. private _renderFunction;
  96125. private _scene;
  96126. private _updateToMeshFunction;
  96127. private _attachedToMesh;
  96128. private _meshSpaceDirection;
  96129. private _meshSpaceOrigin;
  96130. /**
  96131. * Helper function to create a colored helper in a scene in one line.
  96132. * @param ray Defines the ray we are currently tryin to visualize
  96133. * @param scene Defines the scene the ray is used in
  96134. * @param color Defines the color we want to see the ray in
  96135. * @returns The newly created ray helper.
  96136. */
  96137. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  96138. /**
  96139. * Instantiate a new ray helper.
  96140. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  96141. * in order to better appreciate the issue one might have.
  96142. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  96143. * @param ray Defines the ray we are currently tryin to visualize
  96144. */
  96145. constructor(ray: Ray);
  96146. /**
  96147. * Shows the ray we are willing to debug.
  96148. * @param scene Defines the scene the ray needs to be rendered in
  96149. * @param color Defines the color the ray needs to be rendered in
  96150. */
  96151. show(scene: Scene, color?: Color3): void;
  96152. /**
  96153. * Hides the ray we are debugging.
  96154. */
  96155. hide(): void;
  96156. private _render;
  96157. /**
  96158. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  96159. * @param mesh Defines the mesh we want the helper attached to
  96160. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  96161. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  96162. * @param length Defines the length of the ray
  96163. */
  96164. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  96165. /**
  96166. * Detach the ray helper from the mesh it has previously been attached to.
  96167. */
  96168. detachFromMesh(): void;
  96169. private _updateToMesh;
  96170. /**
  96171. * Dispose the helper and release its associated resources.
  96172. */
  96173. dispose(): void;
  96174. }
  96175. }
  96176. declare module BABYLON.Debug {
  96177. /**
  96178. * Class used to render a debug view of a given skeleton
  96179. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  96180. */
  96181. export class SkeletonViewer {
  96182. /** defines the skeleton to render */
  96183. skeleton: Skeleton;
  96184. /** defines the mesh attached to the skeleton */
  96185. mesh: AbstractMesh;
  96186. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96187. autoUpdateBonesMatrices: boolean;
  96188. /** defines the rendering group id to use with the viewer */
  96189. renderingGroupId: number;
  96190. /** Gets or sets the color used to render the skeleton */
  96191. color: Color3;
  96192. private _scene;
  96193. private _debugLines;
  96194. private _debugMesh;
  96195. private _isEnabled;
  96196. private _renderFunction;
  96197. private _utilityLayer;
  96198. /**
  96199. * Returns the mesh used to render the bones
  96200. */
  96201. readonly debugMesh: Nullable<LinesMesh>;
  96202. /**
  96203. * Creates a new SkeletonViewer
  96204. * @param skeleton defines the skeleton to render
  96205. * @param mesh defines the mesh attached to the skeleton
  96206. * @param scene defines the hosting scene
  96207. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  96208. * @param renderingGroupId defines the rendering group id to use with the viewer
  96209. */
  96210. constructor(
  96211. /** defines the skeleton to render */
  96212. skeleton: Skeleton,
  96213. /** defines the mesh attached to the skeleton */
  96214. mesh: AbstractMesh, scene: Scene,
  96215. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  96216. autoUpdateBonesMatrices?: boolean,
  96217. /** defines the rendering group id to use with the viewer */
  96218. renderingGroupId?: number);
  96219. /** Gets or sets a boolean indicating if the viewer is enabled */
  96220. isEnabled: boolean;
  96221. private _getBonePosition;
  96222. private _getLinesForBonesWithLength;
  96223. private _getLinesForBonesNoLength;
  96224. /** Update the viewer to sync with current skeleton state */
  96225. update(): void;
  96226. /** Release associated resources */
  96227. dispose(): void;
  96228. }
  96229. }
  96230. declare module BABYLON {
  96231. /**
  96232. * Options to create the null engine
  96233. */
  96234. export class NullEngineOptions {
  96235. /**
  96236. * Render width (Default: 512)
  96237. */
  96238. renderWidth: number;
  96239. /**
  96240. * Render height (Default: 256)
  96241. */
  96242. renderHeight: number;
  96243. /**
  96244. * Texture size (Default: 512)
  96245. */
  96246. textureSize: number;
  96247. /**
  96248. * If delta time between frames should be constant
  96249. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96250. */
  96251. deterministicLockstep: boolean;
  96252. /**
  96253. * Maximum about of steps between frames (Default: 4)
  96254. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96255. */
  96256. lockstepMaxSteps: number;
  96257. }
  96258. /**
  96259. * The null engine class provides support for headless version of babylon.js.
  96260. * This can be used in server side scenario or for testing purposes
  96261. */
  96262. export class NullEngine extends Engine {
  96263. private _options;
  96264. /**
  96265. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  96266. */
  96267. isDeterministicLockStep(): boolean;
  96268. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  96269. getLockstepMaxSteps(): number;
  96270. /**
  96271. * Sets hardware scaling, used to save performance if needed
  96272. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96273. */
  96274. getHardwareScalingLevel(): number;
  96275. constructor(options?: NullEngineOptions);
  96276. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96277. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  96278. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96279. getRenderWidth(useScreen?: boolean): number;
  96280. getRenderHeight(useScreen?: boolean): number;
  96281. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  96282. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  96283. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  96284. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  96285. bindSamplers(effect: Effect): void;
  96286. enableEffect(effect: Effect): void;
  96287. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  96288. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  96289. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  96290. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  96291. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  96292. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  96293. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  96294. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  96295. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  96296. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  96297. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  96298. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  96299. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  96300. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  96301. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  96302. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96303. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  96304. setFloat(uniform: WebGLUniformLocation, value: number): void;
  96305. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  96306. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  96307. setBool(uniform: WebGLUniformLocation, bool: number): void;
  96308. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  96309. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  96310. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  96311. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  96312. bindBuffers(vertexBuffers: {
  96313. [key: string]: VertexBuffer;
  96314. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  96315. wipeCaches(bruteForce?: boolean): void;
  96316. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96317. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96318. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96319. /** @hidden */
  96320. _createTexture(): WebGLTexture;
  96321. /** @hidden */
  96322. _releaseTexture(texture: InternalTexture): void;
  96323. 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;
  96324. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  96325. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96326. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  96327. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96328. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  96329. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  96330. areAllEffectsReady(): boolean;
  96331. /**
  96332. * @hidden
  96333. * Get the current error code of the webGL context
  96334. * @returns the error code
  96335. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96336. */
  96337. getError(): number;
  96338. /** @hidden */
  96339. _getUnpackAlignement(): number;
  96340. /** @hidden */
  96341. _unpackFlipY(value: boolean): void;
  96342. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  96343. /**
  96344. * Updates a dynamic vertex buffer.
  96345. * @param vertexBuffer the vertex buffer to update
  96346. * @param data the data used to update the vertex buffer
  96347. * @param byteOffset the byte offset of the data (optional)
  96348. * @param byteLength the byte length of the data (optional)
  96349. */
  96350. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  96351. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  96352. /** @hidden */
  96353. _bindTexture(channel: number, texture: InternalTexture): void;
  96354. /** @hidden */
  96355. _releaseBuffer(buffer: WebGLBuffer): boolean;
  96356. releaseEffects(): void;
  96357. displayLoadingUI(): void;
  96358. hideLoadingUI(): void;
  96359. /** @hidden */
  96360. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96361. /** @hidden */
  96362. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96363. /** @hidden */
  96364. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96365. /** @hidden */
  96366. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96367. }
  96368. }
  96369. declare module BABYLON {
  96370. /** @hidden */
  96371. export class _OcclusionDataStorage {
  96372. /** @hidden */
  96373. occlusionInternalRetryCounter: number;
  96374. /** @hidden */
  96375. isOcclusionQueryInProgress: boolean;
  96376. /** @hidden */
  96377. isOccluded: boolean;
  96378. /** @hidden */
  96379. occlusionRetryCount: number;
  96380. /** @hidden */
  96381. occlusionType: number;
  96382. /** @hidden */
  96383. occlusionQueryAlgorithmType: number;
  96384. }
  96385. interface Engine {
  96386. /**
  96387. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  96388. * @return the new query
  96389. */
  96390. createQuery(): WebGLQuery;
  96391. /**
  96392. * Delete and release a webGL query
  96393. * @param query defines the query to delete
  96394. * @return the current engine
  96395. */
  96396. deleteQuery(query: WebGLQuery): Engine;
  96397. /**
  96398. * Check if a given query has resolved and got its value
  96399. * @param query defines the query to check
  96400. * @returns true if the query got its value
  96401. */
  96402. isQueryResultAvailable(query: WebGLQuery): boolean;
  96403. /**
  96404. * Gets the value of a given query
  96405. * @param query defines the query to check
  96406. * @returns the value of the query
  96407. */
  96408. getQueryResult(query: WebGLQuery): number;
  96409. /**
  96410. * Initiates an occlusion query
  96411. * @param algorithmType defines the algorithm to use
  96412. * @param query defines the query to use
  96413. * @returns the current engine
  96414. * @see http://doc.babylonjs.com/features/occlusionquery
  96415. */
  96416. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  96417. /**
  96418. * Ends an occlusion query
  96419. * @see http://doc.babylonjs.com/features/occlusionquery
  96420. * @param algorithmType defines the algorithm to use
  96421. * @returns the current engine
  96422. */
  96423. endOcclusionQuery(algorithmType: number): Engine;
  96424. /**
  96425. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  96426. * Please note that only one query can be issued at a time
  96427. * @returns a time token used to track the time span
  96428. */
  96429. startTimeQuery(): Nullable<_TimeToken>;
  96430. /**
  96431. * Ends a time query
  96432. * @param token defines the token used to measure the time span
  96433. * @returns the time spent (in ns)
  96434. */
  96435. endTimeQuery(token: _TimeToken): int;
  96436. /** @hidden */
  96437. _currentNonTimestampToken: Nullable<_TimeToken>;
  96438. /** @hidden */
  96439. _createTimeQuery(): WebGLQuery;
  96440. /** @hidden */
  96441. _deleteTimeQuery(query: WebGLQuery): void;
  96442. /** @hidden */
  96443. _getGlAlgorithmType(algorithmType: number): number;
  96444. /** @hidden */
  96445. _getTimeQueryResult(query: WebGLQuery): any;
  96446. /** @hidden */
  96447. _getTimeQueryAvailability(query: WebGLQuery): any;
  96448. }
  96449. interface AbstractMesh {
  96450. /**
  96451. * Backing filed
  96452. * @hidden
  96453. */
  96454. __occlusionDataStorage: _OcclusionDataStorage;
  96455. /**
  96456. * Access property
  96457. * @hidden
  96458. */
  96459. _occlusionDataStorage: _OcclusionDataStorage;
  96460. /**
  96461. * 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.
  96462. * The default value is -1 which means don't break the query and wait till the result
  96463. * @see http://doc.babylonjs.com/features/occlusionquery
  96464. */
  96465. occlusionRetryCount: number;
  96466. /**
  96467. * 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:
  96468. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  96469. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  96470. * * 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.
  96471. * @see http://doc.babylonjs.com/features/occlusionquery
  96472. */
  96473. occlusionType: number;
  96474. /**
  96475. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  96476. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  96477. * * 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.
  96478. * @see http://doc.babylonjs.com/features/occlusionquery
  96479. */
  96480. occlusionQueryAlgorithmType: number;
  96481. /**
  96482. * 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
  96483. * @see http://doc.babylonjs.com/features/occlusionquery
  96484. */
  96485. isOccluded: boolean;
  96486. /**
  96487. * Flag to check the progress status of the query
  96488. * @see http://doc.babylonjs.com/features/occlusionquery
  96489. */
  96490. isOcclusionQueryInProgress: boolean;
  96491. }
  96492. }
  96493. declare module BABYLON {
  96494. /** @hidden */
  96495. export var _forceTransformFeedbackToBundle: boolean;
  96496. interface Engine {
  96497. /**
  96498. * Creates a webGL transform feedback object
  96499. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  96500. * @returns the webGL transform feedback object
  96501. */
  96502. createTransformFeedback(): WebGLTransformFeedback;
  96503. /**
  96504. * Delete a webGL transform feedback object
  96505. * @param value defines the webGL transform feedback object to delete
  96506. */
  96507. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  96508. /**
  96509. * Bind a webGL transform feedback object to the webgl context
  96510. * @param value defines the webGL transform feedback object to bind
  96511. */
  96512. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  96513. /**
  96514. * Begins a transform feedback operation
  96515. * @param usePoints defines if points or triangles must be used
  96516. */
  96517. beginTransformFeedback(usePoints: boolean): void;
  96518. /**
  96519. * Ends a transform feedback operation
  96520. */
  96521. endTransformFeedback(): void;
  96522. /**
  96523. * Specify the varyings to use with transform feedback
  96524. * @param program defines the associated webGL program
  96525. * @param value defines the list of strings representing the varying names
  96526. */
  96527. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  96528. /**
  96529. * Bind a webGL buffer for a transform feedback operation
  96530. * @param value defines the webGL buffer to bind
  96531. */
  96532. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  96533. }
  96534. }
  96535. declare module BABYLON {
  96536. /**
  96537. * Gather the list of clipboard event types as constants.
  96538. */
  96539. export class ClipboardEventTypes {
  96540. /**
  96541. * The clipboard event is fired when a copy command is active (pressed).
  96542. */
  96543. static readonly COPY: number;
  96544. /**
  96545. * The clipboard event is fired when a cut command is active (pressed).
  96546. */
  96547. static readonly CUT: number;
  96548. /**
  96549. * The clipboard event is fired when a paste command is active (pressed).
  96550. */
  96551. static readonly PASTE: number;
  96552. }
  96553. /**
  96554. * This class is used to store clipboard related info for the onClipboardObservable event.
  96555. */
  96556. export class ClipboardInfo {
  96557. /**
  96558. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96559. */
  96560. type: number;
  96561. /**
  96562. * Defines the related dom event
  96563. */
  96564. event: ClipboardEvent;
  96565. /**
  96566. *Creates an instance of ClipboardInfo.
  96567. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  96568. * @param event Defines the related dom event
  96569. */
  96570. constructor(
  96571. /**
  96572. * Defines the type of event (BABYLON.ClipboardEventTypes)
  96573. */
  96574. type: number,
  96575. /**
  96576. * Defines the related dom event
  96577. */
  96578. event: ClipboardEvent);
  96579. /**
  96580. * Get the clipboard event's type from the keycode.
  96581. * @param keyCode Defines the keyCode for the current keyboard event.
  96582. * @return {number}
  96583. */
  96584. static GetTypeFromCharacter(keyCode: number): number;
  96585. }
  96586. }
  96587. declare module BABYLON {
  96588. /**
  96589. * Class used to represent data loading progression
  96590. */
  96591. export class SceneLoaderProgressEvent {
  96592. /** defines if data length to load can be evaluated */
  96593. readonly lengthComputable: boolean;
  96594. /** defines the loaded data length */
  96595. readonly loaded: number;
  96596. /** defines the data length to load */
  96597. readonly total: number;
  96598. /**
  96599. * Create a new progress event
  96600. * @param lengthComputable defines if data length to load can be evaluated
  96601. * @param loaded defines the loaded data length
  96602. * @param total defines the data length to load
  96603. */
  96604. constructor(
  96605. /** defines if data length to load can be evaluated */
  96606. lengthComputable: boolean,
  96607. /** defines the loaded data length */
  96608. loaded: number,
  96609. /** defines the data length to load */
  96610. total: number);
  96611. /**
  96612. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  96613. * @param event defines the source event
  96614. * @returns a new SceneLoaderProgressEvent
  96615. */
  96616. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  96617. }
  96618. /**
  96619. * Interface used by SceneLoader plugins to define supported file extensions
  96620. */
  96621. export interface ISceneLoaderPluginExtensions {
  96622. /**
  96623. * Defines the list of supported extensions
  96624. */
  96625. [extension: string]: {
  96626. isBinary: boolean;
  96627. };
  96628. }
  96629. /**
  96630. * Interface used by SceneLoader plugin factory
  96631. */
  96632. export interface ISceneLoaderPluginFactory {
  96633. /**
  96634. * Defines the name of the factory
  96635. */
  96636. name: string;
  96637. /**
  96638. * Function called to create a new plugin
  96639. * @return the new plugin
  96640. */
  96641. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  96642. /**
  96643. * Boolean indicating if the plugin can direct load specific data
  96644. */
  96645. canDirectLoad?: (data: string) => boolean;
  96646. }
  96647. /**
  96648. * Interface used to define a SceneLoader plugin
  96649. */
  96650. export interface ISceneLoaderPlugin {
  96651. /**
  96652. * The friendly name of this plugin.
  96653. */
  96654. name: string;
  96655. /**
  96656. * The file extensions supported by this plugin.
  96657. */
  96658. extensions: string | ISceneLoaderPluginExtensions;
  96659. /**
  96660. * Import meshes into a scene.
  96661. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96662. * @param scene The scene to import into
  96663. * @param data The data to import
  96664. * @param rootUrl The root url for scene and resources
  96665. * @param meshes The meshes array to import into
  96666. * @param particleSystems The particle systems array to import into
  96667. * @param skeletons The skeletons array to import into
  96668. * @param onError The callback when import fails
  96669. * @returns True if successful or false otherwise
  96670. */
  96671. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  96672. /**
  96673. * Load into a scene.
  96674. * @param scene The scene to load into
  96675. * @param data The data to import
  96676. * @param rootUrl The root url for scene and resources
  96677. * @param onError The callback when import fails
  96678. * @returns true if successful or false otherwise
  96679. */
  96680. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  96681. /**
  96682. * The callback that returns true if the data can be directly loaded.
  96683. */
  96684. canDirectLoad?: (data: string) => boolean;
  96685. /**
  96686. * The callback that allows custom handling of the root url based on the response url.
  96687. */
  96688. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96689. /**
  96690. * Load into an asset container.
  96691. * @param scene The scene to load into
  96692. * @param data The data to import
  96693. * @param rootUrl The root url for scene and resources
  96694. * @param onError The callback when import fails
  96695. * @returns The loaded asset container
  96696. */
  96697. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  96698. }
  96699. /**
  96700. * Interface used to define an async SceneLoader plugin
  96701. */
  96702. export interface ISceneLoaderPluginAsync {
  96703. /**
  96704. * The friendly name of this plugin.
  96705. */
  96706. name: string;
  96707. /**
  96708. * The file extensions supported by this plugin.
  96709. */
  96710. extensions: string | ISceneLoaderPluginExtensions;
  96711. /**
  96712. * Import meshes into a scene.
  96713. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96714. * @param scene The scene to import into
  96715. * @param data The data to import
  96716. * @param rootUrl The root url for scene and resources
  96717. * @param onProgress The callback when the load progresses
  96718. * @param fileName Defines the name of the file to load
  96719. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  96720. */
  96721. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  96722. meshes: AbstractMesh[];
  96723. particleSystems: IParticleSystem[];
  96724. skeletons: Skeleton[];
  96725. animationGroups: AnimationGroup[];
  96726. }>;
  96727. /**
  96728. * Load into a scene.
  96729. * @param scene The scene to load into
  96730. * @param data The data to import
  96731. * @param rootUrl The root url for scene and resources
  96732. * @param onProgress The callback when the load progresses
  96733. * @param fileName Defines the name of the file to load
  96734. * @returns Nothing
  96735. */
  96736. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  96737. /**
  96738. * The callback that returns true if the data can be directly loaded.
  96739. */
  96740. canDirectLoad?: (data: string) => boolean;
  96741. /**
  96742. * The callback that allows custom handling of the root url based on the response url.
  96743. */
  96744. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  96745. /**
  96746. * Load into an asset container.
  96747. * @param scene The scene to load into
  96748. * @param data The data to import
  96749. * @param rootUrl The root url for scene and resources
  96750. * @param onProgress The callback when the load progresses
  96751. * @param fileName Defines the name of the file to load
  96752. * @returns The loaded asset container
  96753. */
  96754. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  96755. }
  96756. /**
  96757. * Class used to load scene from various file formats using registered plugins
  96758. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  96759. */
  96760. export class SceneLoader {
  96761. /**
  96762. * No logging while loading
  96763. */
  96764. static readonly NO_LOGGING: number;
  96765. /**
  96766. * Minimal logging while loading
  96767. */
  96768. static readonly MINIMAL_LOGGING: number;
  96769. /**
  96770. * Summary logging while loading
  96771. */
  96772. static readonly SUMMARY_LOGGING: number;
  96773. /**
  96774. * Detailled logging while loading
  96775. */
  96776. static readonly DETAILED_LOGGING: number;
  96777. /**
  96778. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96779. */
  96780. static ForceFullSceneLoadingForIncremental: boolean;
  96781. /**
  96782. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96783. */
  96784. static ShowLoadingScreen: boolean;
  96785. /**
  96786. * Defines the current logging level (while loading the scene)
  96787. * @ignorenaming
  96788. */
  96789. static loggingLevel: number;
  96790. /**
  96791. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96792. */
  96793. static CleanBoneMatrixWeights: boolean;
  96794. /**
  96795. * Event raised when a plugin is used to load a scene
  96796. */
  96797. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  96798. private static _registeredPlugins;
  96799. private static _getDefaultPlugin;
  96800. private static _getPluginForExtension;
  96801. private static _getPluginForDirectLoad;
  96802. private static _getPluginForFilename;
  96803. private static _getDirectLoad;
  96804. private static _loadData;
  96805. private static _getFileInfo;
  96806. /**
  96807. * Gets a plugin that can load the given extension
  96808. * @param extension defines the extension to load
  96809. * @returns a plugin or null if none works
  96810. */
  96811. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  96812. /**
  96813. * Gets a boolean indicating that the given extension can be loaded
  96814. * @param extension defines the extension to load
  96815. * @returns true if the extension is supported
  96816. */
  96817. static IsPluginForExtensionAvailable(extension: string): boolean;
  96818. /**
  96819. * Adds a new plugin to the list of registered plugins
  96820. * @param plugin defines the plugin to add
  96821. */
  96822. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  96823. /**
  96824. * Import meshes into a scene
  96825. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96826. * @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)
  96827. * @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)
  96828. * @param scene the instance of BABYLON.Scene to append to
  96829. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  96830. * @param onProgress a callback with a progress event for each file being loaded
  96831. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96832. * @param pluginExtension the extension used to determine the plugin
  96833. * @returns The loaded plugin
  96834. */
  96835. 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>;
  96836. /**
  96837. * Import meshes into a scene
  96838. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  96839. * @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)
  96840. * @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)
  96841. * @param scene the instance of BABYLON.Scene to append to
  96842. * @param onProgress a callback with a progress event for each file being loaded
  96843. * @param pluginExtension the extension used to determine the plugin
  96844. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  96845. */
  96846. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  96847. meshes: AbstractMesh[];
  96848. particleSystems: IParticleSystem[];
  96849. skeletons: Skeleton[];
  96850. animationGroups: AnimationGroup[];
  96851. }>;
  96852. /**
  96853. * Load a scene
  96854. * @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)
  96855. * @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)
  96856. * @param engine is the instance of BABYLON.Engine to use to create the scene
  96857. * @param onSuccess a callback with the scene when import succeeds
  96858. * @param onProgress a callback with a progress event for each file being loaded
  96859. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96860. * @param pluginExtension the extension used to determine the plugin
  96861. * @returns The loaded plugin
  96862. */
  96863. 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>;
  96864. /**
  96865. * Load a scene
  96866. * @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)
  96867. * @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)
  96868. * @param engine is the instance of BABYLON.Engine to use to create the scene
  96869. * @param onProgress a callback with a progress event for each file being loaded
  96870. * @param pluginExtension the extension used to determine the plugin
  96871. * @returns The loaded scene
  96872. */
  96873. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  96874. /**
  96875. * Append a scene
  96876. * @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)
  96877. * @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)
  96878. * @param scene is the instance of BABYLON.Scene to append to
  96879. * @param onSuccess a callback with the scene when import succeeds
  96880. * @param onProgress a callback with a progress event for each file being loaded
  96881. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96882. * @param pluginExtension the extension used to determine the plugin
  96883. * @returns The loaded plugin
  96884. */
  96885. 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>;
  96886. /**
  96887. * Append a scene
  96888. * @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)
  96889. * @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)
  96890. * @param scene is the instance of BABYLON.Scene to append to
  96891. * @param onProgress a callback with a progress event for each file being loaded
  96892. * @param pluginExtension the extension used to determine the plugin
  96893. * @returns The given scene
  96894. */
  96895. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  96896. /**
  96897. * Load a scene into an asset container
  96898. * @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)
  96899. * @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)
  96900. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  96901. * @param onSuccess a callback with the scene when import succeeds
  96902. * @param onProgress a callback with a progress event for each file being loaded
  96903. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  96904. * @param pluginExtension the extension used to determine the plugin
  96905. * @returns The loaded plugin
  96906. */
  96907. 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>;
  96908. /**
  96909. * Load a scene into an asset container
  96910. * @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)
  96911. * @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)
  96912. * @param scene is the instance of Scene to append to
  96913. * @param onProgress a callback with a progress event for each file being loaded
  96914. * @param pluginExtension the extension used to determine the plugin
  96915. * @returns The loaded asset container
  96916. */
  96917. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  96918. }
  96919. }
  96920. declare module BABYLON {
  96921. /**
  96922. * Google Daydream controller
  96923. */
  96924. export class DaydreamController extends WebVRController {
  96925. /**
  96926. * Base Url for the controller model.
  96927. */
  96928. static MODEL_BASE_URL: string;
  96929. /**
  96930. * File name for the controller model.
  96931. */
  96932. static MODEL_FILENAME: string;
  96933. /**
  96934. * Gamepad Id prefix used to identify Daydream Controller.
  96935. */
  96936. static readonly GAMEPAD_ID_PREFIX: string;
  96937. /**
  96938. * Creates a new DaydreamController from a gamepad
  96939. * @param vrGamepad the gamepad that the controller should be created from
  96940. */
  96941. constructor(vrGamepad: any);
  96942. /**
  96943. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  96944. * @param scene scene in which to add meshes
  96945. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  96946. */
  96947. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96948. /**
  96949. * Called once for each button that changed state since the last frame
  96950. * @param buttonIdx Which button index changed
  96951. * @param state New state of the button
  96952. * @param changes Which properties on the state changed since last frame
  96953. */
  96954. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96955. }
  96956. }
  96957. declare module BABYLON {
  96958. /**
  96959. * Gear VR Controller
  96960. */
  96961. export class GearVRController extends WebVRController {
  96962. /**
  96963. * Base Url for the controller model.
  96964. */
  96965. static MODEL_BASE_URL: string;
  96966. /**
  96967. * File name for the controller model.
  96968. */
  96969. static MODEL_FILENAME: string;
  96970. /**
  96971. * Gamepad Id prefix used to identify this controller.
  96972. */
  96973. static readonly GAMEPAD_ID_PREFIX: string;
  96974. private readonly _buttonIndexToObservableNameMap;
  96975. /**
  96976. * Creates a new GearVRController from a gamepad
  96977. * @param vrGamepad the gamepad that the controller should be created from
  96978. */
  96979. constructor(vrGamepad: any);
  96980. /**
  96981. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  96982. * @param scene scene in which to add meshes
  96983. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  96984. */
  96985. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  96986. /**
  96987. * Called once for each button that changed state since the last frame
  96988. * @param buttonIdx Which button index changed
  96989. * @param state New state of the button
  96990. * @param changes Which properties on the state changed since last frame
  96991. */
  96992. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  96993. }
  96994. }
  96995. declare module BABYLON {
  96996. /**
  96997. * Generic Controller
  96998. */
  96999. export class GenericController extends WebVRController {
  97000. /**
  97001. * Base Url for the controller model.
  97002. */
  97003. static readonly MODEL_BASE_URL: string;
  97004. /**
  97005. * File name for the controller model.
  97006. */
  97007. static readonly MODEL_FILENAME: string;
  97008. /**
  97009. * Creates a new GenericController from a gamepad
  97010. * @param vrGamepad the gamepad that the controller should be created from
  97011. */
  97012. constructor(vrGamepad: any);
  97013. /**
  97014. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97015. * @param scene scene in which to add meshes
  97016. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97017. */
  97018. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97019. /**
  97020. * Called once for each button that changed state since the last frame
  97021. * @param buttonIdx Which button index changed
  97022. * @param state New state of the button
  97023. * @param changes Which properties on the state changed since last frame
  97024. */
  97025. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97026. }
  97027. }
  97028. declare module BABYLON {
  97029. /**
  97030. * Oculus Touch Controller
  97031. */
  97032. export class OculusTouchController extends WebVRController {
  97033. /**
  97034. * Base Url for the controller model.
  97035. */
  97036. static MODEL_BASE_URL: string;
  97037. /**
  97038. * File name for the left controller model.
  97039. */
  97040. static MODEL_LEFT_FILENAME: string;
  97041. /**
  97042. * File name for the right controller model.
  97043. */
  97044. static MODEL_RIGHT_FILENAME: string;
  97045. /**
  97046. * Fired when the secondary trigger on this controller is modified
  97047. */
  97048. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97049. /**
  97050. * Fired when the thumb rest on this controller is modified
  97051. */
  97052. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  97053. /**
  97054. * Creates a new OculusTouchController from a gamepad
  97055. * @param vrGamepad the gamepad that the controller should be created from
  97056. */
  97057. constructor(vrGamepad: any);
  97058. /**
  97059. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97060. * @param scene scene in which to add meshes
  97061. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97062. */
  97063. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97064. /**
  97065. * Fired when the A button on this controller is modified
  97066. */
  97067. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97068. /**
  97069. * Fired when the B button on this controller is modified
  97070. */
  97071. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97072. /**
  97073. * Fired when the X button on this controller is modified
  97074. */
  97075. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97076. /**
  97077. * Fired when the Y button on this controller is modified
  97078. */
  97079. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97080. /**
  97081. * Called once for each button that changed state since the last frame
  97082. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  97083. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  97084. * 2) secondary trigger (same)
  97085. * 3) A (right) X (left), touch, pressed = value
  97086. * 4) B / Y
  97087. * 5) thumb rest
  97088. * @param buttonIdx Which button index changed
  97089. * @param state New state of the button
  97090. * @param changes Which properties on the state changed since last frame
  97091. */
  97092. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97093. }
  97094. }
  97095. declare module BABYLON {
  97096. /**
  97097. * Vive Controller
  97098. */
  97099. export class ViveController extends WebVRController {
  97100. /**
  97101. * Base Url for the controller model.
  97102. */
  97103. static MODEL_BASE_URL: string;
  97104. /**
  97105. * File name for the controller model.
  97106. */
  97107. static MODEL_FILENAME: string;
  97108. /**
  97109. * Creates a new ViveController from a gamepad
  97110. * @param vrGamepad the gamepad that the controller should be created from
  97111. */
  97112. constructor(vrGamepad: any);
  97113. /**
  97114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97115. * @param scene scene in which to add meshes
  97116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97117. */
  97118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97119. /**
  97120. * Fired when the left button on this controller is modified
  97121. */
  97122. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97123. /**
  97124. * Fired when the right button on this controller is modified
  97125. */
  97126. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97127. /**
  97128. * Fired when the menu button on this controller is modified
  97129. */
  97130. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97131. /**
  97132. * Called once for each button that changed state since the last frame
  97133. * Vive mapping:
  97134. * 0: touchpad
  97135. * 1: trigger
  97136. * 2: left AND right buttons
  97137. * 3: menu button
  97138. * @param buttonIdx Which button index changed
  97139. * @param state New state of the button
  97140. * @param changes Which properties on the state changed since last frame
  97141. */
  97142. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97143. }
  97144. }
  97145. declare module BABYLON {
  97146. /**
  97147. * Defines the WindowsMotionController object that the state of the windows motion controller
  97148. */
  97149. export class WindowsMotionController extends WebVRController {
  97150. /**
  97151. * The base url used to load the left and right controller models
  97152. */
  97153. static MODEL_BASE_URL: string;
  97154. /**
  97155. * The name of the left controller model file
  97156. */
  97157. static MODEL_LEFT_FILENAME: string;
  97158. /**
  97159. * The name of the right controller model file
  97160. */
  97161. static MODEL_RIGHT_FILENAME: string;
  97162. /**
  97163. * The controller name prefix for this controller type
  97164. */
  97165. static readonly GAMEPAD_ID_PREFIX: string;
  97166. /**
  97167. * The controller id pattern for this controller type
  97168. */
  97169. private static readonly GAMEPAD_ID_PATTERN;
  97170. private _loadedMeshInfo;
  97171. private readonly _mapping;
  97172. /**
  97173. * Fired when the trackpad on this controller is clicked
  97174. */
  97175. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  97176. /**
  97177. * Fired when the trackpad on this controller is modified
  97178. */
  97179. onTrackpadValuesChangedObservable: Observable<StickValues>;
  97180. /**
  97181. * The current x and y values of this controller's trackpad
  97182. */
  97183. trackpad: StickValues;
  97184. /**
  97185. * Creates a new WindowsMotionController from a gamepad
  97186. * @param vrGamepad the gamepad that the controller should be created from
  97187. */
  97188. constructor(vrGamepad: any);
  97189. /**
  97190. * Fired when the trigger on this controller is modified
  97191. */
  97192. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97193. /**
  97194. * Fired when the menu button on this controller is modified
  97195. */
  97196. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97197. /**
  97198. * Fired when the grip button on this controller is modified
  97199. */
  97200. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97201. /**
  97202. * Fired when the thumbstick button on this controller is modified
  97203. */
  97204. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97205. /**
  97206. * Fired when the touchpad button on this controller is modified
  97207. */
  97208. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97209. /**
  97210. * Fired when the touchpad values on this controller are modified
  97211. */
  97212. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  97213. private _updateTrackpad;
  97214. /**
  97215. * Called once per frame by the engine.
  97216. */
  97217. update(): void;
  97218. /**
  97219. * Called once for each button that changed state since the last frame
  97220. * @param buttonIdx Which button index changed
  97221. * @param state New state of the button
  97222. * @param changes Which properties on the state changed since last frame
  97223. */
  97224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97225. /**
  97226. * Moves the buttons on the controller mesh based on their current state
  97227. * @param buttonName the name of the button to move
  97228. * @param buttonValue the value of the button which determines the buttons new position
  97229. */
  97230. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  97231. /**
  97232. * Moves the axis on the controller mesh based on its current state
  97233. * @param axis the index of the axis
  97234. * @param axisValue the value of the axis which determines the meshes new position
  97235. * @hidden
  97236. */
  97237. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  97238. /**
  97239. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  97240. * @param scene scene in which to add meshes
  97241. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  97242. */
  97243. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  97244. /**
  97245. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  97246. * can be transformed by button presses and axes values, based on this._mapping.
  97247. *
  97248. * @param scene scene in which the meshes exist
  97249. * @param meshes list of meshes that make up the controller model to process
  97250. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  97251. */
  97252. private processModel;
  97253. private createMeshInfo;
  97254. /**
  97255. * Gets the ray of the controller in the direction the controller is pointing
  97256. * @param length the length the resulting ray should be
  97257. * @returns a ray in the direction the controller is pointing
  97258. */
  97259. getForwardRay(length?: number): Ray;
  97260. /**
  97261. * Disposes of the controller
  97262. */
  97263. dispose(): void;
  97264. }
  97265. }
  97266. declare module BABYLON {
  97267. /**
  97268. * Manager for handling gamepads
  97269. */
  97270. export class GamepadManager {
  97271. private _scene?;
  97272. private _babylonGamepads;
  97273. private _oneGamepadConnected;
  97274. /** @hidden */
  97275. _isMonitoring: boolean;
  97276. private _gamepadEventSupported;
  97277. private _gamepadSupport;
  97278. /**
  97279. * observable to be triggered when the gamepad controller has been connected
  97280. */
  97281. onGamepadConnectedObservable: Observable<Gamepad>;
  97282. /**
  97283. * observable to be triggered when the gamepad controller has been disconnected
  97284. */
  97285. onGamepadDisconnectedObservable: Observable<Gamepad>;
  97286. private _onGamepadConnectedEvent;
  97287. private _onGamepadDisconnectedEvent;
  97288. /**
  97289. * Initializes the gamepad manager
  97290. * @param _scene BabylonJS scene
  97291. */
  97292. constructor(_scene?: Scene | undefined);
  97293. /**
  97294. * The gamepads in the game pad manager
  97295. */
  97296. readonly gamepads: Gamepad[];
  97297. /**
  97298. * Get the gamepad controllers based on type
  97299. * @param type The type of gamepad controller
  97300. * @returns Nullable gamepad
  97301. */
  97302. getGamepadByType(type?: number): Nullable<Gamepad>;
  97303. /**
  97304. * Disposes the gamepad manager
  97305. */
  97306. dispose(): void;
  97307. private _addNewGamepad;
  97308. private _startMonitoringGamepads;
  97309. private _stopMonitoringGamepads;
  97310. /** @hidden */
  97311. _checkGamepadsStatus(): void;
  97312. private _updateGamepadObjects;
  97313. }
  97314. }
  97315. declare module BABYLON {
  97316. interface Scene {
  97317. /** @hidden */
  97318. _gamepadManager: Nullable<GamepadManager>;
  97319. /**
  97320. * Gets the gamepad manager associated with the scene
  97321. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  97322. */
  97323. gamepadManager: GamepadManager;
  97324. }
  97325. /**
  97326. * Interface representing a free camera inputs manager
  97327. */
  97328. interface FreeCameraInputsManager {
  97329. /**
  97330. * Adds gamepad input support to the FreeCameraInputsManager.
  97331. * @returns the FreeCameraInputsManager
  97332. */
  97333. addGamepad(): FreeCameraInputsManager;
  97334. }
  97335. /**
  97336. * Interface representing an arc rotate camera inputs manager
  97337. */
  97338. interface ArcRotateCameraInputsManager {
  97339. /**
  97340. * Adds gamepad input support to the ArcRotateCamera InputManager.
  97341. * @returns the camera inputs manager
  97342. */
  97343. addGamepad(): ArcRotateCameraInputsManager;
  97344. }
  97345. /**
  97346. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  97347. */
  97348. export class GamepadSystemSceneComponent implements ISceneComponent {
  97349. /**
  97350. * The component name helpfull to identify the component in the list of scene components.
  97351. */
  97352. readonly name: string;
  97353. /**
  97354. * The scene the component belongs to.
  97355. */
  97356. scene: Scene;
  97357. /**
  97358. * Creates a new instance of the component for the given scene
  97359. * @param scene Defines the scene to register the component in
  97360. */
  97361. constructor(scene: Scene);
  97362. /**
  97363. * Registers the component in a given scene
  97364. */
  97365. register(): void;
  97366. /**
  97367. * Rebuilds the elements related to this component in case of
  97368. * context lost for instance.
  97369. */
  97370. rebuild(): void;
  97371. /**
  97372. * Disposes the component and the associated ressources
  97373. */
  97374. dispose(): void;
  97375. private _beforeCameraUpdate;
  97376. }
  97377. }
  97378. declare module BABYLON {
  97379. /**
  97380. * Single axis scale gizmo
  97381. */
  97382. export class AxisScaleGizmo extends Gizmo {
  97383. private _coloredMaterial;
  97384. /**
  97385. * Drag behavior responsible for the gizmos dragging interactions
  97386. */
  97387. dragBehavior: PointerDragBehavior;
  97388. private _pointerObserver;
  97389. /**
  97390. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97391. */
  97392. snapDistance: number;
  97393. /**
  97394. * Event that fires each time the gizmo snaps to a new location.
  97395. * * snapDistance is the the change in distance
  97396. */
  97397. onSnapObservable: Observable<{
  97398. snapDistance: number;
  97399. }>;
  97400. /**
  97401. * If the scaling operation should be done on all axis (default: false)
  97402. */
  97403. uniformScaling: boolean;
  97404. /**
  97405. * Creates an AxisScaleGizmo
  97406. * @param gizmoLayer The utility layer the gizmo will be added to
  97407. * @param dragAxis The axis which the gizmo will be able to scale on
  97408. * @param color The color of the gizmo
  97409. */
  97410. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97411. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97412. /**
  97413. * Disposes of the gizmo
  97414. */
  97415. dispose(): void;
  97416. /**
  97417. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  97418. * @param mesh The mesh to replace the default mesh of the gizmo
  97419. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  97420. */
  97421. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  97422. }
  97423. }
  97424. declare module BABYLON {
  97425. /**
  97426. * Bounding box gizmo
  97427. */
  97428. export class BoundingBoxGizmo extends Gizmo {
  97429. private _lineBoundingBox;
  97430. private _rotateSpheresParent;
  97431. private _scaleBoxesParent;
  97432. private _boundingDimensions;
  97433. private _renderObserver;
  97434. private _pointerObserver;
  97435. private _scaleDragSpeed;
  97436. private _tmpQuaternion;
  97437. private _tmpVector;
  97438. private _tmpRotationMatrix;
  97439. /**
  97440. * 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)
  97441. */
  97442. ignoreChildren: boolean;
  97443. /**
  97444. * 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)
  97445. */
  97446. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  97447. /**
  97448. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  97449. */
  97450. rotationSphereSize: number;
  97451. /**
  97452. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  97453. */
  97454. scaleBoxSize: number;
  97455. /**
  97456. * 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)
  97457. */
  97458. fixedDragMeshScreenSize: boolean;
  97459. /**
  97460. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  97461. */
  97462. fixedDragMeshScreenSizeDistanceFactor: number;
  97463. /**
  97464. * Fired when a rotation sphere or scale box is dragged
  97465. */
  97466. onDragStartObservable: Observable<{}>;
  97467. /**
  97468. * Fired when a scale box is dragged
  97469. */
  97470. onScaleBoxDragObservable: Observable<{}>;
  97471. /**
  97472. * Fired when a scale box drag is ended
  97473. */
  97474. onScaleBoxDragEndObservable: Observable<{}>;
  97475. /**
  97476. * Fired when a rotation sphere is dragged
  97477. */
  97478. onRotationSphereDragObservable: Observable<{}>;
  97479. /**
  97480. * Fired when a rotation sphere drag is ended
  97481. */
  97482. onRotationSphereDragEndObservable: Observable<{}>;
  97483. /**
  97484. * 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)
  97485. */
  97486. scalePivot: Nullable<Vector3>;
  97487. private _anchorMesh;
  97488. private _existingMeshScale;
  97489. private _dragMesh;
  97490. private pointerDragBehavior;
  97491. /**
  97492. * Creates an BoundingBoxGizmo
  97493. * @param gizmoLayer The utility layer the gizmo will be added to
  97494. * @param color The color of the gizmo
  97495. */
  97496. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  97497. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97498. private _selectNode;
  97499. /**
  97500. * Updates the bounding box information for the Gizmo
  97501. */
  97502. updateBoundingBox(): void;
  97503. private _updateRotationSpheres;
  97504. private _updateScaleBoxes;
  97505. /**
  97506. * Enables rotation on the specified axis and disables rotation on the others
  97507. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  97508. */
  97509. setEnabledRotationAxis(axis: string): void;
  97510. /**
  97511. * Enables/disables scaling
  97512. * @param enable if scaling should be enabled
  97513. */
  97514. setEnabledScaling(enable: boolean): void;
  97515. private _updateDummy;
  97516. /**
  97517. * Enables a pointer drag behavior on the bounding box of the gizmo
  97518. */
  97519. enableDragBehavior(): void;
  97520. /**
  97521. * Disposes of the gizmo
  97522. */
  97523. dispose(): void;
  97524. /**
  97525. * 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)
  97526. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  97527. * @returns the bounding box mesh with the passed in mesh as a child
  97528. */
  97529. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  97530. /**
  97531. * CustomMeshes are not supported by this gizmo
  97532. * @param mesh The mesh to replace the default mesh of the gizmo
  97533. */
  97534. setCustomMesh(mesh: Mesh): void;
  97535. }
  97536. }
  97537. declare module BABYLON {
  97538. /**
  97539. * Single plane rotation gizmo
  97540. */
  97541. export class PlaneRotationGizmo extends Gizmo {
  97542. /**
  97543. * Drag behavior responsible for the gizmos dragging interactions
  97544. */
  97545. dragBehavior: PointerDragBehavior;
  97546. private _pointerObserver;
  97547. /**
  97548. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  97549. */
  97550. snapDistance: number;
  97551. /**
  97552. * Event that fires each time the gizmo snaps to a new location.
  97553. * * snapDistance is the the change in distance
  97554. */
  97555. onSnapObservable: Observable<{
  97556. snapDistance: number;
  97557. }>;
  97558. /**
  97559. * Creates a PlaneRotationGizmo
  97560. * @param gizmoLayer The utility layer the gizmo will be added to
  97561. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  97562. * @param color The color of the gizmo
  97563. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97564. */
  97565. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97566. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  97567. /**
  97568. * Disposes of the gizmo
  97569. */
  97570. dispose(): void;
  97571. }
  97572. }
  97573. declare module BABYLON {
  97574. /**
  97575. * Gizmo that enables rotating a mesh along 3 axis
  97576. */
  97577. export class RotationGizmo extends Gizmo {
  97578. /**
  97579. * Internal gizmo used for interactions on the x axis
  97580. */
  97581. xGizmo: PlaneRotationGizmo;
  97582. /**
  97583. * Internal gizmo used for interactions on the y axis
  97584. */
  97585. yGizmo: PlaneRotationGizmo;
  97586. /**
  97587. * Internal gizmo used for interactions on the z axis
  97588. */
  97589. zGizmo: PlaneRotationGizmo;
  97590. /** Fires an event when any of it's sub gizmos are dragged */
  97591. onDragStartObservable: Observable<{}>;
  97592. /** Fires an event when any of it's sub gizmos are released from dragging */
  97593. onDragEndObservable: Observable<{}>;
  97594. attachedMesh: Nullable<AbstractMesh>;
  97595. /**
  97596. * Creates a RotationGizmo
  97597. * @param gizmoLayer The utility layer the gizmo will be added to
  97598. * @param tessellation Amount of tessellation to be used when creating rotation circles
  97599. */
  97600. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  97601. updateGizmoRotationToMatchAttachedMesh: boolean;
  97602. /**
  97603. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97604. */
  97605. snapDistance: number;
  97606. /**
  97607. * Ratio for the scale of the gizmo (Default: 1)
  97608. */
  97609. scaleRatio: number;
  97610. /**
  97611. * Disposes of the gizmo
  97612. */
  97613. dispose(): void;
  97614. /**
  97615. * CustomMeshes are not supported by this gizmo
  97616. * @param mesh The mesh to replace the default mesh of the gizmo
  97617. */
  97618. setCustomMesh(mesh: Mesh): void;
  97619. }
  97620. }
  97621. declare module BABYLON {
  97622. /**
  97623. * Gizmo that enables dragging a mesh along 3 axis
  97624. */
  97625. export class PositionGizmo extends Gizmo {
  97626. /**
  97627. * Internal gizmo used for interactions on the x axis
  97628. */
  97629. xGizmo: AxisDragGizmo;
  97630. /**
  97631. * Internal gizmo used for interactions on the y axis
  97632. */
  97633. yGizmo: AxisDragGizmo;
  97634. /**
  97635. * Internal gizmo used for interactions on the z axis
  97636. */
  97637. zGizmo: AxisDragGizmo;
  97638. /** Fires an event when any of it's sub gizmos are dragged */
  97639. onDragStartObservable: Observable<{}>;
  97640. /** Fires an event when any of it's sub gizmos are released from dragging */
  97641. onDragEndObservable: Observable<{}>;
  97642. attachedMesh: Nullable<AbstractMesh>;
  97643. /**
  97644. * Creates a PositionGizmo
  97645. * @param gizmoLayer The utility layer the gizmo will be added to
  97646. */
  97647. constructor(gizmoLayer?: UtilityLayerRenderer);
  97648. updateGizmoRotationToMatchAttachedMesh: boolean;
  97649. /**
  97650. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97651. */
  97652. snapDistance: number;
  97653. /**
  97654. * Ratio for the scale of the gizmo (Default: 1)
  97655. */
  97656. scaleRatio: number;
  97657. /**
  97658. * Disposes of the gizmo
  97659. */
  97660. dispose(): void;
  97661. /**
  97662. * CustomMeshes are not supported by this gizmo
  97663. * @param mesh The mesh to replace the default mesh of the gizmo
  97664. */
  97665. setCustomMesh(mesh: Mesh): void;
  97666. }
  97667. }
  97668. declare module BABYLON {
  97669. /**
  97670. * Class containing static functions to help procedurally build meshes
  97671. */
  97672. export class PolyhedronBuilder {
  97673. /**
  97674. * Creates a polyhedron mesh
  97675. * * 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
  97676. * * The parameter `size` (positive float, default 1) sets the polygon size
  97677. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  97678. * * 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`
  97679. * * 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
  97680. * * 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)`)
  97681. * * 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
  97682. * * 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
  97683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97686. * @param name defines the name of the mesh
  97687. * @param options defines the options used to create the mesh
  97688. * @param scene defines the hosting scene
  97689. * @returns the polyhedron mesh
  97690. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  97691. */
  97692. static CreatePolyhedron(name: string, options: {
  97693. type?: number;
  97694. size?: number;
  97695. sizeX?: number;
  97696. sizeY?: number;
  97697. sizeZ?: number;
  97698. custom?: any;
  97699. faceUV?: Vector4[];
  97700. faceColors?: Color4[];
  97701. flat?: boolean;
  97702. updatable?: boolean;
  97703. sideOrientation?: number;
  97704. frontUVs?: Vector4;
  97705. backUVs?: Vector4;
  97706. }, scene: Scene): Mesh;
  97707. }
  97708. }
  97709. declare module BABYLON {
  97710. /**
  97711. * Gizmo that enables scaling a mesh along 3 axis
  97712. */
  97713. export class ScaleGizmo extends Gizmo {
  97714. /**
  97715. * Internal gizmo used for interactions on the x axis
  97716. */
  97717. xGizmo: AxisScaleGizmo;
  97718. /**
  97719. * Internal gizmo used for interactions on the y axis
  97720. */
  97721. yGizmo: AxisScaleGizmo;
  97722. /**
  97723. * Internal gizmo used for interactions on the z axis
  97724. */
  97725. zGizmo: AxisScaleGizmo;
  97726. /**
  97727. * Internal gizmo used to scale all axis equally
  97728. */
  97729. uniformScaleGizmo: AxisScaleGizmo;
  97730. /** Fires an event when any of it's sub gizmos are dragged */
  97731. onDragStartObservable: Observable<{}>;
  97732. /** Fires an event when any of it's sub gizmos are released from dragging */
  97733. onDragEndObservable: Observable<{}>;
  97734. attachedMesh: Nullable<AbstractMesh>;
  97735. /**
  97736. * Creates a ScaleGizmo
  97737. * @param gizmoLayer The utility layer the gizmo will be added to
  97738. */
  97739. constructor(gizmoLayer?: UtilityLayerRenderer);
  97740. updateGizmoRotationToMatchAttachedMesh: boolean;
  97741. /**
  97742. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  97743. */
  97744. snapDistance: number;
  97745. /**
  97746. * Ratio for the scale of the gizmo (Default: 1)
  97747. */
  97748. scaleRatio: number;
  97749. /**
  97750. * Disposes of the gizmo
  97751. */
  97752. dispose(): void;
  97753. }
  97754. }
  97755. declare module BABYLON {
  97756. /**
  97757. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  97758. */
  97759. export class GizmoManager implements IDisposable {
  97760. private scene;
  97761. /**
  97762. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  97763. */
  97764. gizmos: {
  97765. positionGizmo: Nullable<PositionGizmo>;
  97766. rotationGizmo: Nullable<RotationGizmo>;
  97767. scaleGizmo: Nullable<ScaleGizmo>;
  97768. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  97769. };
  97770. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  97771. clearGizmoOnEmptyPointerEvent: boolean;
  97772. /** Fires an event when the manager is attached to a mesh */
  97773. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  97774. private _gizmosEnabled;
  97775. private _pointerObserver;
  97776. private _attachedMesh;
  97777. private _boundingBoxColor;
  97778. private _defaultUtilityLayer;
  97779. private _defaultKeepDepthUtilityLayer;
  97780. /**
  97781. * When bounding box gizmo is enabled, this can be used to track drag/end events
  97782. */
  97783. boundingBoxDragBehavior: SixDofDragBehavior;
  97784. /**
  97785. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  97786. */
  97787. attachableMeshes: Nullable<Array<AbstractMesh>>;
  97788. /**
  97789. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  97790. */
  97791. usePointerToAttachGizmos: boolean;
  97792. /**
  97793. * Instatiates a gizmo manager
  97794. * @param scene the scene to overlay the gizmos on top of
  97795. */
  97796. constructor(scene: Scene);
  97797. /**
  97798. * Attaches a set of gizmos to the specified mesh
  97799. * @param mesh The mesh the gizmo's should be attached to
  97800. */
  97801. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  97802. /**
  97803. * If the position gizmo is enabled
  97804. */
  97805. positionGizmoEnabled: boolean;
  97806. /**
  97807. * If the rotation gizmo is enabled
  97808. */
  97809. rotationGizmoEnabled: boolean;
  97810. /**
  97811. * If the scale gizmo is enabled
  97812. */
  97813. scaleGizmoEnabled: boolean;
  97814. /**
  97815. * If the boundingBox gizmo is enabled
  97816. */
  97817. boundingBoxGizmoEnabled: boolean;
  97818. /**
  97819. * Disposes of the gizmo manager
  97820. */
  97821. dispose(): void;
  97822. }
  97823. }
  97824. declare module BABYLON {
  97825. /** @hidden */
  97826. export var backgroundFragmentDeclaration: {
  97827. name: string;
  97828. shader: string;
  97829. };
  97830. }
  97831. declare module BABYLON {
  97832. /** @hidden */
  97833. export var backgroundUboDeclaration: {
  97834. name: string;
  97835. shader: string;
  97836. };
  97837. }
  97838. declare module BABYLON {
  97839. /** @hidden */
  97840. export var backgroundPixelShader: {
  97841. name: string;
  97842. shader: string;
  97843. };
  97844. }
  97845. declare module BABYLON {
  97846. /** @hidden */
  97847. export var backgroundVertexDeclaration: {
  97848. name: string;
  97849. shader: string;
  97850. };
  97851. }
  97852. declare module BABYLON {
  97853. /** @hidden */
  97854. export var backgroundVertexShader: {
  97855. name: string;
  97856. shader: string;
  97857. };
  97858. }
  97859. declare module BABYLON {
  97860. /**
  97861. * Background material used to create an efficient environement around your scene.
  97862. */
  97863. export class BackgroundMaterial extends PushMaterial {
  97864. /**
  97865. * Standard reflectance value at parallel view angle.
  97866. */
  97867. static StandardReflectance0: number;
  97868. /**
  97869. * Standard reflectance value at grazing angle.
  97870. */
  97871. static StandardReflectance90: number;
  97872. protected _primaryColor: Color3;
  97873. /**
  97874. * Key light Color (multiply against the environement texture)
  97875. */
  97876. primaryColor: Color3;
  97877. protected __perceptualColor: Nullable<Color3>;
  97878. /**
  97879. * Experimental Internal Use Only.
  97880. *
  97881. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  97882. * This acts as a helper to set the primary color to a more "human friendly" value.
  97883. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  97884. * output color as close as possible from the chosen value.
  97885. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  97886. * part of lighting setup.)
  97887. */
  97888. _perceptualColor: Nullable<Color3>;
  97889. protected _primaryColorShadowLevel: float;
  97890. /**
  97891. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  97892. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  97893. */
  97894. primaryColorShadowLevel: float;
  97895. protected _primaryColorHighlightLevel: float;
  97896. /**
  97897. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  97898. * The primary color is used at the level chosen to define what the white area would look.
  97899. */
  97900. primaryColorHighlightLevel: float;
  97901. protected _reflectionTexture: Nullable<BaseTexture>;
  97902. /**
  97903. * Reflection Texture used in the material.
  97904. * Should be author in a specific way for the best result (refer to the documentation).
  97905. */
  97906. reflectionTexture: Nullable<BaseTexture>;
  97907. protected _reflectionBlur: float;
  97908. /**
  97909. * Reflection Texture level of blur.
  97910. *
  97911. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  97912. * texture twice.
  97913. */
  97914. reflectionBlur: float;
  97915. protected _diffuseTexture: Nullable<BaseTexture>;
  97916. /**
  97917. * Diffuse Texture used in the material.
  97918. * Should be author in a specific way for the best result (refer to the documentation).
  97919. */
  97920. diffuseTexture: Nullable<BaseTexture>;
  97921. protected _shadowLights: Nullable<IShadowLight[]>;
  97922. /**
  97923. * Specify the list of lights casting shadow on the material.
  97924. * All scene shadow lights will be included if null.
  97925. */
  97926. shadowLights: Nullable<IShadowLight[]>;
  97927. protected _shadowLevel: float;
  97928. /**
  97929. * Helps adjusting the shadow to a softer level if required.
  97930. * 0 means black shadows and 1 means no shadows.
  97931. */
  97932. shadowLevel: float;
  97933. protected _sceneCenter: Vector3;
  97934. /**
  97935. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  97936. * It is usually zero but might be interesting to modify according to your setup.
  97937. */
  97938. sceneCenter: Vector3;
  97939. protected _opacityFresnel: boolean;
  97940. /**
  97941. * This helps specifying that the material is falling off to the sky box at grazing angle.
  97942. * This helps ensuring a nice transition when the camera goes under the ground.
  97943. */
  97944. opacityFresnel: boolean;
  97945. protected _reflectionFresnel: boolean;
  97946. /**
  97947. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  97948. * This helps adding a mirror texture on the ground.
  97949. */
  97950. reflectionFresnel: boolean;
  97951. protected _reflectionFalloffDistance: number;
  97952. /**
  97953. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  97954. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  97955. */
  97956. reflectionFalloffDistance: number;
  97957. protected _reflectionAmount: number;
  97958. /**
  97959. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  97960. */
  97961. reflectionAmount: number;
  97962. protected _reflectionReflectance0: number;
  97963. /**
  97964. * This specifies the weight of the reflection at grazing angle.
  97965. */
  97966. reflectionReflectance0: number;
  97967. protected _reflectionReflectance90: number;
  97968. /**
  97969. * This specifies the weight of the reflection at a perpendicular point of view.
  97970. */
  97971. reflectionReflectance90: number;
  97972. /**
  97973. * Sets the reflection reflectance fresnel values according to the default standard
  97974. * empirically know to work well :-)
  97975. */
  97976. reflectionStandardFresnelWeight: number;
  97977. protected _useRGBColor: boolean;
  97978. /**
  97979. * Helps to directly use the maps channels instead of their level.
  97980. */
  97981. useRGBColor: boolean;
  97982. protected _enableNoise: boolean;
  97983. /**
  97984. * This helps reducing the banding effect that could occur on the background.
  97985. */
  97986. enableNoise: boolean;
  97987. /**
  97988. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  97989. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  97990. * Recommended to be keep at 1.0 except for special cases.
  97991. */
  97992. fovMultiplier: number;
  97993. private _fovMultiplier;
  97994. /**
  97995. * Enable the FOV adjustment feature controlled by fovMultiplier.
  97996. */
  97997. useEquirectangularFOV: boolean;
  97998. private _maxSimultaneousLights;
  97999. /**
  98000. * Number of Simultaneous lights allowed on the material.
  98001. */
  98002. maxSimultaneousLights: int;
  98003. /**
  98004. * Default configuration related to image processing available in the Background Material.
  98005. */
  98006. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98007. /**
  98008. * Keep track of the image processing observer to allow dispose and replace.
  98009. */
  98010. private _imageProcessingObserver;
  98011. /**
  98012. * Attaches a new image processing configuration to the PBR Material.
  98013. * @param configuration (if null the scene configuration will be use)
  98014. */
  98015. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98016. /**
  98017. * Gets the image processing configuration used either in this material.
  98018. */
  98019. /**
  98020. * Sets the Default image processing configuration used either in the this material.
  98021. *
  98022. * If sets to null, the scene one is in use.
  98023. */
  98024. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  98025. /**
  98026. * Gets wether the color curves effect is enabled.
  98027. */
  98028. /**
  98029. * Sets wether the color curves effect is enabled.
  98030. */
  98031. cameraColorCurvesEnabled: boolean;
  98032. /**
  98033. * Gets wether the color grading effect is enabled.
  98034. */
  98035. /**
  98036. * Gets wether the color grading effect is enabled.
  98037. */
  98038. cameraColorGradingEnabled: boolean;
  98039. /**
  98040. * Gets wether tonemapping is enabled or not.
  98041. */
  98042. /**
  98043. * Sets wether tonemapping is enabled or not
  98044. */
  98045. cameraToneMappingEnabled: boolean;
  98046. /**
  98047. * The camera exposure used on this material.
  98048. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98049. * This corresponds to a photographic exposure.
  98050. */
  98051. /**
  98052. * The camera exposure used on this material.
  98053. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98054. * This corresponds to a photographic exposure.
  98055. */
  98056. cameraExposure: float;
  98057. /**
  98058. * Gets The camera contrast used on this material.
  98059. */
  98060. /**
  98061. * Sets The camera contrast used on this material.
  98062. */
  98063. cameraContrast: float;
  98064. /**
  98065. * Gets the Color Grading 2D Lookup Texture.
  98066. */
  98067. /**
  98068. * Sets the Color Grading 2D Lookup Texture.
  98069. */
  98070. cameraColorGradingTexture: Nullable<BaseTexture>;
  98071. /**
  98072. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98073. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98074. * 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;
  98075. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98076. */
  98077. /**
  98078. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98079. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98080. * 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;
  98081. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98082. */
  98083. cameraColorCurves: Nullable<ColorCurves>;
  98084. /**
  98085. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  98086. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  98087. */
  98088. switchToBGR: boolean;
  98089. private _renderTargets;
  98090. private _reflectionControls;
  98091. private _white;
  98092. private _primaryShadowColor;
  98093. private _primaryHighlightColor;
  98094. /**
  98095. * Instantiates a Background Material in the given scene
  98096. * @param name The friendly name of the material
  98097. * @param scene The scene to add the material to
  98098. */
  98099. constructor(name: string, scene: Scene);
  98100. /**
  98101. * Gets a boolean indicating that current material needs to register RTT
  98102. */
  98103. readonly hasRenderTargetTextures: boolean;
  98104. /**
  98105. * The entire material has been created in order to prevent overdraw.
  98106. * @returns false
  98107. */
  98108. needAlphaTesting(): boolean;
  98109. /**
  98110. * The entire material has been created in order to prevent overdraw.
  98111. * @returns true if blending is enable
  98112. */
  98113. needAlphaBlending(): boolean;
  98114. /**
  98115. * Checks wether the material is ready to be rendered for a given mesh.
  98116. * @param mesh The mesh to render
  98117. * @param subMesh The submesh to check against
  98118. * @param useInstances Specify wether or not the material is used with instances
  98119. * @returns true if all the dependencies are ready (Textures, Effects...)
  98120. */
  98121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98122. /**
  98123. * Compute the primary color according to the chosen perceptual color.
  98124. */
  98125. private _computePrimaryColorFromPerceptualColor;
  98126. /**
  98127. * Compute the highlights and shadow colors according to their chosen levels.
  98128. */
  98129. private _computePrimaryColors;
  98130. /**
  98131. * Build the uniform buffer used in the material.
  98132. */
  98133. buildUniformLayout(): void;
  98134. /**
  98135. * Unbind the material.
  98136. */
  98137. unbind(): void;
  98138. /**
  98139. * Bind only the world matrix to the material.
  98140. * @param world The world matrix to bind.
  98141. */
  98142. bindOnlyWorldMatrix(world: Matrix): void;
  98143. /**
  98144. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  98145. * @param world The world matrix to bind.
  98146. * @param subMesh The submesh to bind for.
  98147. */
  98148. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98149. /**
  98150. * Dispose the material.
  98151. * @param forceDisposeEffect Force disposal of the associated effect.
  98152. * @param forceDisposeTextures Force disposal of the associated textures.
  98153. */
  98154. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98155. /**
  98156. * Clones the material.
  98157. * @param name The cloned name.
  98158. * @returns The cloned material.
  98159. */
  98160. clone(name: string): BackgroundMaterial;
  98161. /**
  98162. * Serializes the current material to its JSON representation.
  98163. * @returns The JSON representation.
  98164. */
  98165. serialize(): any;
  98166. /**
  98167. * Gets the class name of the material
  98168. * @returns "BackgroundMaterial"
  98169. */
  98170. getClassName(): string;
  98171. /**
  98172. * Parse a JSON input to create back a background material.
  98173. * @param source The JSON data to parse
  98174. * @param scene The scene to create the parsed material in
  98175. * @param rootUrl The root url of the assets the material depends upon
  98176. * @returns the instantiated BackgroundMaterial.
  98177. */
  98178. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  98179. }
  98180. }
  98181. declare module BABYLON {
  98182. /**
  98183. * Represents the different options available during the creation of
  98184. * a Environment helper.
  98185. *
  98186. * This can control the default ground, skybox and image processing setup of your scene.
  98187. */
  98188. export interface IEnvironmentHelperOptions {
  98189. /**
  98190. * Specifies wether or not to create a ground.
  98191. * True by default.
  98192. */
  98193. createGround: boolean;
  98194. /**
  98195. * Specifies the ground size.
  98196. * 15 by default.
  98197. */
  98198. groundSize: number;
  98199. /**
  98200. * The texture used on the ground for the main color.
  98201. * Comes from the BabylonJS CDN by default.
  98202. *
  98203. * Remarks: Can be either a texture or a url.
  98204. */
  98205. groundTexture: string | BaseTexture;
  98206. /**
  98207. * The color mixed in the ground texture by default.
  98208. * BabylonJS clearColor by default.
  98209. */
  98210. groundColor: Color3;
  98211. /**
  98212. * Specifies the ground opacity.
  98213. * 1 by default.
  98214. */
  98215. groundOpacity: number;
  98216. /**
  98217. * Enables the ground to receive shadows.
  98218. * True by default.
  98219. */
  98220. enableGroundShadow: boolean;
  98221. /**
  98222. * Helps preventing the shadow to be fully black on the ground.
  98223. * 0.5 by default.
  98224. */
  98225. groundShadowLevel: number;
  98226. /**
  98227. * Creates a mirror texture attach to the ground.
  98228. * false by default.
  98229. */
  98230. enableGroundMirror: boolean;
  98231. /**
  98232. * Specifies the ground mirror size ratio.
  98233. * 0.3 by default as the default kernel is 64.
  98234. */
  98235. groundMirrorSizeRatio: number;
  98236. /**
  98237. * Specifies the ground mirror blur kernel size.
  98238. * 64 by default.
  98239. */
  98240. groundMirrorBlurKernel: number;
  98241. /**
  98242. * Specifies the ground mirror visibility amount.
  98243. * 1 by default
  98244. */
  98245. groundMirrorAmount: number;
  98246. /**
  98247. * Specifies the ground mirror reflectance weight.
  98248. * This uses the standard weight of the background material to setup the fresnel effect
  98249. * of the mirror.
  98250. * 1 by default.
  98251. */
  98252. groundMirrorFresnelWeight: number;
  98253. /**
  98254. * Specifies the ground mirror Falloff distance.
  98255. * This can helps reducing the size of the reflection.
  98256. * 0 by Default.
  98257. */
  98258. groundMirrorFallOffDistance: number;
  98259. /**
  98260. * Specifies the ground mirror texture type.
  98261. * Unsigned Int by Default.
  98262. */
  98263. groundMirrorTextureType: number;
  98264. /**
  98265. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  98266. * the shown objects.
  98267. */
  98268. groundYBias: number;
  98269. /**
  98270. * Specifies wether or not to create a skybox.
  98271. * True by default.
  98272. */
  98273. createSkybox: boolean;
  98274. /**
  98275. * Specifies the skybox size.
  98276. * 20 by default.
  98277. */
  98278. skyboxSize: number;
  98279. /**
  98280. * The texture used on the skybox for the main color.
  98281. * Comes from the BabylonJS CDN by default.
  98282. *
  98283. * Remarks: Can be either a texture or a url.
  98284. */
  98285. skyboxTexture: string | BaseTexture;
  98286. /**
  98287. * The color mixed in the skybox texture by default.
  98288. * BabylonJS clearColor by default.
  98289. */
  98290. skyboxColor: Color3;
  98291. /**
  98292. * The background rotation around the Y axis of the scene.
  98293. * This helps aligning the key lights of your scene with the background.
  98294. * 0 by default.
  98295. */
  98296. backgroundYRotation: number;
  98297. /**
  98298. * Compute automatically the size of the elements to best fit with the scene.
  98299. */
  98300. sizeAuto: boolean;
  98301. /**
  98302. * Default position of the rootMesh if autoSize is not true.
  98303. */
  98304. rootPosition: Vector3;
  98305. /**
  98306. * Sets up the image processing in the scene.
  98307. * true by default.
  98308. */
  98309. setupImageProcessing: boolean;
  98310. /**
  98311. * The texture used as your environment texture in the scene.
  98312. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  98313. *
  98314. * Remarks: Can be either a texture or a url.
  98315. */
  98316. environmentTexture: string | BaseTexture;
  98317. /**
  98318. * The value of the exposure to apply to the scene.
  98319. * 0.6 by default if setupImageProcessing is true.
  98320. */
  98321. cameraExposure: number;
  98322. /**
  98323. * The value of the contrast to apply to the scene.
  98324. * 1.6 by default if setupImageProcessing is true.
  98325. */
  98326. cameraContrast: number;
  98327. /**
  98328. * Specifies wether or not tonemapping should be enabled in the scene.
  98329. * true by default if setupImageProcessing is true.
  98330. */
  98331. toneMappingEnabled: boolean;
  98332. }
  98333. /**
  98334. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  98335. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  98336. * It also helps with the default setup of your imageProcessing configuration.
  98337. */
  98338. export class EnvironmentHelper {
  98339. /**
  98340. * Default ground texture URL.
  98341. */
  98342. private static _groundTextureCDNUrl;
  98343. /**
  98344. * Default skybox texture URL.
  98345. */
  98346. private static _skyboxTextureCDNUrl;
  98347. /**
  98348. * Default environment texture URL.
  98349. */
  98350. private static _environmentTextureCDNUrl;
  98351. /**
  98352. * Creates the default options for the helper.
  98353. */
  98354. private static _getDefaultOptions;
  98355. private _rootMesh;
  98356. /**
  98357. * Gets the root mesh created by the helper.
  98358. */
  98359. readonly rootMesh: Mesh;
  98360. private _skybox;
  98361. /**
  98362. * Gets the skybox created by the helper.
  98363. */
  98364. readonly skybox: Nullable<Mesh>;
  98365. private _skyboxTexture;
  98366. /**
  98367. * Gets the skybox texture created by the helper.
  98368. */
  98369. readonly skyboxTexture: Nullable<BaseTexture>;
  98370. private _skyboxMaterial;
  98371. /**
  98372. * Gets the skybox material created by the helper.
  98373. */
  98374. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  98375. private _ground;
  98376. /**
  98377. * Gets the ground mesh created by the helper.
  98378. */
  98379. readonly ground: Nullable<Mesh>;
  98380. private _groundTexture;
  98381. /**
  98382. * Gets the ground texture created by the helper.
  98383. */
  98384. readonly groundTexture: Nullable<BaseTexture>;
  98385. private _groundMirror;
  98386. /**
  98387. * Gets the ground mirror created by the helper.
  98388. */
  98389. readonly groundMirror: Nullable<MirrorTexture>;
  98390. /**
  98391. * Gets the ground mirror render list to helps pushing the meshes
  98392. * you wish in the ground reflection.
  98393. */
  98394. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  98395. private _groundMaterial;
  98396. /**
  98397. * Gets the ground material created by the helper.
  98398. */
  98399. readonly groundMaterial: Nullable<BackgroundMaterial>;
  98400. /**
  98401. * Stores the creation options.
  98402. */
  98403. private readonly _scene;
  98404. private _options;
  98405. /**
  98406. * This observable will be notified with any error during the creation of the environment,
  98407. * mainly texture creation errors.
  98408. */
  98409. onErrorObservable: Observable<{
  98410. message?: string;
  98411. exception?: any;
  98412. }>;
  98413. /**
  98414. * constructor
  98415. * @param options Defines the options we want to customize the helper
  98416. * @param scene The scene to add the material to
  98417. */
  98418. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  98419. /**
  98420. * Updates the background according to the new options
  98421. * @param options
  98422. */
  98423. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  98424. /**
  98425. * Sets the primary color of all the available elements.
  98426. * @param color the main color to affect to the ground and the background
  98427. */
  98428. setMainColor(color: Color3): void;
  98429. /**
  98430. * Setup the image processing according to the specified options.
  98431. */
  98432. private _setupImageProcessing;
  98433. /**
  98434. * Setup the environment texture according to the specified options.
  98435. */
  98436. private _setupEnvironmentTexture;
  98437. /**
  98438. * Setup the background according to the specified options.
  98439. */
  98440. private _setupBackground;
  98441. /**
  98442. * Get the scene sizes according to the setup.
  98443. */
  98444. private _getSceneSize;
  98445. /**
  98446. * Setup the ground according to the specified options.
  98447. */
  98448. private _setupGround;
  98449. /**
  98450. * Setup the ground material according to the specified options.
  98451. */
  98452. private _setupGroundMaterial;
  98453. /**
  98454. * Setup the ground diffuse texture according to the specified options.
  98455. */
  98456. private _setupGroundDiffuseTexture;
  98457. /**
  98458. * Setup the ground mirror texture according to the specified options.
  98459. */
  98460. private _setupGroundMirrorTexture;
  98461. /**
  98462. * Setup the ground to receive the mirror texture.
  98463. */
  98464. private _setupMirrorInGroundMaterial;
  98465. /**
  98466. * Setup the skybox according to the specified options.
  98467. */
  98468. private _setupSkybox;
  98469. /**
  98470. * Setup the skybox material according to the specified options.
  98471. */
  98472. private _setupSkyboxMaterial;
  98473. /**
  98474. * Setup the skybox reflection texture according to the specified options.
  98475. */
  98476. private _setupSkyboxReflectionTexture;
  98477. private _errorHandler;
  98478. /**
  98479. * Dispose all the elements created by the Helper.
  98480. */
  98481. dispose(): void;
  98482. }
  98483. }
  98484. declare module BABYLON {
  98485. /**
  98486. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  98487. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  98488. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  98489. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  98490. */
  98491. export class PhotoDome extends TransformNode {
  98492. private _useDirectMapping;
  98493. /**
  98494. * The texture being displayed on the sphere
  98495. */
  98496. protected _photoTexture: Texture;
  98497. /**
  98498. * Gets or sets the texture being displayed on the sphere
  98499. */
  98500. photoTexture: Texture;
  98501. /**
  98502. * Observable raised when an error occured while loading the 360 image
  98503. */
  98504. onLoadErrorObservable: Observable<string>;
  98505. /**
  98506. * The skybox material
  98507. */
  98508. protected _material: BackgroundMaterial;
  98509. /**
  98510. * The surface used for the skybox
  98511. */
  98512. protected _mesh: Mesh;
  98513. /**
  98514. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  98515. * Also see the options.resolution property.
  98516. */
  98517. fovMultiplier: number;
  98518. /**
  98519. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  98520. * @param name Element's name, child elements will append suffixes for their own names.
  98521. * @param urlsOfPhoto defines the url of the photo to display
  98522. * @param options defines an object containing optional or exposed sub element properties
  98523. * @param onError defines a callback called when an error occured while loading the texture
  98524. */
  98525. constructor(name: string, urlOfPhoto: string, options: {
  98526. resolution?: number;
  98527. size?: number;
  98528. useDirectMapping?: boolean;
  98529. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  98530. /**
  98531. * Releases resources associated with this node.
  98532. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98533. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98534. */
  98535. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98536. }
  98537. }
  98538. declare module BABYLON {
  98539. /**
  98540. * Class used to host texture specific utilities
  98541. */
  98542. export class TextureTools {
  98543. /**
  98544. * Uses the GPU to create a copy texture rescaled at a given size
  98545. * @param texture Texture to copy from
  98546. * @param width defines the desired width
  98547. * @param height defines the desired height
  98548. * @param useBilinearMode defines if bilinear mode has to be used
  98549. * @return the generated texture
  98550. */
  98551. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  98552. /**
  98553. * Gets an environment BRDF texture for a given scene
  98554. * @param scene defines the hosting scene
  98555. * @returns the environment BRDF texture
  98556. */
  98557. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  98558. private static _environmentBRDFBase64Texture;
  98559. }
  98560. }
  98561. declare module BABYLON {
  98562. /** @hidden */
  98563. export var pbrFragmentDeclaration: {
  98564. name: string;
  98565. shader: string;
  98566. };
  98567. }
  98568. declare module BABYLON {
  98569. /** @hidden */
  98570. export var pbrUboDeclaration: {
  98571. name: string;
  98572. shader: string;
  98573. };
  98574. }
  98575. declare module BABYLON {
  98576. /** @hidden */
  98577. export var pbrFunctions: {
  98578. name: string;
  98579. shader: string;
  98580. };
  98581. }
  98582. declare module BABYLON {
  98583. /** @hidden */
  98584. export var harmonicsFunctions: {
  98585. name: string;
  98586. shader: string;
  98587. };
  98588. }
  98589. declare module BABYLON {
  98590. /** @hidden */
  98591. export var pbrLightFunctions: {
  98592. name: string;
  98593. shader: string;
  98594. };
  98595. }
  98596. declare module BABYLON {
  98597. /** @hidden */
  98598. export var pbrPixelShader: {
  98599. name: string;
  98600. shader: string;
  98601. };
  98602. }
  98603. declare module BABYLON {
  98604. /** @hidden */
  98605. export var pbrVertexDeclaration: {
  98606. name: string;
  98607. shader: string;
  98608. };
  98609. }
  98610. declare module BABYLON {
  98611. /** @hidden */
  98612. export var pbrVertexShader: {
  98613. name: string;
  98614. shader: string;
  98615. };
  98616. }
  98617. declare module BABYLON {
  98618. /**
  98619. * The Physically based material base class of BJS.
  98620. *
  98621. * This offers the main features of a standard PBR material.
  98622. * For more information, please refer to the documentation :
  98623. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  98624. */
  98625. export abstract class PBRBaseMaterial extends PushMaterial {
  98626. /**
  98627. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  98628. */
  98629. static readonly PBRMATERIAL_OPAQUE: number;
  98630. /**
  98631. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  98632. */
  98633. static readonly PBRMATERIAL_ALPHATEST: number;
  98634. /**
  98635. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98636. */
  98637. static readonly PBRMATERIAL_ALPHABLEND: number;
  98638. /**
  98639. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  98640. * They are also discarded below the alpha cutoff threshold to improve performances.
  98641. */
  98642. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  98643. /**
  98644. * Defines the default value of how much AO map is occluding the analytical lights
  98645. * (point spot...).
  98646. */
  98647. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  98648. /**
  98649. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  98650. */
  98651. static readonly LIGHTFALLOFF_PHYSICAL: number;
  98652. /**
  98653. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  98654. * to enhance interoperability with other engines.
  98655. */
  98656. static readonly LIGHTFALLOFF_GLTF: number;
  98657. /**
  98658. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  98659. * to enhance interoperability with other materials.
  98660. */
  98661. static readonly LIGHTFALLOFF_STANDARD: number;
  98662. /**
  98663. * Intensity of the direct lights e.g. the four lights available in your scene.
  98664. * This impacts both the direct diffuse and specular highlights.
  98665. */
  98666. protected _directIntensity: number;
  98667. /**
  98668. * Intensity of the emissive part of the material.
  98669. * This helps controlling the emissive effect without modifying the emissive color.
  98670. */
  98671. protected _emissiveIntensity: number;
  98672. /**
  98673. * Intensity of the environment e.g. how much the environment will light the object
  98674. * either through harmonics for rough material or through the refelction for shiny ones.
  98675. */
  98676. protected _environmentIntensity: number;
  98677. /**
  98678. * This is a special control allowing the reduction of the specular highlights coming from the
  98679. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  98680. */
  98681. protected _specularIntensity: number;
  98682. /**
  98683. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  98684. */
  98685. private _lightingInfos;
  98686. /**
  98687. * Debug Control allowing disabling the bump map on this material.
  98688. */
  98689. protected _disableBumpMap: boolean;
  98690. /**
  98691. * AKA Diffuse Texture in standard nomenclature.
  98692. */
  98693. protected _albedoTexture: BaseTexture;
  98694. /**
  98695. * AKA Occlusion Texture in other nomenclature.
  98696. */
  98697. protected _ambientTexture: BaseTexture;
  98698. /**
  98699. * AKA Occlusion Texture Intensity in other nomenclature.
  98700. */
  98701. protected _ambientTextureStrength: number;
  98702. /**
  98703. * Defines how much the AO map is occluding the analytical lights (point spot...).
  98704. * 1 means it completely occludes it
  98705. * 0 mean it has no impact
  98706. */
  98707. protected _ambientTextureImpactOnAnalyticalLights: number;
  98708. /**
  98709. * Stores the alpha values in a texture.
  98710. */
  98711. protected _opacityTexture: BaseTexture;
  98712. /**
  98713. * Stores the reflection values in a texture.
  98714. */
  98715. protected _reflectionTexture: BaseTexture;
  98716. /**
  98717. * Stores the refraction values in a texture.
  98718. */
  98719. protected _refractionTexture: BaseTexture;
  98720. /**
  98721. * Stores the emissive values in a texture.
  98722. */
  98723. protected _emissiveTexture: BaseTexture;
  98724. /**
  98725. * AKA Specular texture in other nomenclature.
  98726. */
  98727. protected _reflectivityTexture: BaseTexture;
  98728. /**
  98729. * Used to switch from specular/glossiness to metallic/roughness workflow.
  98730. */
  98731. protected _metallicTexture: BaseTexture;
  98732. /**
  98733. * Specifies the metallic scalar of the metallic/roughness workflow.
  98734. * Can also be used to scale the metalness values of the metallic texture.
  98735. */
  98736. protected _metallic: Nullable<number>;
  98737. /**
  98738. * Specifies the roughness scalar of the metallic/roughness workflow.
  98739. * Can also be used to scale the roughness values of the metallic texture.
  98740. */
  98741. protected _roughness: Nullable<number>;
  98742. /**
  98743. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  98744. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  98745. */
  98746. protected _microSurfaceTexture: BaseTexture;
  98747. /**
  98748. * Stores surface normal data used to displace a mesh in a texture.
  98749. */
  98750. protected _bumpTexture: BaseTexture;
  98751. /**
  98752. * Stores the pre-calculated light information of a mesh in a texture.
  98753. */
  98754. protected _lightmapTexture: BaseTexture;
  98755. /**
  98756. * The color of a material in ambient lighting.
  98757. */
  98758. protected _ambientColor: Color3;
  98759. /**
  98760. * AKA Diffuse Color in other nomenclature.
  98761. */
  98762. protected _albedoColor: Color3;
  98763. /**
  98764. * AKA Specular Color in other nomenclature.
  98765. */
  98766. protected _reflectivityColor: Color3;
  98767. /**
  98768. * The color applied when light is reflected from a material.
  98769. */
  98770. protected _reflectionColor: Color3;
  98771. /**
  98772. * The color applied when light is emitted from a material.
  98773. */
  98774. protected _emissiveColor: Color3;
  98775. /**
  98776. * AKA Glossiness in other nomenclature.
  98777. */
  98778. protected _microSurface: number;
  98779. /**
  98780. * source material index of refraction (IOR)' / 'destination material IOR.
  98781. */
  98782. protected _indexOfRefraction: number;
  98783. /**
  98784. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  98785. */
  98786. protected _invertRefractionY: boolean;
  98787. /**
  98788. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  98789. * Materials half opaque for instance using refraction could benefit from this control.
  98790. */
  98791. protected _linkRefractionWithTransparency: boolean;
  98792. /**
  98793. * Specifies that the material will use the light map as a show map.
  98794. */
  98795. protected _useLightmapAsShadowmap: boolean;
  98796. /**
  98797. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  98798. * makes the reflect vector face the model (under horizon).
  98799. */
  98800. protected _useHorizonOcclusion: boolean;
  98801. /**
  98802. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  98803. * too much the area relying on ambient texture to define their ambient occlusion.
  98804. */
  98805. protected _useRadianceOcclusion: boolean;
  98806. /**
  98807. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  98808. */
  98809. protected _useAlphaFromAlbedoTexture: boolean;
  98810. /**
  98811. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  98812. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98813. */
  98814. protected _useSpecularOverAlpha: boolean;
  98815. /**
  98816. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  98817. */
  98818. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  98819. /**
  98820. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  98821. */
  98822. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  98823. /**
  98824. * Specifies if the metallic texture contains the roughness information in its green channel.
  98825. */
  98826. protected _useRoughnessFromMetallicTextureGreen: boolean;
  98827. /**
  98828. * Specifies if the metallic texture contains the metallness information in its blue channel.
  98829. */
  98830. protected _useMetallnessFromMetallicTextureBlue: boolean;
  98831. /**
  98832. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  98833. */
  98834. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  98835. /**
  98836. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  98837. */
  98838. protected _useAmbientInGrayScale: boolean;
  98839. /**
  98840. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  98841. * The material will try to infer what glossiness each pixel should be.
  98842. */
  98843. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  98844. /**
  98845. * Defines the falloff type used in this material.
  98846. * It by default is Physical.
  98847. */
  98848. protected _lightFalloff: number;
  98849. /**
  98850. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98851. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98852. */
  98853. protected _useRadianceOverAlpha: boolean;
  98854. /**
  98855. * Allows using an object space normal map (instead of tangent space).
  98856. */
  98857. protected _useObjectSpaceNormalMap: boolean;
  98858. /**
  98859. * Allows using the bump map in parallax mode.
  98860. */
  98861. protected _useParallax: boolean;
  98862. /**
  98863. * Allows using the bump map in parallax occlusion mode.
  98864. */
  98865. protected _useParallaxOcclusion: boolean;
  98866. /**
  98867. * Controls the scale bias of the parallax mode.
  98868. */
  98869. protected _parallaxScaleBias: number;
  98870. /**
  98871. * If sets to true, disables all the lights affecting the material.
  98872. */
  98873. protected _disableLighting: boolean;
  98874. /**
  98875. * Number of Simultaneous lights allowed on the material.
  98876. */
  98877. protected _maxSimultaneousLights: number;
  98878. /**
  98879. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  98880. */
  98881. protected _invertNormalMapX: boolean;
  98882. /**
  98883. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  98884. */
  98885. protected _invertNormalMapY: boolean;
  98886. /**
  98887. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98888. */
  98889. protected _twoSidedLighting: boolean;
  98890. /**
  98891. * Defines the alpha limits in alpha test mode.
  98892. */
  98893. protected _alphaCutOff: number;
  98894. /**
  98895. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  98896. */
  98897. protected _forceAlphaTest: boolean;
  98898. /**
  98899. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98900. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  98901. */
  98902. protected _useAlphaFresnel: boolean;
  98903. /**
  98904. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  98905. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  98906. */
  98907. protected _useLinearAlphaFresnel: boolean;
  98908. /**
  98909. * The transparency mode of the material.
  98910. */
  98911. protected _transparencyMode: Nullable<number>;
  98912. /**
  98913. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  98914. * from cos thetav and roughness:
  98915. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  98916. */
  98917. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  98918. /**
  98919. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  98920. */
  98921. protected _forceIrradianceInFragment: boolean;
  98922. /**
  98923. * Force normal to face away from face.
  98924. */
  98925. protected _forceNormalForward: boolean;
  98926. /**
  98927. * Enables specular anti aliasing in the PBR shader.
  98928. * It will both interacts on the Geometry for analytical and IBL lighting.
  98929. * It also prefilter the roughness map based on the bump values.
  98930. */
  98931. protected _enableSpecularAntiAliasing: boolean;
  98932. /**
  98933. * Default configuration related to image processing available in the PBR Material.
  98934. */
  98935. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98936. /**
  98937. * Keep track of the image processing observer to allow dispose and replace.
  98938. */
  98939. private _imageProcessingObserver;
  98940. /**
  98941. * Attaches a new image processing configuration to the PBR Material.
  98942. * @param configuration
  98943. */
  98944. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98945. /**
  98946. * Stores the available render targets.
  98947. */
  98948. private _renderTargets;
  98949. /**
  98950. * Sets the global ambient color for the material used in lighting calculations.
  98951. */
  98952. private _globalAmbientColor;
  98953. /**
  98954. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  98955. */
  98956. private _useLogarithmicDepth;
  98957. /**
  98958. * If set to true, no lighting calculations will be applied.
  98959. */
  98960. private _unlit;
  98961. /**
  98962. * Instantiates a new PBRMaterial instance.
  98963. *
  98964. * @param name The material name
  98965. * @param scene The scene the material will be use in.
  98966. */
  98967. constructor(name: string, scene: Scene);
  98968. /**
  98969. * Gets a boolean indicating that current material needs to register RTT
  98970. */
  98971. readonly hasRenderTargetTextures: boolean;
  98972. /**
  98973. * Gets the name of the material class.
  98974. */
  98975. getClassName(): string;
  98976. /**
  98977. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  98978. */
  98979. /**
  98980. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  98981. */
  98982. useLogarithmicDepth: boolean;
  98983. /**
  98984. * Gets the current transparency mode.
  98985. */
  98986. /**
  98987. * Sets the transparency mode of the material.
  98988. *
  98989. * | Value | Type | Description |
  98990. * | ----- | ----------------------------------- | ----------- |
  98991. * | 0 | OPAQUE | |
  98992. * | 1 | ALPHATEST | |
  98993. * | 2 | ALPHABLEND | |
  98994. * | 3 | ALPHATESTANDBLEND | |
  98995. *
  98996. */
  98997. transparencyMode: Nullable<number>;
  98998. /**
  98999. * Returns true if alpha blending should be disabled.
  99000. */
  99001. private readonly _disableAlphaBlending;
  99002. /**
  99003. * Specifies whether or not this material should be rendered in alpha blend mode.
  99004. */
  99005. needAlphaBlending(): boolean;
  99006. /**
  99007. * Specifies if the mesh will require alpha blending.
  99008. * @param mesh - BJS mesh.
  99009. */
  99010. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  99011. /**
  99012. * Specifies whether or not this material should be rendered in alpha test mode.
  99013. */
  99014. needAlphaTesting(): boolean;
  99015. /**
  99016. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  99017. */
  99018. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  99019. /**
  99020. * Gets the texture used for the alpha test.
  99021. */
  99022. getAlphaTestTexture(): BaseTexture;
  99023. /**
  99024. * Specifies that the submesh is ready to be used.
  99025. * @param mesh - BJS mesh.
  99026. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  99027. * @param useInstances - Specifies that instances should be used.
  99028. * @returns - boolean indicating that the submesh is ready or not.
  99029. */
  99030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99031. /**
  99032. * Specifies if the material uses metallic roughness workflow.
  99033. * @returns boolean specifiying if the material uses metallic roughness workflow.
  99034. */
  99035. isMetallicWorkflow(): boolean;
  99036. private _prepareEffect;
  99037. private _prepareDefines;
  99038. /**
  99039. * Force shader compilation
  99040. */
  99041. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  99042. clipPlane: boolean;
  99043. }>): void;
  99044. /**
  99045. * Initializes the uniform buffer layout for the shader.
  99046. */
  99047. buildUniformLayout(): void;
  99048. /**
  99049. * Unbinds the textures.
  99050. */
  99051. unbind(): void;
  99052. /**
  99053. * Binds the submesh data.
  99054. * @param world - The world matrix.
  99055. * @param mesh - The BJS mesh.
  99056. * @param subMesh - A submesh of the BJS mesh.
  99057. */
  99058. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99059. /**
  99060. * Returns the animatable textures.
  99061. * @returns - Array of animatable textures.
  99062. */
  99063. getAnimatables(): IAnimatable[];
  99064. /**
  99065. * Returns the texture used for reflections.
  99066. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  99067. */
  99068. private _getReflectionTexture;
  99069. /**
  99070. * Returns the texture used for refraction or null if none is used.
  99071. * @returns - Refection texture if present. If no refraction texture and refraction
  99072. * is linked with transparency, returns environment texture. Otherwise, returns null.
  99073. */
  99074. private _getRefractionTexture;
  99075. /**
  99076. * Disposes the resources of the material.
  99077. * @param forceDisposeEffect - Forces the disposal of effects.
  99078. * @param forceDisposeTextures - Forces the disposal of all textures.
  99079. */
  99080. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  99081. }
  99082. }
  99083. declare module BABYLON {
  99084. /**
  99085. * The Physically based material of BJS.
  99086. *
  99087. * This offers the main features of a standard PBR material.
  99088. * For more information, please refer to the documentation :
  99089. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  99090. */
  99091. export class PBRMaterial extends PBRBaseMaterial {
  99092. /**
  99093. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  99094. */
  99095. static readonly PBRMATERIAL_OPAQUE: number;
  99096. /**
  99097. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  99098. */
  99099. static readonly PBRMATERIAL_ALPHATEST: number;
  99100. /**
  99101. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99102. */
  99103. static readonly PBRMATERIAL_ALPHABLEND: number;
  99104. /**
  99105. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  99106. * They are also discarded below the alpha cutoff threshold to improve performances.
  99107. */
  99108. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  99109. /**
  99110. * Defines the default value of how much AO map is occluding the analytical lights
  99111. * (point spot...).
  99112. */
  99113. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  99114. /**
  99115. * Intensity of the direct lights e.g. the four lights available in your scene.
  99116. * This impacts both the direct diffuse and specular highlights.
  99117. */
  99118. directIntensity: number;
  99119. /**
  99120. * Intensity of the emissive part of the material.
  99121. * This helps controlling the emissive effect without modifying the emissive color.
  99122. */
  99123. emissiveIntensity: number;
  99124. /**
  99125. * Intensity of the environment e.g. how much the environment will light the object
  99126. * either through harmonics for rough material or through the refelction for shiny ones.
  99127. */
  99128. environmentIntensity: number;
  99129. /**
  99130. * This is a special control allowing the reduction of the specular highlights coming from the
  99131. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  99132. */
  99133. specularIntensity: number;
  99134. /**
  99135. * Debug Control allowing disabling the bump map on this material.
  99136. */
  99137. disableBumpMap: boolean;
  99138. /**
  99139. * AKA Diffuse Texture in standard nomenclature.
  99140. */
  99141. albedoTexture: BaseTexture;
  99142. /**
  99143. * AKA Occlusion Texture in other nomenclature.
  99144. */
  99145. ambientTexture: BaseTexture;
  99146. /**
  99147. * AKA Occlusion Texture Intensity in other nomenclature.
  99148. */
  99149. ambientTextureStrength: number;
  99150. /**
  99151. * Defines how much the AO map is occluding the analytical lights (point spot...).
  99152. * 1 means it completely occludes it
  99153. * 0 mean it has no impact
  99154. */
  99155. ambientTextureImpactOnAnalyticalLights: number;
  99156. /**
  99157. * Stores the alpha values in a texture.
  99158. */
  99159. opacityTexture: BaseTexture;
  99160. /**
  99161. * Stores the reflection values in a texture.
  99162. */
  99163. reflectionTexture: Nullable<BaseTexture>;
  99164. /**
  99165. * Stores the emissive values in a texture.
  99166. */
  99167. emissiveTexture: BaseTexture;
  99168. /**
  99169. * AKA Specular texture in other nomenclature.
  99170. */
  99171. reflectivityTexture: BaseTexture;
  99172. /**
  99173. * Used to switch from specular/glossiness to metallic/roughness workflow.
  99174. */
  99175. metallicTexture: BaseTexture;
  99176. /**
  99177. * Specifies the metallic scalar of the metallic/roughness workflow.
  99178. * Can also be used to scale the metalness values of the metallic texture.
  99179. */
  99180. metallic: Nullable<number>;
  99181. /**
  99182. * Specifies the roughness scalar of the metallic/roughness workflow.
  99183. * Can also be used to scale the roughness values of the metallic texture.
  99184. */
  99185. roughness: Nullable<number>;
  99186. /**
  99187. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  99188. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  99189. */
  99190. microSurfaceTexture: BaseTexture;
  99191. /**
  99192. * Stores surface normal data used to displace a mesh in a texture.
  99193. */
  99194. bumpTexture: BaseTexture;
  99195. /**
  99196. * Stores the pre-calculated light information of a mesh in a texture.
  99197. */
  99198. lightmapTexture: BaseTexture;
  99199. /**
  99200. * Stores the refracted light information in a texture.
  99201. */
  99202. refractionTexture: BaseTexture;
  99203. /**
  99204. * The color of a material in ambient lighting.
  99205. */
  99206. ambientColor: Color3;
  99207. /**
  99208. * AKA Diffuse Color in other nomenclature.
  99209. */
  99210. albedoColor: Color3;
  99211. /**
  99212. * AKA Specular Color in other nomenclature.
  99213. */
  99214. reflectivityColor: Color3;
  99215. /**
  99216. * The color reflected from the material.
  99217. */
  99218. reflectionColor: Color3;
  99219. /**
  99220. * The color emitted from the material.
  99221. */
  99222. emissiveColor: Color3;
  99223. /**
  99224. * AKA Glossiness in other nomenclature.
  99225. */
  99226. microSurface: number;
  99227. /**
  99228. * source material index of refraction (IOR)' / 'destination material IOR.
  99229. */
  99230. indexOfRefraction: number;
  99231. /**
  99232. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99233. */
  99234. invertRefractionY: boolean;
  99235. /**
  99236. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99237. * Materials half opaque for instance using refraction could benefit from this control.
  99238. */
  99239. linkRefractionWithTransparency: boolean;
  99240. /**
  99241. * If true, the light map contains occlusion information instead of lighting info.
  99242. */
  99243. useLightmapAsShadowmap: boolean;
  99244. /**
  99245. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  99246. */
  99247. useAlphaFromAlbedoTexture: boolean;
  99248. /**
  99249. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  99250. */
  99251. forceAlphaTest: boolean;
  99252. /**
  99253. * Defines the alpha limits in alpha test mode.
  99254. */
  99255. alphaCutOff: number;
  99256. /**
  99257. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99258. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99259. */
  99260. useSpecularOverAlpha: boolean;
  99261. /**
  99262. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  99263. */
  99264. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  99265. /**
  99266. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  99267. */
  99268. useRoughnessFromMetallicTextureAlpha: boolean;
  99269. /**
  99270. * Specifies if the metallic texture contains the roughness information in its green channel.
  99271. */
  99272. useRoughnessFromMetallicTextureGreen: boolean;
  99273. /**
  99274. * Specifies if the metallic texture contains the metallness information in its blue channel.
  99275. */
  99276. useMetallnessFromMetallicTextureBlue: boolean;
  99277. /**
  99278. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  99279. */
  99280. useAmbientOcclusionFromMetallicTextureRed: boolean;
  99281. /**
  99282. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  99283. */
  99284. useAmbientInGrayScale: boolean;
  99285. /**
  99286. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  99287. * The material will try to infer what glossiness each pixel should be.
  99288. */
  99289. useAutoMicroSurfaceFromReflectivityMap: boolean;
  99290. /**
  99291. * BJS is using an harcoded light falloff based on a manually sets up range.
  99292. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99293. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99294. */
  99295. /**
  99296. * BJS is using an harcoded light falloff based on a manually sets up range.
  99297. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  99298. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  99299. */
  99300. usePhysicalLightFalloff: boolean;
  99301. /**
  99302. * In order to support the falloff compatibility with gltf, a special mode has been added
  99303. * to reproduce the gltf light falloff.
  99304. */
  99305. /**
  99306. * In order to support the falloff compatibility with gltf, a special mode has been added
  99307. * to reproduce the gltf light falloff.
  99308. */
  99309. useGLTFLightFalloff: boolean;
  99310. /**
  99311. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99312. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99313. */
  99314. useRadianceOverAlpha: boolean;
  99315. /**
  99316. * Allows using an object space normal map (instead of tangent space).
  99317. */
  99318. useObjectSpaceNormalMap: boolean;
  99319. /**
  99320. * Allows using the bump map in parallax mode.
  99321. */
  99322. useParallax: boolean;
  99323. /**
  99324. * Allows using the bump map in parallax occlusion mode.
  99325. */
  99326. useParallaxOcclusion: boolean;
  99327. /**
  99328. * Controls the scale bias of the parallax mode.
  99329. */
  99330. parallaxScaleBias: number;
  99331. /**
  99332. * If sets to true, disables all the lights affecting the material.
  99333. */
  99334. disableLighting: boolean;
  99335. /**
  99336. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  99337. */
  99338. forceIrradianceInFragment: boolean;
  99339. /**
  99340. * Number of Simultaneous lights allowed on the material.
  99341. */
  99342. maxSimultaneousLights: number;
  99343. /**
  99344. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99345. */
  99346. invertNormalMapX: boolean;
  99347. /**
  99348. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99349. */
  99350. invertNormalMapY: boolean;
  99351. /**
  99352. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99353. */
  99354. twoSidedLighting: boolean;
  99355. /**
  99356. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99357. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  99358. */
  99359. useAlphaFresnel: boolean;
  99360. /**
  99361. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99362. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  99363. */
  99364. useLinearAlphaFresnel: boolean;
  99365. /**
  99366. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  99367. * And/Or occlude the blended part.
  99368. */
  99369. environmentBRDFTexture: Nullable<BaseTexture>;
  99370. /**
  99371. * Force normal to face away from face.
  99372. */
  99373. forceNormalForward: boolean;
  99374. /**
  99375. * Enables specular anti aliasing in the PBR shader.
  99376. * It will both interacts on the Geometry for analytical and IBL lighting.
  99377. * It also prefilter the roughness map based on the bump values.
  99378. */
  99379. enableSpecularAntiAliasing: boolean;
  99380. /**
  99381. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  99382. * makes the reflect vector face the model (under horizon).
  99383. */
  99384. useHorizonOcclusion: boolean;
  99385. /**
  99386. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  99387. * too much the area relying on ambient texture to define their ambient occlusion.
  99388. */
  99389. useRadianceOcclusion: boolean;
  99390. /**
  99391. * If set to true, no lighting calculations will be applied.
  99392. */
  99393. unlit: boolean;
  99394. /**
  99395. * Gets the image processing configuration used either in this material.
  99396. */
  99397. /**
  99398. * Sets the Default image processing configuration used either in the this material.
  99399. *
  99400. * If sets to null, the scene one is in use.
  99401. */
  99402. imageProcessingConfiguration: ImageProcessingConfiguration;
  99403. /**
  99404. * Gets wether the color curves effect is enabled.
  99405. */
  99406. /**
  99407. * Sets wether the color curves effect is enabled.
  99408. */
  99409. cameraColorCurvesEnabled: boolean;
  99410. /**
  99411. * Gets wether the color grading effect is enabled.
  99412. */
  99413. /**
  99414. * Gets wether the color grading effect is enabled.
  99415. */
  99416. cameraColorGradingEnabled: boolean;
  99417. /**
  99418. * Gets wether tonemapping is enabled or not.
  99419. */
  99420. /**
  99421. * Sets wether tonemapping is enabled or not
  99422. */
  99423. cameraToneMappingEnabled: boolean;
  99424. /**
  99425. * The camera exposure used on this material.
  99426. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99427. * This corresponds to a photographic exposure.
  99428. */
  99429. /**
  99430. * The camera exposure used on this material.
  99431. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99432. * This corresponds to a photographic exposure.
  99433. */
  99434. cameraExposure: number;
  99435. /**
  99436. * Gets The camera contrast used on this material.
  99437. */
  99438. /**
  99439. * Sets The camera contrast used on this material.
  99440. */
  99441. cameraContrast: number;
  99442. /**
  99443. * Gets the Color Grading 2D Lookup Texture.
  99444. */
  99445. /**
  99446. * Sets the Color Grading 2D Lookup Texture.
  99447. */
  99448. cameraColorGradingTexture: Nullable<BaseTexture>;
  99449. /**
  99450. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99451. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99452. * 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;
  99453. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99454. */
  99455. /**
  99456. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99457. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99458. * 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;
  99459. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99460. */
  99461. cameraColorCurves: Nullable<ColorCurves>;
  99462. /**
  99463. * Instantiates a new PBRMaterial instance.
  99464. *
  99465. * @param name The material name
  99466. * @param scene The scene the material will be use in.
  99467. */
  99468. constructor(name: string, scene: Scene);
  99469. /**
  99470. * Returns the name of this material class.
  99471. */
  99472. getClassName(): string;
  99473. /**
  99474. * Returns an array of the actively used textures.
  99475. * @returns - Array of BaseTextures
  99476. */
  99477. getActiveTextures(): BaseTexture[];
  99478. /**
  99479. * Checks to see if a texture is used in the material.
  99480. * @param texture - Base texture to use.
  99481. * @returns - Boolean specifying if a texture is used in the material.
  99482. */
  99483. hasTexture(texture: BaseTexture): boolean;
  99484. /**
  99485. * Makes a duplicate of the current material.
  99486. * @param name - name to use for the new material.
  99487. */
  99488. clone(name: string): PBRMaterial;
  99489. /**
  99490. * Serializes this PBR Material.
  99491. * @returns - An object with the serialized material.
  99492. */
  99493. serialize(): any;
  99494. /**
  99495. * Parses a PBR Material from a serialized object.
  99496. * @param source - Serialized object.
  99497. * @param scene - BJS scene instance.
  99498. * @param rootUrl - url for the scene object
  99499. * @returns - PBRMaterial
  99500. */
  99501. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  99502. }
  99503. }
  99504. declare module BABYLON {
  99505. /** @hidden */
  99506. export var _forceSceneHelpersToBundle: boolean;
  99507. interface Scene {
  99508. /**
  99509. * Creates a default light for the scene.
  99510. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  99511. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  99512. */
  99513. createDefaultLight(replace?: boolean): void;
  99514. /**
  99515. * Creates a default camera for the scene.
  99516. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  99517. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99518. * @param replace has default false, when true replaces the active camera in the scene
  99519. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  99520. */
  99521. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99522. /**
  99523. * Creates a default camera and a default light.
  99524. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  99525. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  99526. * @param replace has the default false, when true replaces the active camera/light in the scene
  99527. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  99528. */
  99529. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  99530. /**
  99531. * Creates a new sky box
  99532. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  99533. * @param environmentTexture defines the texture to use as environment texture
  99534. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  99535. * @param scale defines the overall scale of the skybox
  99536. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  99537. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  99538. * @returns a new mesh holding the sky box
  99539. */
  99540. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  99541. /**
  99542. * Creates a new environment
  99543. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  99544. * @param options defines the options you can use to configure the environment
  99545. * @returns the new EnvironmentHelper
  99546. */
  99547. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  99548. /**
  99549. * Creates a new VREXperienceHelper
  99550. * @see http://doc.babylonjs.com/how_to/webvr_helper
  99551. * @param webVROptions defines the options used to create the new VREXperienceHelper
  99552. * @returns a new VREXperienceHelper
  99553. */
  99554. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  99555. /**
  99556. * Creates a new XREXperienceHelper
  99557. * @see http://doc.babylonjs.com/how_to/webxr
  99558. * @returns a promise for a new XREXperienceHelper
  99559. */
  99560. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  99561. }
  99562. }
  99563. declare module BABYLON {
  99564. /**
  99565. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  99566. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  99567. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  99568. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  99569. */
  99570. export class VideoDome extends TransformNode {
  99571. private _useDirectMapping;
  99572. /**
  99573. * The video texture being displayed on the sphere
  99574. */
  99575. protected _videoTexture: VideoTexture;
  99576. /**
  99577. * Gets the video texture being displayed on the sphere
  99578. */
  99579. readonly videoTexture: VideoTexture;
  99580. /**
  99581. * The skybox material
  99582. */
  99583. protected _material: BackgroundMaterial;
  99584. /**
  99585. * The surface used for the skybox
  99586. */
  99587. protected _mesh: Mesh;
  99588. /**
  99589. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  99590. * Also see the options.resolution property.
  99591. */
  99592. fovMultiplier: number;
  99593. /**
  99594. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  99595. * @param name Element's name, child elements will append suffixes for their own names.
  99596. * @param urlsOrVideo defines the url(s) or the video element to use
  99597. * @param options An object containing optional or exposed sub element properties
  99598. */
  99599. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  99600. resolution?: number;
  99601. clickToPlay?: boolean;
  99602. autoPlay?: boolean;
  99603. loop?: boolean;
  99604. size?: number;
  99605. poster?: string;
  99606. useDirectMapping?: boolean;
  99607. }, scene: Scene);
  99608. /**
  99609. * Releases resources associated with this node.
  99610. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99611. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99612. */
  99613. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99614. }
  99615. }
  99616. declare module BABYLON {
  99617. /**
  99618. * This class can be used to get instrumentation data from a Babylon engine
  99619. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99620. */
  99621. export class EngineInstrumentation implements IDisposable {
  99622. /**
  99623. * Define the instrumented engine.
  99624. */
  99625. engine: Engine;
  99626. private _captureGPUFrameTime;
  99627. private _gpuFrameTimeToken;
  99628. private _gpuFrameTime;
  99629. private _captureShaderCompilationTime;
  99630. private _shaderCompilationTime;
  99631. private _onBeginFrameObserver;
  99632. private _onEndFrameObserver;
  99633. private _onBeforeShaderCompilationObserver;
  99634. private _onAfterShaderCompilationObserver;
  99635. /**
  99636. * Gets the perf counter used for GPU frame time
  99637. */
  99638. readonly gpuFrameTimeCounter: PerfCounter;
  99639. /**
  99640. * Gets the GPU frame time capture status
  99641. */
  99642. /**
  99643. * Enable or disable the GPU frame time capture
  99644. */
  99645. captureGPUFrameTime: boolean;
  99646. /**
  99647. * Gets the perf counter used for shader compilation time
  99648. */
  99649. readonly shaderCompilationTimeCounter: PerfCounter;
  99650. /**
  99651. * Gets the shader compilation time capture status
  99652. */
  99653. /**
  99654. * Enable or disable the shader compilation time capture
  99655. */
  99656. captureShaderCompilationTime: boolean;
  99657. /**
  99658. * Instantiates a new engine instrumentation.
  99659. * This class can be used to get instrumentation data from a Babylon engine
  99660. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  99661. * @param engine Defines the engine to instrument
  99662. */
  99663. constructor(
  99664. /**
  99665. * Define the instrumented engine.
  99666. */
  99667. engine: Engine);
  99668. /**
  99669. * Dispose and release associated resources.
  99670. */
  99671. dispose(): void;
  99672. }
  99673. }
  99674. declare module BABYLON {
  99675. /**
  99676. * This class can be used to get instrumentation data from a Babylon engine
  99677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99678. */
  99679. export class SceneInstrumentation implements IDisposable {
  99680. /**
  99681. * Defines the scene to instrument
  99682. */
  99683. scene: Scene;
  99684. private _captureActiveMeshesEvaluationTime;
  99685. private _activeMeshesEvaluationTime;
  99686. private _captureRenderTargetsRenderTime;
  99687. private _renderTargetsRenderTime;
  99688. private _captureFrameTime;
  99689. private _frameTime;
  99690. private _captureRenderTime;
  99691. private _renderTime;
  99692. private _captureInterFrameTime;
  99693. private _interFrameTime;
  99694. private _captureParticlesRenderTime;
  99695. private _particlesRenderTime;
  99696. private _captureSpritesRenderTime;
  99697. private _spritesRenderTime;
  99698. private _capturePhysicsTime;
  99699. private _physicsTime;
  99700. private _captureAnimationsTime;
  99701. private _animationsTime;
  99702. private _captureCameraRenderTime;
  99703. private _cameraRenderTime;
  99704. private _onBeforeActiveMeshesEvaluationObserver;
  99705. private _onAfterActiveMeshesEvaluationObserver;
  99706. private _onBeforeRenderTargetsRenderObserver;
  99707. private _onAfterRenderTargetsRenderObserver;
  99708. private _onAfterRenderObserver;
  99709. private _onBeforeDrawPhaseObserver;
  99710. private _onAfterDrawPhaseObserver;
  99711. private _onBeforeAnimationsObserver;
  99712. private _onBeforeParticlesRenderingObserver;
  99713. private _onAfterParticlesRenderingObserver;
  99714. private _onBeforeSpritesRenderingObserver;
  99715. private _onAfterSpritesRenderingObserver;
  99716. private _onBeforePhysicsObserver;
  99717. private _onAfterPhysicsObserver;
  99718. private _onAfterAnimationsObserver;
  99719. private _onBeforeCameraRenderObserver;
  99720. private _onAfterCameraRenderObserver;
  99721. /**
  99722. * Gets the perf counter used for active meshes evaluation time
  99723. */
  99724. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  99725. /**
  99726. * Gets the active meshes evaluation time capture status
  99727. */
  99728. /**
  99729. * Enable or disable the active meshes evaluation time capture
  99730. */
  99731. captureActiveMeshesEvaluationTime: boolean;
  99732. /**
  99733. * Gets the perf counter used for render targets render time
  99734. */
  99735. readonly renderTargetsRenderTimeCounter: PerfCounter;
  99736. /**
  99737. * Gets the render targets render time capture status
  99738. */
  99739. /**
  99740. * Enable or disable the render targets render time capture
  99741. */
  99742. captureRenderTargetsRenderTime: boolean;
  99743. /**
  99744. * Gets the perf counter used for particles render time
  99745. */
  99746. readonly particlesRenderTimeCounter: PerfCounter;
  99747. /**
  99748. * Gets the particles render time capture status
  99749. */
  99750. /**
  99751. * Enable or disable the particles render time capture
  99752. */
  99753. captureParticlesRenderTime: boolean;
  99754. /**
  99755. * Gets the perf counter used for sprites render time
  99756. */
  99757. readonly spritesRenderTimeCounter: PerfCounter;
  99758. /**
  99759. * Gets the sprites render time capture status
  99760. */
  99761. /**
  99762. * Enable or disable the sprites render time capture
  99763. */
  99764. captureSpritesRenderTime: boolean;
  99765. /**
  99766. * Gets the perf counter used for physics time
  99767. */
  99768. readonly physicsTimeCounter: PerfCounter;
  99769. /**
  99770. * Gets the physics time capture status
  99771. */
  99772. /**
  99773. * Enable or disable the physics time capture
  99774. */
  99775. capturePhysicsTime: boolean;
  99776. /**
  99777. * Gets the perf counter used for animations time
  99778. */
  99779. readonly animationsTimeCounter: PerfCounter;
  99780. /**
  99781. * Gets the animations time capture status
  99782. */
  99783. /**
  99784. * Enable or disable the animations time capture
  99785. */
  99786. captureAnimationsTime: boolean;
  99787. /**
  99788. * Gets the perf counter used for frame time capture
  99789. */
  99790. readonly frameTimeCounter: PerfCounter;
  99791. /**
  99792. * Gets the frame time capture status
  99793. */
  99794. /**
  99795. * Enable or disable the frame time capture
  99796. */
  99797. captureFrameTime: boolean;
  99798. /**
  99799. * Gets the perf counter used for inter-frames time capture
  99800. */
  99801. readonly interFrameTimeCounter: PerfCounter;
  99802. /**
  99803. * Gets the inter-frames time capture status
  99804. */
  99805. /**
  99806. * Enable or disable the inter-frames time capture
  99807. */
  99808. captureInterFrameTime: boolean;
  99809. /**
  99810. * Gets the perf counter used for render time capture
  99811. */
  99812. readonly renderTimeCounter: PerfCounter;
  99813. /**
  99814. * Gets the render time capture status
  99815. */
  99816. /**
  99817. * Enable or disable the render time capture
  99818. */
  99819. captureRenderTime: boolean;
  99820. /**
  99821. * Gets the perf counter used for camera render time capture
  99822. */
  99823. readonly cameraRenderTimeCounter: PerfCounter;
  99824. /**
  99825. * Gets the camera render time capture status
  99826. */
  99827. /**
  99828. * Enable or disable the camera render time capture
  99829. */
  99830. captureCameraRenderTime: boolean;
  99831. /**
  99832. * Gets the perf counter used for draw calls
  99833. */
  99834. readonly drawCallsCounter: PerfCounter;
  99835. /**
  99836. * Gets the perf counter used for texture collisions
  99837. */
  99838. readonly textureCollisionsCounter: PerfCounter;
  99839. /**
  99840. * Instantiates a new scene instrumentation.
  99841. * This class can be used to get instrumentation data from a Babylon engine
  99842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  99843. * @param scene Defines the scene to instrument
  99844. */
  99845. constructor(
  99846. /**
  99847. * Defines the scene to instrument
  99848. */
  99849. scene: Scene);
  99850. /**
  99851. * Dispose and release associated resources.
  99852. */
  99853. dispose(): void;
  99854. }
  99855. }
  99856. declare module BABYLON {
  99857. /** @hidden */
  99858. export var glowMapGenerationPixelShader: {
  99859. name: string;
  99860. shader: string;
  99861. };
  99862. }
  99863. declare module BABYLON {
  99864. /** @hidden */
  99865. export var glowMapGenerationVertexShader: {
  99866. name: string;
  99867. shader: string;
  99868. };
  99869. }
  99870. declare module BABYLON {
  99871. /**
  99872. * Effect layer options. This helps customizing the behaviour
  99873. * of the effect layer.
  99874. */
  99875. export interface IEffectLayerOptions {
  99876. /**
  99877. * Multiplication factor apply to the canvas size to compute the render target size
  99878. * used to generated the objects (the smaller the faster).
  99879. */
  99880. mainTextureRatio: number;
  99881. /**
  99882. * Enforces a fixed size texture to ensure effect stability across devices.
  99883. */
  99884. mainTextureFixedSize?: number;
  99885. /**
  99886. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  99887. */
  99888. alphaBlendingMode: number;
  99889. /**
  99890. * The camera attached to the layer.
  99891. */
  99892. camera: Nullable<Camera>;
  99893. /**
  99894. * The rendering group to draw the layer in.
  99895. */
  99896. renderingGroupId: number;
  99897. }
  99898. /**
  99899. * The effect layer Helps adding post process effect blended with the main pass.
  99900. *
  99901. * This can be for instance use to generate glow or higlight effects on the scene.
  99902. *
  99903. * The effect layer class can not be used directly and is intented to inherited from to be
  99904. * customized per effects.
  99905. */
  99906. export abstract class EffectLayer {
  99907. private _vertexBuffers;
  99908. private _indexBuffer;
  99909. private _cachedDefines;
  99910. private _effectLayerMapGenerationEffect;
  99911. private _effectLayerOptions;
  99912. private _mergeEffect;
  99913. protected _scene: Scene;
  99914. protected _engine: Engine;
  99915. protected _maxSize: number;
  99916. protected _mainTextureDesiredSize: ISize;
  99917. protected _mainTexture: RenderTargetTexture;
  99918. protected _shouldRender: boolean;
  99919. protected _postProcesses: PostProcess[];
  99920. protected _textures: BaseTexture[];
  99921. protected _emissiveTextureAndColor: {
  99922. texture: Nullable<BaseTexture>;
  99923. color: Color4;
  99924. };
  99925. /**
  99926. * The name of the layer
  99927. */
  99928. name: string;
  99929. /**
  99930. * The clear color of the texture used to generate the glow map.
  99931. */
  99932. neutralColor: Color4;
  99933. /**
  99934. * Specifies wether the highlight layer is enabled or not.
  99935. */
  99936. isEnabled: boolean;
  99937. /**
  99938. * Gets the camera attached to the layer.
  99939. */
  99940. readonly camera: Nullable<Camera>;
  99941. /**
  99942. * Gets the rendering group id the layer should render in.
  99943. */
  99944. readonly renderingGroupId: number;
  99945. /**
  99946. * An event triggered when the effect layer has been disposed.
  99947. */
  99948. onDisposeObservable: Observable<EffectLayer>;
  99949. /**
  99950. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  99951. */
  99952. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  99953. /**
  99954. * An event triggered when the generated texture is being merged in the scene.
  99955. */
  99956. onBeforeComposeObservable: Observable<EffectLayer>;
  99957. /**
  99958. * An event triggered when the generated texture has been merged in the scene.
  99959. */
  99960. onAfterComposeObservable: Observable<EffectLayer>;
  99961. /**
  99962. * An event triggered when the efffect layer changes its size.
  99963. */
  99964. onSizeChangedObservable: Observable<EffectLayer>;
  99965. /** @hidden */
  99966. static _SceneComponentInitialization: (scene: Scene) => void;
  99967. /**
  99968. * Instantiates a new effect Layer and references it in the scene.
  99969. * @param name The name of the layer
  99970. * @param scene The scene to use the layer in
  99971. */
  99972. constructor(
  99973. /** The Friendly of the effect in the scene */
  99974. name: string, scene: Scene);
  99975. /**
  99976. * Get the effect name of the layer.
  99977. * @return The effect name
  99978. */
  99979. abstract getEffectName(): string;
  99980. /**
  99981. * Checks for the readiness of the element composing the layer.
  99982. * @param subMesh the mesh to check for
  99983. * @param useInstances specify wether or not to use instances to render the mesh
  99984. * @return true if ready otherwise, false
  99985. */
  99986. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  99987. /**
  99988. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  99989. * @returns true if the effect requires stencil during the main canvas render pass.
  99990. */
  99991. abstract needStencil(): boolean;
  99992. /**
  99993. * Create the merge effect. This is the shader use to blit the information back
  99994. * to the main canvas at the end of the scene rendering.
  99995. * @returns The effect containing the shader used to merge the effect on the main canvas
  99996. */
  99997. protected abstract _createMergeEffect(): Effect;
  99998. /**
  99999. * Creates the render target textures and post processes used in the effect layer.
  100000. */
  100001. protected abstract _createTextureAndPostProcesses(): void;
  100002. /**
  100003. * Implementation specific of rendering the generating effect on the main canvas.
  100004. * @param effect The effect used to render through
  100005. */
  100006. protected abstract _internalRender(effect: Effect): void;
  100007. /**
  100008. * Sets the required values for both the emissive texture and and the main color.
  100009. */
  100010. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100011. /**
  100012. * Free any resources and references associated to a mesh.
  100013. * Internal use
  100014. * @param mesh The mesh to free.
  100015. */
  100016. abstract _disposeMesh(mesh: Mesh): void;
  100017. /**
  100018. * Serializes this layer (Glow or Highlight for example)
  100019. * @returns a serialized layer object
  100020. */
  100021. abstract serialize?(): any;
  100022. /**
  100023. * Initializes the effect layer with the required options.
  100024. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  100025. */
  100026. protected _init(options: Partial<IEffectLayerOptions>): void;
  100027. /**
  100028. * Generates the index buffer of the full screen quad blending to the main canvas.
  100029. */
  100030. private _generateIndexBuffer;
  100031. /**
  100032. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  100033. */
  100034. private _genrateVertexBuffer;
  100035. /**
  100036. * Sets the main texture desired size which is the closest power of two
  100037. * of the engine canvas size.
  100038. */
  100039. private _setMainTextureSize;
  100040. /**
  100041. * Creates the main texture for the effect layer.
  100042. */
  100043. protected _createMainTexture(): void;
  100044. /**
  100045. * Adds specific effects defines.
  100046. * @param defines The defines to add specifics to.
  100047. */
  100048. protected _addCustomEffectDefines(defines: string[]): void;
  100049. /**
  100050. * Checks for the readiness of the element composing the layer.
  100051. * @param subMesh the mesh to check for
  100052. * @param useInstances specify wether or not to use instances to render the mesh
  100053. * @param emissiveTexture the associated emissive texture used to generate the glow
  100054. * @return true if ready otherwise, false
  100055. */
  100056. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  100057. /**
  100058. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  100059. */
  100060. render(): void;
  100061. /**
  100062. * Determine if a given mesh will be used in the current effect.
  100063. * @param mesh mesh to test
  100064. * @returns true if the mesh will be used
  100065. */
  100066. hasMesh(mesh: AbstractMesh): boolean;
  100067. /**
  100068. * Returns true if the layer contains information to display, otherwise false.
  100069. * @returns true if the glow layer should be rendered
  100070. */
  100071. shouldRender(): boolean;
  100072. /**
  100073. * Returns true if the mesh should render, otherwise false.
  100074. * @param mesh The mesh to render
  100075. * @returns true if it should render otherwise false
  100076. */
  100077. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  100078. /**
  100079. * Returns true if the mesh can be rendered, otherwise false.
  100080. * @param mesh The mesh to render
  100081. * @param material The material used on the mesh
  100082. * @returns true if it can be rendered otherwise false
  100083. */
  100084. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100085. /**
  100086. * Returns true if the mesh should render, otherwise false.
  100087. * @param mesh The mesh to render
  100088. * @returns true if it should render otherwise false
  100089. */
  100090. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  100091. /**
  100092. * Renders the submesh passed in parameter to the generation map.
  100093. */
  100094. protected _renderSubMesh(subMesh: SubMesh): void;
  100095. /**
  100096. * Rebuild the required buffers.
  100097. * @hidden Internal use only.
  100098. */
  100099. _rebuild(): void;
  100100. /**
  100101. * Dispose only the render target textures and post process.
  100102. */
  100103. private _disposeTextureAndPostProcesses;
  100104. /**
  100105. * Dispose the highlight layer and free resources.
  100106. */
  100107. dispose(): void;
  100108. /**
  100109. * Gets the class name of the effect layer
  100110. * @returns the string with the class name of the effect layer
  100111. */
  100112. getClassName(): string;
  100113. /**
  100114. * Creates an effect layer from parsed effect layer data
  100115. * @param parsedEffectLayer defines effect layer data
  100116. * @param scene defines the current scene
  100117. * @param rootUrl defines the root URL containing the effect layer information
  100118. * @returns a parsed effect Layer
  100119. */
  100120. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  100121. }
  100122. }
  100123. declare module BABYLON {
  100124. interface AbstractScene {
  100125. /**
  100126. * The list of effect layers (highlights/glow) added to the scene
  100127. * @see http://doc.babylonjs.com/how_to/highlight_layer
  100128. * @see http://doc.babylonjs.com/how_to/glow_layer
  100129. */
  100130. effectLayers: Array<EffectLayer>;
  100131. /**
  100132. * Removes the given effect layer from this scene.
  100133. * @param toRemove defines the effect layer to remove
  100134. * @returns the index of the removed effect layer
  100135. */
  100136. removeEffectLayer(toRemove: EffectLayer): number;
  100137. /**
  100138. * Adds the given effect layer to this scene
  100139. * @param newEffectLayer defines the effect layer to add
  100140. */
  100141. addEffectLayer(newEffectLayer: EffectLayer): void;
  100142. }
  100143. /**
  100144. * Defines the layer scene component responsible to manage any effect layers
  100145. * in a given scene.
  100146. */
  100147. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  100148. /**
  100149. * The component name helpfull to identify the component in the list of scene components.
  100150. */
  100151. readonly name: string;
  100152. /**
  100153. * The scene the component belongs to.
  100154. */
  100155. scene: Scene;
  100156. private _engine;
  100157. private _renderEffects;
  100158. private _needStencil;
  100159. private _previousStencilState;
  100160. /**
  100161. * Creates a new instance of the component for the given scene
  100162. * @param scene Defines the scene to register the component in
  100163. */
  100164. constructor(scene: Scene);
  100165. /**
  100166. * Registers the component in a given scene
  100167. */
  100168. register(): void;
  100169. /**
  100170. * Rebuilds the elements related to this component in case of
  100171. * context lost for instance.
  100172. */
  100173. rebuild(): void;
  100174. /**
  100175. * Serializes the component data to the specified json object
  100176. * @param serializationObject The object to serialize to
  100177. */
  100178. serialize(serializationObject: any): void;
  100179. /**
  100180. * Adds all the element from the container to the scene
  100181. * @param container the container holding the elements
  100182. */
  100183. addFromContainer(container: AbstractScene): void;
  100184. /**
  100185. * Removes all the elements in the container from the scene
  100186. * @param container contains the elements to remove
  100187. */
  100188. removeFromContainer(container: AbstractScene): void;
  100189. /**
  100190. * Disposes the component and the associated ressources.
  100191. */
  100192. dispose(): void;
  100193. private _isReadyForMesh;
  100194. private _renderMainTexture;
  100195. private _setStencil;
  100196. private _setStencilBack;
  100197. private _draw;
  100198. private _drawCamera;
  100199. private _drawRenderingGroup;
  100200. }
  100201. }
  100202. declare module BABYLON {
  100203. /** @hidden */
  100204. export var glowMapMergePixelShader: {
  100205. name: string;
  100206. shader: string;
  100207. };
  100208. }
  100209. declare module BABYLON {
  100210. /** @hidden */
  100211. export var glowMapMergeVertexShader: {
  100212. name: string;
  100213. shader: string;
  100214. };
  100215. }
  100216. declare module BABYLON {
  100217. interface AbstractScene {
  100218. /**
  100219. * Return a the first highlight layer of the scene with a given name.
  100220. * @param name The name of the highlight layer to look for.
  100221. * @return The highlight layer if found otherwise null.
  100222. */
  100223. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  100224. }
  100225. /**
  100226. * Glow layer options. This helps customizing the behaviour
  100227. * of the glow layer.
  100228. */
  100229. export interface IGlowLayerOptions {
  100230. /**
  100231. * Multiplication factor apply to the canvas size to compute the render target size
  100232. * used to generated the glowing objects (the smaller the faster).
  100233. */
  100234. mainTextureRatio: number;
  100235. /**
  100236. * Enforces a fixed size texture to ensure resize independant blur.
  100237. */
  100238. mainTextureFixedSize?: number;
  100239. /**
  100240. * How big is the kernel of the blur texture.
  100241. */
  100242. blurKernelSize: number;
  100243. /**
  100244. * The camera attached to the layer.
  100245. */
  100246. camera: Nullable<Camera>;
  100247. /**
  100248. * Enable MSAA by chosing the number of samples.
  100249. */
  100250. mainTextureSamples?: number;
  100251. /**
  100252. * The rendering group to draw the layer in.
  100253. */
  100254. renderingGroupId: number;
  100255. }
  100256. /**
  100257. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  100258. *
  100259. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100260. * glowy meshes to your scene.
  100261. *
  100262. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  100263. */
  100264. export class GlowLayer extends EffectLayer {
  100265. /**
  100266. * Effect Name of the layer.
  100267. */
  100268. static readonly EffectName: string;
  100269. /**
  100270. * The default blur kernel size used for the glow.
  100271. */
  100272. static DefaultBlurKernelSize: number;
  100273. /**
  100274. * The default texture size ratio used for the glow.
  100275. */
  100276. static DefaultTextureRatio: number;
  100277. /**
  100278. * Sets the kernel size of the blur.
  100279. */
  100280. /**
  100281. * Gets the kernel size of the blur.
  100282. */
  100283. blurKernelSize: number;
  100284. /**
  100285. * Sets the glow intensity.
  100286. */
  100287. /**
  100288. * Gets the glow intensity.
  100289. */
  100290. intensity: number;
  100291. private _options;
  100292. private _intensity;
  100293. private _horizontalBlurPostprocess1;
  100294. private _verticalBlurPostprocess1;
  100295. private _horizontalBlurPostprocess2;
  100296. private _verticalBlurPostprocess2;
  100297. private _blurTexture1;
  100298. private _blurTexture2;
  100299. private _postProcesses1;
  100300. private _postProcesses2;
  100301. private _includedOnlyMeshes;
  100302. private _excludedMeshes;
  100303. /**
  100304. * Callback used to let the user override the color selection on a per mesh basis
  100305. */
  100306. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  100307. /**
  100308. * Callback used to let the user override the texture selection on a per mesh basis
  100309. */
  100310. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  100311. /**
  100312. * Instantiates a new glow Layer and references it to the scene.
  100313. * @param name The name of the layer
  100314. * @param scene The scene to use the layer in
  100315. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  100316. */
  100317. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  100318. /**
  100319. * Get the effect name of the layer.
  100320. * @return The effect name
  100321. */
  100322. getEffectName(): string;
  100323. /**
  100324. * Create the merge effect. This is the shader use to blit the information back
  100325. * to the main canvas at the end of the scene rendering.
  100326. */
  100327. protected _createMergeEffect(): Effect;
  100328. /**
  100329. * Creates the render target textures and post processes used in the glow layer.
  100330. */
  100331. protected _createTextureAndPostProcesses(): void;
  100332. /**
  100333. * Checks for the readiness of the element composing the layer.
  100334. * @param subMesh the mesh to check for
  100335. * @param useInstances specify wether or not to use instances to render the mesh
  100336. * @param emissiveTexture the associated emissive texture used to generate the glow
  100337. * @return true if ready otherwise, false
  100338. */
  100339. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100340. /**
  100341. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100342. */
  100343. needStencil(): boolean;
  100344. /**
  100345. * Returns true if the mesh can be rendered, otherwise false.
  100346. * @param mesh The mesh to render
  100347. * @param material The material used on the mesh
  100348. * @returns true if it can be rendered otherwise false
  100349. */
  100350. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  100351. /**
  100352. * Implementation specific of rendering the generating effect on the main canvas.
  100353. * @param effect The effect used to render through
  100354. */
  100355. protected _internalRender(effect: Effect): void;
  100356. /**
  100357. * Sets the required values for both the emissive texture and and the main color.
  100358. */
  100359. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100360. /**
  100361. * Returns true if the mesh should render, otherwise false.
  100362. * @param mesh The mesh to render
  100363. * @returns true if it should render otherwise false
  100364. */
  100365. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100366. /**
  100367. * Adds specific effects defines.
  100368. * @param defines The defines to add specifics to.
  100369. */
  100370. protected _addCustomEffectDefines(defines: string[]): void;
  100371. /**
  100372. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  100373. * @param mesh The mesh to exclude from the glow layer
  100374. */
  100375. addExcludedMesh(mesh: Mesh): void;
  100376. /**
  100377. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  100378. * @param mesh The mesh to remove
  100379. */
  100380. removeExcludedMesh(mesh: Mesh): void;
  100381. /**
  100382. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  100383. * @param mesh The mesh to include in the glow layer
  100384. */
  100385. addIncludedOnlyMesh(mesh: Mesh): void;
  100386. /**
  100387. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  100388. * @param mesh The mesh to remove
  100389. */
  100390. removeIncludedOnlyMesh(mesh: Mesh): void;
  100391. /**
  100392. * Determine if a given mesh will be used in the glow layer
  100393. * @param mesh The mesh to test
  100394. * @returns true if the mesh will be highlighted by the current glow layer
  100395. */
  100396. hasMesh(mesh: AbstractMesh): boolean;
  100397. /**
  100398. * Free any resources and references associated to a mesh.
  100399. * Internal use
  100400. * @param mesh The mesh to free.
  100401. * @hidden
  100402. */
  100403. _disposeMesh(mesh: Mesh): void;
  100404. /**
  100405. * Gets the class name of the effect layer
  100406. * @returns the string with the class name of the effect layer
  100407. */
  100408. getClassName(): string;
  100409. /**
  100410. * Serializes this glow layer
  100411. * @returns a serialized glow layer object
  100412. */
  100413. serialize(): any;
  100414. /**
  100415. * Creates a Glow Layer from parsed glow layer data
  100416. * @param parsedGlowLayer defines glow layer data
  100417. * @param scene defines the current scene
  100418. * @param rootUrl defines the root URL containing the glow layer information
  100419. * @returns a parsed Glow Layer
  100420. */
  100421. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  100422. }
  100423. }
  100424. declare module BABYLON {
  100425. /** @hidden */
  100426. export var glowBlurPostProcessPixelShader: {
  100427. name: string;
  100428. shader: string;
  100429. };
  100430. }
  100431. declare module BABYLON {
  100432. interface AbstractScene {
  100433. /**
  100434. * Return a the first highlight layer of the scene with a given name.
  100435. * @param name The name of the highlight layer to look for.
  100436. * @return The highlight layer if found otherwise null.
  100437. */
  100438. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  100439. }
  100440. /**
  100441. * Highlight layer options. This helps customizing the behaviour
  100442. * of the highlight layer.
  100443. */
  100444. export interface IHighlightLayerOptions {
  100445. /**
  100446. * Multiplication factor apply to the canvas size to compute the render target size
  100447. * used to generated the glowing objects (the smaller the faster).
  100448. */
  100449. mainTextureRatio: number;
  100450. /**
  100451. * Enforces a fixed size texture to ensure resize independant blur.
  100452. */
  100453. mainTextureFixedSize?: number;
  100454. /**
  100455. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  100456. * of the picture to blur (the smaller the faster).
  100457. */
  100458. blurTextureSizeRatio: number;
  100459. /**
  100460. * How big in texel of the blur texture is the vertical blur.
  100461. */
  100462. blurVerticalSize: number;
  100463. /**
  100464. * How big in texel of the blur texture is the horizontal blur.
  100465. */
  100466. blurHorizontalSize: number;
  100467. /**
  100468. * Alpha blending mode used to apply the blur. Default is combine.
  100469. */
  100470. alphaBlendingMode: number;
  100471. /**
  100472. * The camera attached to the layer.
  100473. */
  100474. camera: Nullable<Camera>;
  100475. /**
  100476. * Should we display highlight as a solid stroke?
  100477. */
  100478. isStroke?: boolean;
  100479. /**
  100480. * The rendering group to draw the layer in.
  100481. */
  100482. renderingGroupId: number;
  100483. }
  100484. /**
  100485. * The highlight layer Helps adding a glow effect around a mesh.
  100486. *
  100487. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  100488. * glowy meshes to your scene.
  100489. *
  100490. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  100491. */
  100492. export class HighlightLayer extends EffectLayer {
  100493. name: string;
  100494. /**
  100495. * Effect Name of the highlight layer.
  100496. */
  100497. static readonly EffectName: string;
  100498. /**
  100499. * The neutral color used during the preparation of the glow effect.
  100500. * This is black by default as the blend operation is a blend operation.
  100501. */
  100502. static NeutralColor: Color4;
  100503. /**
  100504. * Stencil value used for glowing meshes.
  100505. */
  100506. static GlowingMeshStencilReference: number;
  100507. /**
  100508. * Stencil value used for the other meshes in the scene.
  100509. */
  100510. static NormalMeshStencilReference: number;
  100511. /**
  100512. * Specifies whether or not the inner glow is ACTIVE in the layer.
  100513. */
  100514. innerGlow: boolean;
  100515. /**
  100516. * Specifies whether or not the outer glow is ACTIVE in the layer.
  100517. */
  100518. outerGlow: boolean;
  100519. /**
  100520. * Specifies the horizontal size of the blur.
  100521. */
  100522. /**
  100523. * Gets the horizontal size of the blur.
  100524. */
  100525. blurHorizontalSize: number;
  100526. /**
  100527. * Specifies the vertical size of the blur.
  100528. */
  100529. /**
  100530. * Gets the vertical size of the blur.
  100531. */
  100532. blurVerticalSize: number;
  100533. /**
  100534. * An event triggered when the highlight layer is being blurred.
  100535. */
  100536. onBeforeBlurObservable: Observable<HighlightLayer>;
  100537. /**
  100538. * An event triggered when the highlight layer has been blurred.
  100539. */
  100540. onAfterBlurObservable: Observable<HighlightLayer>;
  100541. private _instanceGlowingMeshStencilReference;
  100542. private _options;
  100543. private _downSamplePostprocess;
  100544. private _horizontalBlurPostprocess;
  100545. private _verticalBlurPostprocess;
  100546. private _blurTexture;
  100547. private _meshes;
  100548. private _excludedMeshes;
  100549. /**
  100550. * Instantiates a new highlight Layer and references it to the scene..
  100551. * @param name The name of the layer
  100552. * @param scene The scene to use the layer in
  100553. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  100554. */
  100555. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  100556. /**
  100557. * Get the effect name of the layer.
  100558. * @return The effect name
  100559. */
  100560. getEffectName(): string;
  100561. /**
  100562. * Create the merge effect. This is the shader use to blit the information back
  100563. * to the main canvas at the end of the scene rendering.
  100564. */
  100565. protected _createMergeEffect(): Effect;
  100566. /**
  100567. * Creates the render target textures and post processes used in the highlight layer.
  100568. */
  100569. protected _createTextureAndPostProcesses(): void;
  100570. /**
  100571. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  100572. */
  100573. needStencil(): boolean;
  100574. /**
  100575. * Checks for the readiness of the element composing the layer.
  100576. * @param subMesh the mesh to check for
  100577. * @param useInstances specify wether or not to use instances to render the mesh
  100578. * @param emissiveTexture the associated emissive texture used to generate the glow
  100579. * @return true if ready otherwise, false
  100580. */
  100581. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  100582. /**
  100583. * Implementation specific of rendering the generating effect on the main canvas.
  100584. * @param effect The effect used to render through
  100585. */
  100586. protected _internalRender(effect: Effect): void;
  100587. /**
  100588. * Returns true if the layer contains information to display, otherwise false.
  100589. */
  100590. shouldRender(): boolean;
  100591. /**
  100592. * Returns true if the mesh should render, otherwise false.
  100593. * @param mesh The mesh to render
  100594. * @returns true if it should render otherwise false
  100595. */
  100596. protected _shouldRenderMesh(mesh: Mesh): boolean;
  100597. /**
  100598. * Sets the required values for both the emissive texture and and the main color.
  100599. */
  100600. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  100601. /**
  100602. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  100603. * @param mesh The mesh to exclude from the highlight layer
  100604. */
  100605. addExcludedMesh(mesh: Mesh): void;
  100606. /**
  100607. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  100608. * @param mesh The mesh to highlight
  100609. */
  100610. removeExcludedMesh(mesh: Mesh): void;
  100611. /**
  100612. * Determine if a given mesh will be highlighted by the current HighlightLayer
  100613. * @param mesh mesh to test
  100614. * @returns true if the mesh will be highlighted by the current HighlightLayer
  100615. */
  100616. hasMesh(mesh: AbstractMesh): boolean;
  100617. /**
  100618. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  100619. * @param mesh The mesh to highlight
  100620. * @param color The color of the highlight
  100621. * @param glowEmissiveOnly Extract the glow from the emissive texture
  100622. */
  100623. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  100624. /**
  100625. * Remove a mesh from the highlight layer in order to make it stop glowing.
  100626. * @param mesh The mesh to highlight
  100627. */
  100628. removeMesh(mesh: Mesh): void;
  100629. /**
  100630. * Force the stencil to the normal expected value for none glowing parts
  100631. */
  100632. private _defaultStencilReference;
  100633. /**
  100634. * Free any resources and references associated to a mesh.
  100635. * Internal use
  100636. * @param mesh The mesh to free.
  100637. * @hidden
  100638. */
  100639. _disposeMesh(mesh: Mesh): void;
  100640. /**
  100641. * Dispose the highlight layer and free resources.
  100642. */
  100643. dispose(): void;
  100644. /**
  100645. * Gets the class name of the effect layer
  100646. * @returns the string with the class name of the effect layer
  100647. */
  100648. getClassName(): string;
  100649. /**
  100650. * Serializes this Highlight layer
  100651. * @returns a serialized Highlight layer object
  100652. */
  100653. serialize(): any;
  100654. /**
  100655. * Creates a Highlight layer from parsed Highlight layer data
  100656. * @param parsedHightlightLayer defines the Highlight layer data
  100657. * @param scene defines the current scene
  100658. * @param rootUrl defines the root URL containing the Highlight layer information
  100659. * @returns a parsed Highlight layer
  100660. */
  100661. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  100662. }
  100663. }
  100664. declare module BABYLON {
  100665. /** @hidden */
  100666. export var lensFlarePixelShader: {
  100667. name: string;
  100668. shader: string;
  100669. };
  100670. }
  100671. declare module BABYLON {
  100672. /** @hidden */
  100673. export var lensFlareVertexShader: {
  100674. name: string;
  100675. shader: string;
  100676. };
  100677. }
  100678. declare module BABYLON {
  100679. /**
  100680. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100681. * It is usually composed of several `lensFlare`.
  100682. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100683. */
  100684. export class LensFlareSystem {
  100685. /**
  100686. * Define the name of the lens flare system
  100687. */
  100688. name: string;
  100689. /**
  100690. * List of lens flares used in this system.
  100691. */
  100692. lensFlares: LensFlare[];
  100693. /**
  100694. * Define a limit from the border the lens flare can be visible.
  100695. */
  100696. borderLimit: number;
  100697. /**
  100698. * Define a viewport border we do not want to see the lens flare in.
  100699. */
  100700. viewportBorder: number;
  100701. /**
  100702. * Define a predicate which could limit the list of meshes able to occlude the effect.
  100703. */
  100704. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  100705. /**
  100706. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  100707. */
  100708. layerMask: number;
  100709. /**
  100710. * Define the id of the lens flare system in the scene.
  100711. * (equal to name by default)
  100712. */
  100713. id: string;
  100714. private _scene;
  100715. private _emitter;
  100716. private _vertexBuffers;
  100717. private _indexBuffer;
  100718. private _effect;
  100719. private _positionX;
  100720. private _positionY;
  100721. private _isEnabled;
  100722. /** @hidden */
  100723. static _SceneComponentInitialization: (scene: Scene) => void;
  100724. /**
  100725. * Instantiates a lens flare system.
  100726. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  100727. * It is usually composed of several `lensFlare`.
  100728. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100729. * @param name Define the name of the lens flare system in the scene
  100730. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  100731. * @param scene Define the scene the lens flare system belongs to
  100732. */
  100733. constructor(
  100734. /**
  100735. * Define the name of the lens flare system
  100736. */
  100737. name: string, emitter: any, scene: Scene);
  100738. /**
  100739. * Define if the lens flare system is enabled.
  100740. */
  100741. isEnabled: boolean;
  100742. /**
  100743. * Get the scene the effects belongs to.
  100744. * @returns the scene holding the lens flare system
  100745. */
  100746. getScene(): Scene;
  100747. /**
  100748. * Get the emitter of the lens flare system.
  100749. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100750. * @returns the emitter of the lens flare system
  100751. */
  100752. getEmitter(): any;
  100753. /**
  100754. * Set the emitter of the lens flare system.
  100755. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  100756. * @param newEmitter Define the new emitter of the system
  100757. */
  100758. setEmitter(newEmitter: any): void;
  100759. /**
  100760. * Get the lens flare system emitter position.
  100761. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  100762. * @returns the position
  100763. */
  100764. getEmitterPosition(): Vector3;
  100765. /**
  100766. * @hidden
  100767. */
  100768. computeEffectivePosition(globalViewport: Viewport): boolean;
  100769. /** @hidden */
  100770. _isVisible(): boolean;
  100771. /**
  100772. * @hidden
  100773. */
  100774. render(): boolean;
  100775. /**
  100776. * Dispose and release the lens flare with its associated resources.
  100777. */
  100778. dispose(): void;
  100779. /**
  100780. * Parse a lens flare system from a JSON repressentation
  100781. * @param parsedLensFlareSystem Define the JSON to parse
  100782. * @param scene Define the scene the parsed system should be instantiated in
  100783. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  100784. * @returns the parsed system
  100785. */
  100786. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  100787. /**
  100788. * Serialize the current Lens Flare System into a JSON representation.
  100789. * @returns the serialized JSON
  100790. */
  100791. serialize(): any;
  100792. }
  100793. }
  100794. declare module BABYLON {
  100795. /**
  100796. * This represents one of the lens effect in a `lensFlareSystem`.
  100797. * It controls one of the indiviual texture used in the effect.
  100798. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100799. */
  100800. export class LensFlare {
  100801. /**
  100802. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100803. */
  100804. size: number;
  100805. /**
  100806. * 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.
  100807. */
  100808. position: number;
  100809. /**
  100810. * Define the lens color.
  100811. */
  100812. color: Color3;
  100813. /**
  100814. * Define the lens texture.
  100815. */
  100816. texture: Nullable<Texture>;
  100817. /**
  100818. * Define the alpha mode to render this particular lens.
  100819. */
  100820. alphaMode: number;
  100821. private _system;
  100822. /**
  100823. * Creates a new Lens Flare.
  100824. * This represents one of the lens effect in a `lensFlareSystem`.
  100825. * It controls one of the indiviual texture used in the effect.
  100826. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100827. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  100828. * @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.
  100829. * @param color Define the lens color
  100830. * @param imgUrl Define the lens texture url
  100831. * @param system Define the `lensFlareSystem` this flare is part of
  100832. * @returns The newly created Lens Flare
  100833. */
  100834. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  100835. /**
  100836. * Instantiates a new Lens Flare.
  100837. * This represents one of the lens effect in a `lensFlareSystem`.
  100838. * It controls one of the indiviual texture used in the effect.
  100839. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100840. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  100841. * @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.
  100842. * @param color Define the lens color
  100843. * @param imgUrl Define the lens texture url
  100844. * @param system Define the `lensFlareSystem` this flare is part of
  100845. */
  100846. constructor(
  100847. /**
  100848. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  100849. */
  100850. size: number,
  100851. /**
  100852. * 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.
  100853. */
  100854. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  100855. /**
  100856. * Dispose and release the lens flare with its associated resources.
  100857. */
  100858. dispose(): void;
  100859. }
  100860. }
  100861. declare module BABYLON {
  100862. interface AbstractScene {
  100863. /**
  100864. * The list of lens flare system added to the scene
  100865. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  100866. */
  100867. lensFlareSystems: Array<LensFlareSystem>;
  100868. /**
  100869. * Removes the given lens flare system from this scene.
  100870. * @param toRemove The lens flare system to remove
  100871. * @returns The index of the removed lens flare system
  100872. */
  100873. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  100874. /**
  100875. * Adds the given lens flare system to this scene
  100876. * @param newLensFlareSystem The lens flare system to add
  100877. */
  100878. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  100879. /**
  100880. * Gets a lens flare system using its name
  100881. * @param name defines the name to look for
  100882. * @returns the lens flare system or null if not found
  100883. */
  100884. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  100885. /**
  100886. * Gets a lens flare system using its id
  100887. * @param id defines the id to look for
  100888. * @returns the lens flare system or null if not found
  100889. */
  100890. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  100891. }
  100892. /**
  100893. * Defines the lens flare scene component responsible to manage any lens flares
  100894. * in a given scene.
  100895. */
  100896. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  100897. /**
  100898. * The component name helpfull to identify the component in the list of scene components.
  100899. */
  100900. readonly name: string;
  100901. /**
  100902. * The scene the component belongs to.
  100903. */
  100904. scene: Scene;
  100905. /**
  100906. * Creates a new instance of the component for the given scene
  100907. * @param scene Defines the scene to register the component in
  100908. */
  100909. constructor(scene: Scene);
  100910. /**
  100911. * Registers the component in a given scene
  100912. */
  100913. register(): void;
  100914. /**
  100915. * Rebuilds the elements related to this component in case of
  100916. * context lost for instance.
  100917. */
  100918. rebuild(): void;
  100919. /**
  100920. * Adds all the element from the container to the scene
  100921. * @param container the container holding the elements
  100922. */
  100923. addFromContainer(container: AbstractScene): void;
  100924. /**
  100925. * Removes all the elements in the container from the scene
  100926. * @param container contains the elements to remove
  100927. */
  100928. removeFromContainer(container: AbstractScene): void;
  100929. /**
  100930. * Serializes the component data to the specified json object
  100931. * @param serializationObject The object to serialize to
  100932. */
  100933. serialize(serializationObject: any): void;
  100934. /**
  100935. * Disposes the component and the associated ressources.
  100936. */
  100937. dispose(): void;
  100938. private _draw;
  100939. }
  100940. }
  100941. declare module BABYLON {
  100942. /**
  100943. * Defines the shadow generator component responsible to manage any shadow generators
  100944. * in a given scene.
  100945. */
  100946. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  100947. /**
  100948. * The component name helpfull to identify the component in the list of scene components.
  100949. */
  100950. readonly name: string;
  100951. /**
  100952. * The scene the component belongs to.
  100953. */
  100954. scene: Scene;
  100955. /**
  100956. * Creates a new instance of the component for the given scene
  100957. * @param scene Defines the scene to register the component in
  100958. */
  100959. constructor(scene: Scene);
  100960. /**
  100961. * Registers the component in a given scene
  100962. */
  100963. register(): void;
  100964. /**
  100965. * Rebuilds the elements related to this component in case of
  100966. * context lost for instance.
  100967. */
  100968. rebuild(): void;
  100969. /**
  100970. * Serializes the component data to the specified json object
  100971. * @param serializationObject The object to serialize to
  100972. */
  100973. serialize(serializationObject: any): void;
  100974. /**
  100975. * Adds all the element from the container to the scene
  100976. * @param container the container holding the elements
  100977. */
  100978. addFromContainer(container: AbstractScene): void;
  100979. /**
  100980. * Removes all the elements in the container from the scene
  100981. * @param container contains the elements to remove
  100982. */
  100983. removeFromContainer(container: AbstractScene): void;
  100984. /**
  100985. * Rebuilds the elements related to this component in case of
  100986. * context lost for instance.
  100987. */
  100988. dispose(): void;
  100989. private _gatherRenderTargets;
  100990. }
  100991. }
  100992. declare module BABYLON {
  100993. /**
  100994. * A directional light is defined by a direction (what a surprise!).
  100995. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  100996. * 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.
  100997. * Documentation: https://doc.babylonjs.com/babylon101/lights
  100998. */
  100999. export class DirectionalLight extends ShadowLight {
  101000. private _shadowFrustumSize;
  101001. /**
  101002. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  101003. */
  101004. /**
  101005. * Specifies a fix frustum size for the shadow generation.
  101006. */
  101007. shadowFrustumSize: number;
  101008. private _shadowOrthoScale;
  101009. /**
  101010. * Gets the shadow projection scale against the optimal computed one.
  101011. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101012. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101013. */
  101014. /**
  101015. * Sets the shadow projection scale against the optimal computed one.
  101016. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  101017. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  101018. */
  101019. shadowOrthoScale: number;
  101020. /**
  101021. * Automatically compute the projection matrix to best fit (including all the casters)
  101022. * on each frame.
  101023. */
  101024. autoUpdateExtends: boolean;
  101025. private _orthoLeft;
  101026. private _orthoRight;
  101027. private _orthoTop;
  101028. private _orthoBottom;
  101029. /**
  101030. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  101031. * The directional light is emitted from everywhere in the given direction.
  101032. * It can cast shadows.
  101033. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101034. * @param name The friendly name of the light
  101035. * @param direction The direction of the light
  101036. * @param scene The scene the light belongs to
  101037. */
  101038. constructor(name: string, direction: Vector3, scene: Scene);
  101039. /**
  101040. * Returns the string "DirectionalLight".
  101041. * @return The class name
  101042. */
  101043. getClassName(): string;
  101044. /**
  101045. * Returns the integer 1.
  101046. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101047. */
  101048. getTypeID(): number;
  101049. /**
  101050. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  101051. * Returns the DirectionalLight Shadow projection matrix.
  101052. */
  101053. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101054. /**
  101055. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  101056. * Returns the DirectionalLight Shadow projection matrix.
  101057. */
  101058. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  101059. /**
  101060. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  101061. * Returns the DirectionalLight Shadow projection matrix.
  101062. */
  101063. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101064. protected _buildUniformLayout(): void;
  101065. /**
  101066. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  101067. * @param effect The effect to update
  101068. * @param lightIndex The index of the light in the effect to update
  101069. * @returns The directional light
  101070. */
  101071. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  101072. /**
  101073. * Gets the minZ used for shadow according to both the scene and the light.
  101074. *
  101075. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101076. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101077. * @param activeCamera The camera we are returning the min for
  101078. * @returns the depth min z
  101079. */
  101080. getDepthMinZ(activeCamera: Camera): number;
  101081. /**
  101082. * Gets the maxZ used for shadow according to both the scene and the light.
  101083. *
  101084. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  101085. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  101086. * @param activeCamera The camera we are returning the max for
  101087. * @returns the depth max z
  101088. */
  101089. getDepthMaxZ(activeCamera: Camera): number;
  101090. /**
  101091. * Prepares the list of defines specific to the light type.
  101092. * @param defines the list of defines
  101093. * @param lightIndex defines the index of the light for the effect
  101094. */
  101095. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101096. }
  101097. }
  101098. declare module BABYLON {
  101099. /**
  101100. * A point light is a light defined by an unique point in world space.
  101101. * The light is emitted in every direction from this point.
  101102. * A good example of a point light is a standard light bulb.
  101103. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101104. */
  101105. export class PointLight extends ShadowLight {
  101106. private _shadowAngle;
  101107. /**
  101108. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101109. * This specifies what angle the shadow will use to be created.
  101110. *
  101111. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101112. */
  101113. /**
  101114. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101115. * This specifies what angle the shadow will use to be created.
  101116. *
  101117. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  101118. */
  101119. shadowAngle: number;
  101120. /**
  101121. * Gets the direction if it has been set.
  101122. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101123. */
  101124. /**
  101125. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  101126. */
  101127. direction: Vector3;
  101128. /**
  101129. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  101130. * A PointLight emits the light in every direction.
  101131. * It can cast shadows.
  101132. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  101133. * ```javascript
  101134. * var pointLight = new PointLight("pl", camera.position, scene);
  101135. * ```
  101136. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101137. * @param name The light friendly name
  101138. * @param position The position of the point light in the scene
  101139. * @param scene The scene the lights belongs to
  101140. */
  101141. constructor(name: string, position: Vector3, scene: Scene);
  101142. /**
  101143. * Returns the string "PointLight"
  101144. * @returns the class name
  101145. */
  101146. getClassName(): string;
  101147. /**
  101148. * Returns the integer 0.
  101149. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101150. */
  101151. getTypeID(): number;
  101152. /**
  101153. * Specifies wether or not the shadowmap should be a cube texture.
  101154. * @returns true if the shadowmap needs to be a cube texture.
  101155. */
  101156. needCube(): boolean;
  101157. /**
  101158. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  101159. * @param faceIndex The index of the face we are computed the direction to generate shadow
  101160. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  101161. */
  101162. getShadowDirection(faceIndex?: number): Vector3;
  101163. /**
  101164. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  101165. * - fov = PI / 2
  101166. * - aspect ratio : 1.0
  101167. * - z-near and far equal to the active camera minZ and maxZ.
  101168. * Returns the PointLight.
  101169. */
  101170. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101171. protected _buildUniformLayout(): void;
  101172. /**
  101173. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  101174. * @param effect The effect to update
  101175. * @param lightIndex The index of the light in the effect to update
  101176. * @returns The point light
  101177. */
  101178. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  101179. /**
  101180. * Prepares the list of defines specific to the light type.
  101181. * @param defines the list of defines
  101182. * @param lightIndex defines the index of the light for the effect
  101183. */
  101184. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101185. }
  101186. }
  101187. declare module BABYLON {
  101188. /**
  101189. * A spot light is defined by a position, a direction, an angle, and an exponent.
  101190. * These values define a cone of light starting from the position, emitting toward the direction.
  101191. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  101192. * and the exponent defines the speed of the decay of the light with distance (reach).
  101193. * Documentation: https://doc.babylonjs.com/babylon101/lights
  101194. */
  101195. export class SpotLight extends ShadowLight {
  101196. private _angle;
  101197. private _innerAngle;
  101198. private _cosHalfAngle;
  101199. private _lightAngleScale;
  101200. private _lightAngleOffset;
  101201. /**
  101202. * Gets the cone angle of the spot light in Radians.
  101203. */
  101204. /**
  101205. * Sets the cone angle of the spot light in Radians.
  101206. */
  101207. angle: number;
  101208. /**
  101209. * Only used in gltf falloff mode, this defines the angle where
  101210. * the directional falloff will start before cutting at angle which could be seen
  101211. * as outer angle.
  101212. */
  101213. /**
  101214. * Only used in gltf falloff mode, this defines the angle where
  101215. * the directional falloff will start before cutting at angle which could be seen
  101216. * as outer angle.
  101217. */
  101218. innerAngle: number;
  101219. private _shadowAngleScale;
  101220. /**
  101221. * Allows scaling the angle of the light for shadow generation only.
  101222. */
  101223. /**
  101224. * Allows scaling the angle of the light for shadow generation only.
  101225. */
  101226. shadowAngleScale: number;
  101227. /**
  101228. * The light decay speed with the distance from the emission spot.
  101229. */
  101230. exponent: number;
  101231. private _projectionTextureMatrix;
  101232. /**
  101233. * Allows reading the projecton texture
  101234. */
  101235. readonly projectionTextureMatrix: Matrix;
  101236. protected _projectionTextureLightNear: number;
  101237. /**
  101238. * Gets the near clip of the Spotlight for texture projection.
  101239. */
  101240. /**
  101241. * Sets the near clip of the Spotlight for texture projection.
  101242. */
  101243. projectionTextureLightNear: number;
  101244. protected _projectionTextureLightFar: number;
  101245. /**
  101246. * Gets the far clip of the Spotlight for texture projection.
  101247. */
  101248. /**
  101249. * Sets the far clip of the Spotlight for texture projection.
  101250. */
  101251. projectionTextureLightFar: number;
  101252. protected _projectionTextureUpDirection: Vector3;
  101253. /**
  101254. * Gets the Up vector of the Spotlight for texture projection.
  101255. */
  101256. /**
  101257. * Sets the Up vector of the Spotlight for texture projection.
  101258. */
  101259. projectionTextureUpDirection: Vector3;
  101260. private _projectionTexture;
  101261. /**
  101262. * Gets the projection texture of the light.
  101263. */
  101264. /**
  101265. * Sets the projection texture of the light.
  101266. */
  101267. projectionTexture: Nullable<BaseTexture>;
  101268. private _projectionTextureViewLightDirty;
  101269. private _projectionTextureProjectionLightDirty;
  101270. private _projectionTextureDirty;
  101271. private _projectionTextureViewTargetVector;
  101272. private _projectionTextureViewLightMatrix;
  101273. private _projectionTextureProjectionLightMatrix;
  101274. private _projectionTextureScalingMatrix;
  101275. /**
  101276. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  101277. * It can cast shadows.
  101278. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101279. * @param name The light friendly name
  101280. * @param position The position of the spot light in the scene
  101281. * @param direction The direction of the light in the scene
  101282. * @param angle The cone angle of the light in Radians
  101283. * @param exponent The light decay speed with the distance from the emission spot
  101284. * @param scene The scene the lights belongs to
  101285. */
  101286. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  101287. /**
  101288. * Returns the string "SpotLight".
  101289. * @returns the class name
  101290. */
  101291. getClassName(): string;
  101292. /**
  101293. * Returns the integer 2.
  101294. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101295. */
  101296. getTypeID(): number;
  101297. /**
  101298. * Overrides the direction setter to recompute the projection texture view light Matrix.
  101299. */
  101300. protected _setDirection(value: Vector3): void;
  101301. /**
  101302. * Overrides the position setter to recompute the projection texture view light Matrix.
  101303. */
  101304. protected _setPosition(value: Vector3): void;
  101305. /**
  101306. * 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.
  101307. * Returns the SpotLight.
  101308. */
  101309. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  101310. protected _computeProjectionTextureViewLightMatrix(): void;
  101311. protected _computeProjectionTextureProjectionLightMatrix(): void;
  101312. /**
  101313. * Main function for light texture projection matrix computing.
  101314. */
  101315. protected _computeProjectionTextureMatrix(): void;
  101316. protected _buildUniformLayout(): void;
  101317. private _computeAngleValues;
  101318. /**
  101319. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  101320. * @param effect The effect to update
  101321. * @param lightIndex The index of the light in the effect to update
  101322. * @returns The spot light
  101323. */
  101324. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  101325. /**
  101326. * Disposes the light and the associated resources.
  101327. */
  101328. dispose(): void;
  101329. /**
  101330. * Prepares the list of defines specific to the light type.
  101331. * @param defines the list of defines
  101332. * @param lightIndex defines the index of the light for the effect
  101333. */
  101334. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101335. }
  101336. }
  101337. declare module BABYLON {
  101338. /**
  101339. * Header information of HDR texture files.
  101340. */
  101341. export interface HDRInfo {
  101342. /**
  101343. * The height of the texture in pixels.
  101344. */
  101345. height: number;
  101346. /**
  101347. * The width of the texture in pixels.
  101348. */
  101349. width: number;
  101350. /**
  101351. * The index of the beginning of the data in the binary file.
  101352. */
  101353. dataPosition: number;
  101354. }
  101355. /**
  101356. * This groups tools to convert HDR texture to native colors array.
  101357. */
  101358. export class HDRTools {
  101359. private static Ldexp;
  101360. private static Rgbe2float;
  101361. private static readStringLine;
  101362. /**
  101363. * Reads header information from an RGBE texture stored in a native array.
  101364. * More information on this format are available here:
  101365. * https://en.wikipedia.org/wiki/RGBE_image_format
  101366. *
  101367. * @param uint8array The binary file stored in native array.
  101368. * @return The header information.
  101369. */
  101370. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  101371. /**
  101372. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  101373. * This RGBE texture needs to store the information as a panorama.
  101374. *
  101375. * More information on this format are available here:
  101376. * https://en.wikipedia.org/wiki/RGBE_image_format
  101377. *
  101378. * @param buffer The binary file stored in an array buffer.
  101379. * @param size The expected size of the extracted cubemap.
  101380. * @return The Cube Map information.
  101381. */
  101382. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  101383. /**
  101384. * Returns the pixels data extracted from an RGBE texture.
  101385. * This pixels will be stored left to right up to down in the R G B order in one array.
  101386. *
  101387. * More information on this format are available here:
  101388. * https://en.wikipedia.org/wiki/RGBE_image_format
  101389. *
  101390. * @param uint8array The binary file stored in an array buffer.
  101391. * @param hdrInfo The header information of the file.
  101392. * @return The pixels data in RGB right to left up to down order.
  101393. */
  101394. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  101395. private static RGBE_ReadPixels_RLE;
  101396. }
  101397. }
  101398. declare module BABYLON {
  101399. /**
  101400. * This represents a texture coming from an HDR input.
  101401. *
  101402. * The only supported format is currently panorama picture stored in RGBE format.
  101403. * Example of such files can be found on HDRLib: http://hdrlib.com/
  101404. */
  101405. export class HDRCubeTexture extends BaseTexture {
  101406. private static _facesMapping;
  101407. private _generateHarmonics;
  101408. private _noMipmap;
  101409. private _textureMatrix;
  101410. private _size;
  101411. private _onLoad;
  101412. private _onError;
  101413. /**
  101414. * The texture URL.
  101415. */
  101416. url: string;
  101417. /**
  101418. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  101419. */
  101420. coordinatesMode: number;
  101421. protected _isBlocking: boolean;
  101422. /**
  101423. * Sets wether or not the texture is blocking during loading.
  101424. */
  101425. /**
  101426. * Gets wether or not the texture is blocking during loading.
  101427. */
  101428. isBlocking: boolean;
  101429. protected _rotationY: number;
  101430. /**
  101431. * Sets texture matrix rotation angle around Y axis in radians.
  101432. */
  101433. /**
  101434. * Gets texture matrix rotation angle around Y axis radians.
  101435. */
  101436. rotationY: number;
  101437. /**
  101438. * Gets or sets the center of the bounding box associated with the cube texture
  101439. * It must define where the camera used to render the texture was set
  101440. */
  101441. boundingBoxPosition: Vector3;
  101442. private _boundingBoxSize;
  101443. /**
  101444. * Gets or sets the size of the bounding box associated with the cube texture
  101445. * When defined, the cubemap will switch to local mode
  101446. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101447. * @example https://www.babylonjs-playground.com/#RNASML
  101448. */
  101449. boundingBoxSize: Vector3;
  101450. /**
  101451. * Instantiates an HDRTexture from the following parameters.
  101452. *
  101453. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  101454. * @param scene The scene the texture will be used in
  101455. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  101456. * @param noMipmap Forces to not generate the mipmap if true
  101457. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  101458. * @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)
  101459. * @param reserved Reserved flag for internal use.
  101460. */
  101461. 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>);
  101462. /**
  101463. * Get the current class name of the texture useful for serialization or dynamic coding.
  101464. * @returns "HDRCubeTexture"
  101465. */
  101466. getClassName(): string;
  101467. /**
  101468. * Occurs when the file is raw .hdr file.
  101469. */
  101470. private loadTexture;
  101471. clone(): HDRCubeTexture;
  101472. delayLoad(): void;
  101473. /**
  101474. * Get the texture reflection matrix used to rotate/transform the reflection.
  101475. * @returns the reflection matrix
  101476. */
  101477. getReflectionTextureMatrix(): Matrix;
  101478. /**
  101479. * Set the texture reflection matrix used to rotate/transform the reflection.
  101480. * @param value Define the reflection matrix to set
  101481. */
  101482. setReflectionTextureMatrix(value: Matrix): void;
  101483. /**
  101484. * Parses a JSON representation of an HDR Texture in order to create the texture
  101485. * @param parsedTexture Define the JSON representation
  101486. * @param scene Define the scene the texture should be created in
  101487. * @param rootUrl Define the root url in case we need to load relative dependencies
  101488. * @returns the newly created texture after parsing
  101489. */
  101490. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  101491. serialize(): any;
  101492. }
  101493. }
  101494. declare module BABYLON {
  101495. /**
  101496. * Class used to control physics engine
  101497. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  101498. */
  101499. export class PhysicsEngine implements IPhysicsEngine {
  101500. private _physicsPlugin;
  101501. /**
  101502. * Global value used to control the smallest number supported by the simulation
  101503. */
  101504. static Epsilon: number;
  101505. private _impostors;
  101506. private _joints;
  101507. /**
  101508. * Gets the gravity vector used by the simulation
  101509. */
  101510. gravity: Vector3;
  101511. /**
  101512. * Factory used to create the default physics plugin.
  101513. * @returns The default physics plugin
  101514. */
  101515. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  101516. /**
  101517. * Creates a new Physics Engine
  101518. * @param gravity defines the gravity vector used by the simulation
  101519. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  101520. */
  101521. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  101522. /**
  101523. * Sets the gravity vector used by the simulation
  101524. * @param gravity defines the gravity vector to use
  101525. */
  101526. setGravity(gravity: Vector3): void;
  101527. /**
  101528. * Set the time step of the physics engine.
  101529. * Default is 1/60.
  101530. * To slow it down, enter 1/600 for example.
  101531. * To speed it up, 1/30
  101532. * @param newTimeStep defines the new timestep to apply to this world.
  101533. */
  101534. setTimeStep(newTimeStep?: number): void;
  101535. /**
  101536. * Get the time step of the physics engine.
  101537. * @returns the current time step
  101538. */
  101539. getTimeStep(): number;
  101540. /**
  101541. * Release all resources
  101542. */
  101543. dispose(): void;
  101544. /**
  101545. * Gets the name of the current physics plugin
  101546. * @returns the name of the plugin
  101547. */
  101548. getPhysicsPluginName(): string;
  101549. /**
  101550. * Adding a new impostor for the impostor tracking.
  101551. * This will be done by the impostor itself.
  101552. * @param impostor the impostor to add
  101553. */
  101554. addImpostor(impostor: PhysicsImpostor): void;
  101555. /**
  101556. * Remove an impostor from the engine.
  101557. * This impostor and its mesh will not longer be updated by the physics engine.
  101558. * @param impostor the impostor to remove
  101559. */
  101560. removeImpostor(impostor: PhysicsImpostor): void;
  101561. /**
  101562. * Add a joint to the physics engine
  101563. * @param mainImpostor defines the main impostor to which the joint is added.
  101564. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  101565. * @param joint defines the joint that will connect both impostors.
  101566. */
  101567. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101568. /**
  101569. * Removes a joint from the simulation
  101570. * @param mainImpostor defines the impostor used with the joint
  101571. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  101572. * @param joint defines the joint to remove
  101573. */
  101574. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  101575. /**
  101576. * Called by the scene. No need to call it.
  101577. * @param delta defines the timespam between frames
  101578. */
  101579. _step(delta: number): void;
  101580. /**
  101581. * Gets the current plugin used to run the simulation
  101582. * @returns current plugin
  101583. */
  101584. getPhysicsPlugin(): IPhysicsEnginePlugin;
  101585. /**
  101586. * Gets the list of physic impostors
  101587. * @returns an array of PhysicsImpostor
  101588. */
  101589. getImpostors(): Array<PhysicsImpostor>;
  101590. /**
  101591. * Gets the impostor for a physics enabled object
  101592. * @param object defines the object impersonated by the impostor
  101593. * @returns the PhysicsImpostor or null if not found
  101594. */
  101595. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  101596. /**
  101597. * Gets the impostor for a physics body object
  101598. * @param body defines physics body used by the impostor
  101599. * @returns the PhysicsImpostor or null if not found
  101600. */
  101601. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  101602. }
  101603. }
  101604. declare module BABYLON {
  101605. /** @hidden */
  101606. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  101607. private _useDeltaForWorldStep;
  101608. world: any;
  101609. name: string;
  101610. private _physicsMaterials;
  101611. private _fixedTimeStep;
  101612. BJSCANNON: any;
  101613. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  101614. setGravity(gravity: Vector3): void;
  101615. setTimeStep(timeStep: number): void;
  101616. getTimeStep(): number;
  101617. executeStep(delta: number): void;
  101618. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101619. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101620. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101621. private _processChildMeshes;
  101622. removePhysicsBody(impostor: PhysicsImpostor): void;
  101623. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101624. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101625. private _addMaterial;
  101626. private _checkWithEpsilon;
  101627. private _createShape;
  101628. private _createHeightmap;
  101629. private _minus90X;
  101630. private _plus90X;
  101631. private _tmpPosition;
  101632. private _tmpDeltaPosition;
  101633. private _tmpUnityRotation;
  101634. private _updatePhysicsBodyTransformation;
  101635. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101636. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101637. isSupported(): boolean;
  101638. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101639. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101640. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101641. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101642. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101643. getBodyMass(impostor: PhysicsImpostor): number;
  101644. getBodyFriction(impostor: PhysicsImpostor): number;
  101645. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101646. getBodyRestitution(impostor: PhysicsImpostor): number;
  101647. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101648. sleepBody(impostor: PhysicsImpostor): void;
  101649. wakeUpBody(impostor: PhysicsImpostor): void;
  101650. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  101651. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  101652. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  101653. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101654. getRadius(impostor: PhysicsImpostor): number;
  101655. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101656. dispose(): void;
  101657. private _extendNamespace;
  101658. }
  101659. }
  101660. declare module BABYLON {
  101661. /** @hidden */
  101662. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  101663. world: any;
  101664. name: string;
  101665. BJSOIMO: any;
  101666. constructor(iterations?: number, oimoInjection?: any);
  101667. setGravity(gravity: Vector3): void;
  101668. setTimeStep(timeStep: number): void;
  101669. getTimeStep(): number;
  101670. private _tmpImpostorsArray;
  101671. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  101672. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101673. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  101674. generatePhysicsBody(impostor: PhysicsImpostor): void;
  101675. private _tmpPositionVector;
  101676. removePhysicsBody(impostor: PhysicsImpostor): void;
  101677. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  101678. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  101679. isSupported(): boolean;
  101680. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  101681. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  101682. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101683. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  101684. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101685. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  101686. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  101687. getBodyMass(impostor: PhysicsImpostor): number;
  101688. getBodyFriction(impostor: PhysicsImpostor): number;
  101689. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  101690. getBodyRestitution(impostor: PhysicsImpostor): number;
  101691. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  101692. sleepBody(impostor: PhysicsImpostor): void;
  101693. wakeUpBody(impostor: PhysicsImpostor): void;
  101694. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  101695. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  101696. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  101697. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  101698. getRadius(impostor: PhysicsImpostor): number;
  101699. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  101700. dispose(): void;
  101701. }
  101702. }
  101703. declare module BABYLON {
  101704. interface AbstractScene {
  101705. /**
  101706. * The list of reflection probes added to the scene
  101707. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101708. */
  101709. reflectionProbes: Array<ReflectionProbe>;
  101710. /**
  101711. * Removes the given reflection probe from this scene.
  101712. * @param toRemove The reflection probe to remove
  101713. * @returns The index of the removed reflection probe
  101714. */
  101715. removeReflectionProbe(toRemove: ReflectionProbe): number;
  101716. /**
  101717. * Adds the given reflection probe to this scene.
  101718. * @param newReflectionProbe The reflection probe to add
  101719. */
  101720. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  101721. }
  101722. /**
  101723. * Class used to generate realtime reflection / refraction cube textures
  101724. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  101725. */
  101726. export class ReflectionProbe {
  101727. /** defines the name of the probe */
  101728. name: string;
  101729. private _scene;
  101730. private _renderTargetTexture;
  101731. private _projectionMatrix;
  101732. private _viewMatrix;
  101733. private _target;
  101734. private _add;
  101735. private _attachedMesh;
  101736. private _invertYAxis;
  101737. /** Gets or sets probe position (center of the cube map) */
  101738. position: Vector3;
  101739. /**
  101740. * Creates a new reflection probe
  101741. * @param name defines the name of the probe
  101742. * @param size defines the texture resolution (for each face)
  101743. * @param scene defines the hosting scene
  101744. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  101745. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  101746. */
  101747. constructor(
  101748. /** defines the name of the probe */
  101749. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  101750. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  101751. samples: number;
  101752. /** Gets or sets the refresh rate to use (on every frame by default) */
  101753. refreshRate: number;
  101754. /**
  101755. * Gets the hosting scene
  101756. * @returns a Scene
  101757. */
  101758. getScene(): Scene;
  101759. /** Gets the internal CubeTexture used to render to */
  101760. readonly cubeTexture: RenderTargetTexture;
  101761. /** Gets the list of meshes to render */
  101762. readonly renderList: Nullable<AbstractMesh[]>;
  101763. /**
  101764. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  101765. * @param mesh defines the mesh to attach to
  101766. */
  101767. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  101768. /**
  101769. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  101770. * @param renderingGroupId The rendering group id corresponding to its index
  101771. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101772. */
  101773. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101774. /**
  101775. * Clean all associated resources
  101776. */
  101777. dispose(): void;
  101778. /**
  101779. * Converts the reflection probe information to a readable string for debug purpose.
  101780. * @param fullDetails Supports for multiple levels of logging within scene loading
  101781. * @returns the human readable reflection probe info
  101782. */
  101783. toString(fullDetails?: boolean): string;
  101784. /**
  101785. * Get the class name of the relfection probe.
  101786. * @returns "ReflectionProbe"
  101787. */
  101788. getClassName(): string;
  101789. /**
  101790. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  101791. * @returns The JSON representation of the texture
  101792. */
  101793. serialize(): any;
  101794. /**
  101795. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  101796. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  101797. * @param scene Define the scene the parsed reflection probe should be instantiated in
  101798. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101799. * @returns The parsed reflection probe if successful
  101800. */
  101801. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  101802. }
  101803. }
  101804. declare module BABYLON {
  101805. /** @hidden */
  101806. export var _BabylonLoaderRegistered: boolean;
  101807. }
  101808. declare module BABYLON {
  101809. /**
  101810. * The Physically based simple base material of BJS.
  101811. *
  101812. * This enables better naming and convention enforcements on top of the pbrMaterial.
  101813. * It is used as the base class for both the specGloss and metalRough conventions.
  101814. */
  101815. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  101816. /**
  101817. * Number of Simultaneous lights allowed on the material.
  101818. */
  101819. maxSimultaneousLights: number;
  101820. /**
  101821. * If sets to true, disables all the lights affecting the material.
  101822. */
  101823. disableLighting: boolean;
  101824. /**
  101825. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  101826. */
  101827. environmentTexture: BaseTexture;
  101828. /**
  101829. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101830. */
  101831. invertNormalMapX: boolean;
  101832. /**
  101833. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101834. */
  101835. invertNormalMapY: boolean;
  101836. /**
  101837. * Normal map used in the model.
  101838. */
  101839. normalTexture: BaseTexture;
  101840. /**
  101841. * Emissivie color used to self-illuminate the model.
  101842. */
  101843. emissiveColor: Color3;
  101844. /**
  101845. * Emissivie texture used to self-illuminate the model.
  101846. */
  101847. emissiveTexture: BaseTexture;
  101848. /**
  101849. * Occlusion Channel Strenght.
  101850. */
  101851. occlusionStrength: number;
  101852. /**
  101853. * Occlusion Texture of the material (adding extra occlusion effects).
  101854. */
  101855. occlusionTexture: BaseTexture;
  101856. /**
  101857. * Defines the alpha limits in alpha test mode.
  101858. */
  101859. alphaCutOff: number;
  101860. /**
  101861. * Gets the current double sided mode.
  101862. */
  101863. /**
  101864. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101865. */
  101866. doubleSided: boolean;
  101867. /**
  101868. * Stores the pre-calculated light information of a mesh in a texture.
  101869. */
  101870. lightmapTexture: BaseTexture;
  101871. /**
  101872. * If true, the light map contains occlusion information instead of lighting info.
  101873. */
  101874. useLightmapAsShadowmap: boolean;
  101875. /**
  101876. * Return the active textures of the material.
  101877. */
  101878. getActiveTextures(): BaseTexture[];
  101879. hasTexture(texture: BaseTexture): boolean;
  101880. /**
  101881. * Instantiates a new PBRMaterial instance.
  101882. *
  101883. * @param name The material name
  101884. * @param scene The scene the material will be use in.
  101885. */
  101886. constructor(name: string, scene: Scene);
  101887. getClassName(): string;
  101888. }
  101889. }
  101890. declare module BABYLON {
  101891. /**
  101892. * The PBR material of BJS following the metal roughness convention.
  101893. *
  101894. * This fits to the PBR convention in the GLTF definition:
  101895. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  101896. */
  101897. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  101898. /**
  101899. * The base color has two different interpretations depending on the value of metalness.
  101900. * When the material is a metal, the base color is the specific measured reflectance value
  101901. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  101902. * of the material.
  101903. */
  101904. baseColor: Color3;
  101905. /**
  101906. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  101907. * well as opacity information in the alpha channel.
  101908. */
  101909. baseTexture: BaseTexture;
  101910. /**
  101911. * Specifies the metallic scalar value of the material.
  101912. * Can also be used to scale the metalness values of the metallic texture.
  101913. */
  101914. metallic: number;
  101915. /**
  101916. * Specifies the roughness scalar value of the material.
  101917. * Can also be used to scale the roughness values of the metallic texture.
  101918. */
  101919. roughness: number;
  101920. /**
  101921. * Texture containing both the metallic value in the B channel and the
  101922. * roughness value in the G channel to keep better precision.
  101923. */
  101924. metallicRoughnessTexture: BaseTexture;
  101925. /**
  101926. * Instantiates a new PBRMetalRoughnessMaterial instance.
  101927. *
  101928. * @param name The material name
  101929. * @param scene The scene the material will be use in.
  101930. */
  101931. constructor(name: string, scene: Scene);
  101932. /**
  101933. * Return the currrent class name of the material.
  101934. */
  101935. getClassName(): string;
  101936. /**
  101937. * Return the active textures of the material.
  101938. */
  101939. getActiveTextures(): BaseTexture[];
  101940. /**
  101941. * Checks to see if a texture is used in the material.
  101942. * @param texture - Base texture to use.
  101943. * @returns - Boolean specifying if a texture is used in the material.
  101944. */
  101945. hasTexture(texture: BaseTexture): boolean;
  101946. /**
  101947. * Makes a duplicate of the current material.
  101948. * @param name - name to use for the new material.
  101949. */
  101950. clone(name: string): PBRMetallicRoughnessMaterial;
  101951. /**
  101952. * Serialize the material to a parsable JSON object.
  101953. */
  101954. serialize(): any;
  101955. /**
  101956. * Parses a JSON object correponding to the serialize function.
  101957. */
  101958. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  101959. }
  101960. }
  101961. declare module BABYLON {
  101962. /**
  101963. * The PBR material of BJS following the specular glossiness convention.
  101964. *
  101965. * This fits to the PBR convention in the GLTF definition:
  101966. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  101967. */
  101968. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  101969. /**
  101970. * Specifies the diffuse color of the material.
  101971. */
  101972. diffuseColor: Color3;
  101973. /**
  101974. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  101975. * channel.
  101976. */
  101977. diffuseTexture: BaseTexture;
  101978. /**
  101979. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  101980. */
  101981. specularColor: Color3;
  101982. /**
  101983. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  101984. */
  101985. glossiness: number;
  101986. /**
  101987. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  101988. */
  101989. specularGlossinessTexture: BaseTexture;
  101990. /**
  101991. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  101992. *
  101993. * @param name The material name
  101994. * @param scene The scene the material will be use in.
  101995. */
  101996. constructor(name: string, scene: Scene);
  101997. /**
  101998. * Return the currrent class name of the material.
  101999. */
  102000. getClassName(): string;
  102001. /**
  102002. * Return the active textures of the material.
  102003. */
  102004. getActiveTextures(): BaseTexture[];
  102005. /**
  102006. * Checks to see if a texture is used in the material.
  102007. * @param texture - Base texture to use.
  102008. * @returns - Boolean specifying if a texture is used in the material.
  102009. */
  102010. hasTexture(texture: BaseTexture): boolean;
  102011. /**
  102012. * Makes a duplicate of the current material.
  102013. * @param name - name to use for the new material.
  102014. */
  102015. clone(name: string): PBRSpecularGlossinessMaterial;
  102016. /**
  102017. * Serialize the material to a parsable JSON object.
  102018. */
  102019. serialize(): any;
  102020. /**
  102021. * Parses a JSON object correponding to the serialize function.
  102022. */
  102023. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  102024. }
  102025. }
  102026. declare module BABYLON {
  102027. /**
  102028. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  102029. * It can help converting any input color in a desired output one. This can then be used to create effects
  102030. * from sepia, black and white to sixties or futuristic rendering...
  102031. *
  102032. * The only supported format is currently 3dl.
  102033. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  102034. */
  102035. export class ColorGradingTexture extends BaseTexture {
  102036. /**
  102037. * The current texture matrix. (will always be identity in color grading texture)
  102038. */
  102039. private _textureMatrix;
  102040. /**
  102041. * The texture URL.
  102042. */
  102043. url: string;
  102044. /**
  102045. * Empty line regex stored for GC.
  102046. */
  102047. private static _noneEmptyLineRegex;
  102048. private _engine;
  102049. /**
  102050. * Instantiates a ColorGradingTexture from the following parameters.
  102051. *
  102052. * @param url The location of the color gradind data (currently only supporting 3dl)
  102053. * @param scene The scene the texture will be used in
  102054. */
  102055. constructor(url: string, scene: Scene);
  102056. /**
  102057. * Returns the texture matrix used in most of the material.
  102058. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  102059. */
  102060. getTextureMatrix(): Matrix;
  102061. /**
  102062. * Occurs when the file being loaded is a .3dl LUT file.
  102063. */
  102064. private load3dlTexture;
  102065. /**
  102066. * Starts the loading process of the texture.
  102067. */
  102068. private loadTexture;
  102069. /**
  102070. * Clones the color gradind texture.
  102071. */
  102072. clone(): ColorGradingTexture;
  102073. /**
  102074. * Called during delayed load for textures.
  102075. */
  102076. delayLoad(): void;
  102077. /**
  102078. * Parses a color grading texture serialized by Babylon.
  102079. * @param parsedTexture The texture information being parsedTexture
  102080. * @param scene The scene to load the texture in
  102081. * @param rootUrl The root url of the data assets to load
  102082. * @return A color gradind texture
  102083. */
  102084. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  102085. /**
  102086. * Serializes the LUT texture to json format.
  102087. */
  102088. serialize(): any;
  102089. }
  102090. }
  102091. declare module BABYLON {
  102092. /**
  102093. * Direct draw surface info
  102094. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  102095. */
  102096. export interface DDSInfo {
  102097. /**
  102098. * Width of the texture
  102099. */
  102100. width: number;
  102101. /**
  102102. * Width of the texture
  102103. */
  102104. height: number;
  102105. /**
  102106. * Number of Mipmaps for the texture
  102107. * @see https://en.wikipedia.org/wiki/Mipmap
  102108. */
  102109. mipmapCount: number;
  102110. /**
  102111. * If the textures format is a known fourCC format
  102112. * @see https://www.fourcc.org/
  102113. */
  102114. isFourCC: boolean;
  102115. /**
  102116. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  102117. */
  102118. isRGB: boolean;
  102119. /**
  102120. * If the texture is a lumincance format
  102121. */
  102122. isLuminance: boolean;
  102123. /**
  102124. * If this is a cube texture
  102125. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  102126. */
  102127. isCube: boolean;
  102128. /**
  102129. * If the texture is a compressed format eg. FOURCC_DXT1
  102130. */
  102131. isCompressed: boolean;
  102132. /**
  102133. * The dxgiFormat of the texture
  102134. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  102135. */
  102136. dxgiFormat: number;
  102137. /**
  102138. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  102139. */
  102140. textureType: number;
  102141. /**
  102142. * Sphericle polynomial created for the dds texture
  102143. */
  102144. sphericalPolynomial?: SphericalPolynomial;
  102145. }
  102146. /**
  102147. * Class used to provide DDS decompression tools
  102148. */
  102149. export class DDSTools {
  102150. /**
  102151. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  102152. */
  102153. static StoreLODInAlphaChannel: boolean;
  102154. /**
  102155. * Gets DDS information from an array buffer
  102156. * @param arrayBuffer defines the array buffer to read data from
  102157. * @returns the DDS information
  102158. */
  102159. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  102160. private static _FloatView;
  102161. private static _Int32View;
  102162. private static _ToHalfFloat;
  102163. private static _FromHalfFloat;
  102164. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  102165. private static _GetHalfFloatRGBAArrayBuffer;
  102166. private static _GetFloatRGBAArrayBuffer;
  102167. private static _GetFloatAsUIntRGBAArrayBuffer;
  102168. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  102169. private static _GetRGBAArrayBuffer;
  102170. private static _ExtractLongWordOrder;
  102171. private static _GetRGBArrayBuffer;
  102172. private static _GetLuminanceArrayBuffer;
  102173. /**
  102174. * Uploads DDS Levels to a Babylon Texture
  102175. * @hidden
  102176. */
  102177. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  102178. }
  102179. interface Engine {
  102180. /**
  102181. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  102182. * @param rootUrl defines the url where the file to load is located
  102183. * @param scene defines the current scene
  102184. * @param lodScale defines scale to apply to the mip map selection
  102185. * @param lodOffset defines offset to apply to the mip map selection
  102186. * @param onLoad defines an optional callback raised when the texture is loaded
  102187. * @param onError defines an optional callback raised if there is an issue to load the texture
  102188. * @param format defines the format of the data
  102189. * @param forcedExtension defines the extension to use to pick the right loader
  102190. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  102191. * @returns the cube texture as an InternalTexture
  102192. */
  102193. 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;
  102194. }
  102195. }
  102196. declare module BABYLON {
  102197. /**
  102198. * Implementation of the DDS Texture Loader.
  102199. * @hidden
  102200. */
  102201. export class _DDSTextureLoader implements IInternalTextureLoader {
  102202. /**
  102203. * Defines wether the loader supports cascade loading the different faces.
  102204. */
  102205. readonly supportCascades: boolean;
  102206. /**
  102207. * This returns if the loader support the current file information.
  102208. * @param extension defines the file extension of the file being loaded
  102209. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102210. * @param fallback defines the fallback internal texture if any
  102211. * @param isBase64 defines whether the texture is encoded as a base64
  102212. * @param isBuffer defines whether the texture data are stored as a buffer
  102213. * @returns true if the loader can load the specified file
  102214. */
  102215. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102216. /**
  102217. * Transform the url before loading if required.
  102218. * @param rootUrl the url of the texture
  102219. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102220. * @returns the transformed texture
  102221. */
  102222. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102223. /**
  102224. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102225. * @param rootUrl the url of the texture
  102226. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102227. * @returns the fallback texture
  102228. */
  102229. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102230. /**
  102231. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102232. * @param data contains the texture data
  102233. * @param texture defines the BabylonJS internal texture
  102234. * @param createPolynomials will be true if polynomials have been requested
  102235. * @param onLoad defines the callback to trigger once the texture is ready
  102236. * @param onError defines the callback to trigger in case of error
  102237. */
  102238. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102239. /**
  102240. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102241. * @param data contains the texture data
  102242. * @param texture defines the BabylonJS internal texture
  102243. * @param callback defines the method to call once ready to upload
  102244. */
  102245. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102246. }
  102247. }
  102248. declare module BABYLON {
  102249. /** @hidden */
  102250. export var rgbdEncodePixelShader: {
  102251. name: string;
  102252. shader: string;
  102253. };
  102254. }
  102255. declare module BABYLON {
  102256. /** @hidden */
  102257. export var rgbdDecodePixelShader: {
  102258. name: string;
  102259. shader: string;
  102260. };
  102261. }
  102262. declare module BABYLON {
  102263. /**
  102264. * Raw texture data and descriptor sufficient for WebGL texture upload
  102265. */
  102266. export interface EnvironmentTextureInfo {
  102267. /**
  102268. * Version of the environment map
  102269. */
  102270. version: number;
  102271. /**
  102272. * Width of image
  102273. */
  102274. width: number;
  102275. /**
  102276. * Irradiance information stored in the file.
  102277. */
  102278. irradiance: any;
  102279. /**
  102280. * Specular information stored in the file.
  102281. */
  102282. specular: any;
  102283. }
  102284. /**
  102285. * Sets of helpers addressing the serialization and deserialization of environment texture
  102286. * stored in a BabylonJS env file.
  102287. * Those files are usually stored as .env files.
  102288. */
  102289. export class EnvironmentTextureTools {
  102290. /**
  102291. * Magic number identifying the env file.
  102292. */
  102293. private static _MagicBytes;
  102294. /**
  102295. * Gets the environment info from an env file.
  102296. * @param data The array buffer containing the .env bytes.
  102297. * @returns the environment file info (the json header) if successfully parsed.
  102298. */
  102299. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  102300. /**
  102301. * Creates an environment texture from a loaded cube texture.
  102302. * @param texture defines the cube texture to convert in env file
  102303. * @return a promise containing the environment data if succesfull.
  102304. */
  102305. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  102306. /**
  102307. * Creates a JSON representation of the spherical data.
  102308. * @param texture defines the texture containing the polynomials
  102309. * @return the JSON representation of the spherical info
  102310. */
  102311. private static _CreateEnvTextureIrradiance;
  102312. /**
  102313. * Uploads the texture info contained in the env file to the GPU.
  102314. * @param texture defines the internal texture to upload to
  102315. * @param arrayBuffer defines the buffer cotaining the data to load
  102316. * @param info defines the texture info retrieved through the GetEnvInfo method
  102317. * @returns a promise
  102318. */
  102319. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  102320. /**
  102321. * Uploads the levels of image data to the GPU.
  102322. * @param texture defines the internal texture to upload to
  102323. * @param imageData defines the array buffer views of image data [mipmap][face]
  102324. * @returns a promise
  102325. */
  102326. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  102327. /**
  102328. * Uploads spherical polynomials information to the texture.
  102329. * @param texture defines the texture we are trying to upload the information to
  102330. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  102331. */
  102332. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  102333. /** @hidden */
  102334. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102335. }
  102336. }
  102337. declare module BABYLON {
  102338. /**
  102339. * Implementation of the ENV Texture Loader.
  102340. * @hidden
  102341. */
  102342. export class _ENVTextureLoader implements IInternalTextureLoader {
  102343. /**
  102344. * Defines wether the loader supports cascade loading the different faces.
  102345. */
  102346. readonly supportCascades: boolean;
  102347. /**
  102348. * This returns if the loader support the current file information.
  102349. * @param extension defines the file extension of the file being loaded
  102350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102351. * @param fallback defines the fallback internal texture if any
  102352. * @param isBase64 defines whether the texture is encoded as a base64
  102353. * @param isBuffer defines whether the texture data are stored as a buffer
  102354. * @returns true if the loader can load the specified file
  102355. */
  102356. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102357. /**
  102358. * Transform the url before loading if required.
  102359. * @param rootUrl the url of the texture
  102360. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102361. * @returns the transformed texture
  102362. */
  102363. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102364. /**
  102365. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102366. * @param rootUrl the url of the texture
  102367. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102368. * @returns the fallback texture
  102369. */
  102370. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102371. /**
  102372. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102373. * @param data contains the texture data
  102374. * @param texture defines the BabylonJS internal texture
  102375. * @param createPolynomials will be true if polynomials have been requested
  102376. * @param onLoad defines the callback to trigger once the texture is ready
  102377. * @param onError defines the callback to trigger in case of error
  102378. */
  102379. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102380. /**
  102381. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102382. * @param data contains the texture data
  102383. * @param texture defines the BabylonJS internal texture
  102384. * @param callback defines the method to call once ready to upload
  102385. */
  102386. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102387. }
  102388. }
  102389. declare module BABYLON {
  102390. /**
  102391. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  102392. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  102393. */
  102394. export class KhronosTextureContainer {
  102395. /** contents of the KTX container file */
  102396. arrayBuffer: any;
  102397. private static HEADER_LEN;
  102398. private static COMPRESSED_2D;
  102399. private static COMPRESSED_3D;
  102400. private static TEX_2D;
  102401. private static TEX_3D;
  102402. /**
  102403. * Gets the openGL type
  102404. */
  102405. glType: number;
  102406. /**
  102407. * Gets the openGL type size
  102408. */
  102409. glTypeSize: number;
  102410. /**
  102411. * Gets the openGL format
  102412. */
  102413. glFormat: number;
  102414. /**
  102415. * Gets the openGL internal format
  102416. */
  102417. glInternalFormat: number;
  102418. /**
  102419. * Gets the base internal format
  102420. */
  102421. glBaseInternalFormat: number;
  102422. /**
  102423. * Gets image width in pixel
  102424. */
  102425. pixelWidth: number;
  102426. /**
  102427. * Gets image height in pixel
  102428. */
  102429. pixelHeight: number;
  102430. /**
  102431. * Gets image depth in pixels
  102432. */
  102433. pixelDepth: number;
  102434. /**
  102435. * Gets the number of array elements
  102436. */
  102437. numberOfArrayElements: number;
  102438. /**
  102439. * Gets the number of faces
  102440. */
  102441. numberOfFaces: number;
  102442. /**
  102443. * Gets the number of mipmap levels
  102444. */
  102445. numberOfMipmapLevels: number;
  102446. /**
  102447. * Gets the bytes of key value data
  102448. */
  102449. bytesOfKeyValueData: number;
  102450. /**
  102451. * Gets the load type
  102452. */
  102453. loadType: number;
  102454. /**
  102455. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  102456. */
  102457. isInvalid: boolean;
  102458. /**
  102459. * Creates a new KhronosTextureContainer
  102460. * @param arrayBuffer contents of the KTX container file
  102461. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  102462. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  102463. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  102464. */
  102465. constructor(
  102466. /** contents of the KTX container file */
  102467. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  102468. /**
  102469. * Uploads KTX content to a Babylon Texture.
  102470. * It is assumed that the texture has already been created & is currently bound
  102471. * @hidden
  102472. */
  102473. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  102474. private _upload2DCompressedLevels;
  102475. }
  102476. }
  102477. declare module BABYLON {
  102478. /**
  102479. * Implementation of the KTX Texture Loader.
  102480. * @hidden
  102481. */
  102482. export class _KTXTextureLoader implements IInternalTextureLoader {
  102483. /**
  102484. * Defines wether the loader supports cascade loading the different faces.
  102485. */
  102486. readonly supportCascades: boolean;
  102487. /**
  102488. * This returns if the loader support the current file information.
  102489. * @param extension defines the file extension of the file being loaded
  102490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102491. * @param fallback defines the fallback internal texture if any
  102492. * @param isBase64 defines whether the texture is encoded as a base64
  102493. * @param isBuffer defines whether the texture data are stored as a buffer
  102494. * @returns true if the loader can load the specified file
  102495. */
  102496. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102497. /**
  102498. * Transform the url before loading if required.
  102499. * @param rootUrl the url of the texture
  102500. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102501. * @returns the transformed texture
  102502. */
  102503. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102504. /**
  102505. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102506. * @param rootUrl the url of the texture
  102507. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102508. * @returns the fallback texture
  102509. */
  102510. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102511. /**
  102512. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102513. * @param data contains the texture data
  102514. * @param texture defines the BabylonJS internal texture
  102515. * @param createPolynomials will be true if polynomials have been requested
  102516. * @param onLoad defines the callback to trigger once the texture is ready
  102517. * @param onError defines the callback to trigger in case of error
  102518. */
  102519. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102520. /**
  102521. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102522. * @param data contains the texture data
  102523. * @param texture defines the BabylonJS internal texture
  102524. * @param callback defines the method to call once ready to upload
  102525. */
  102526. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  102527. }
  102528. }
  102529. declare module BABYLON {
  102530. /**
  102531. * Based on jsTGALoader - Javascript loader for TGA file
  102532. * By Vincent Thibault
  102533. * @see http://blog.robrowser.com/javascript-tga-loader.html
  102534. */
  102535. export class TGATools {
  102536. private static _TYPE_INDEXED;
  102537. private static _TYPE_RGB;
  102538. private static _TYPE_GREY;
  102539. private static _TYPE_RLE_INDEXED;
  102540. private static _TYPE_RLE_RGB;
  102541. private static _TYPE_RLE_GREY;
  102542. private static _ORIGIN_MASK;
  102543. private static _ORIGIN_SHIFT;
  102544. private static _ORIGIN_BL;
  102545. private static _ORIGIN_BR;
  102546. private static _ORIGIN_UL;
  102547. private static _ORIGIN_UR;
  102548. /**
  102549. * Gets the header of a TGA file
  102550. * @param data defines the TGA data
  102551. * @returns the header
  102552. */
  102553. static GetTGAHeader(data: Uint8Array): any;
  102554. /**
  102555. * Uploads TGA content to a Babylon Texture
  102556. * @hidden
  102557. */
  102558. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  102559. /** @hidden */
  102560. 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;
  102561. /** @hidden */
  102562. 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;
  102563. /** @hidden */
  102564. 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;
  102565. /** @hidden */
  102566. 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;
  102567. /** @hidden */
  102568. 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;
  102569. /** @hidden */
  102570. 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;
  102571. }
  102572. }
  102573. declare module BABYLON {
  102574. /**
  102575. * Implementation of the TGA Texture Loader.
  102576. * @hidden
  102577. */
  102578. export class _TGATextureLoader implements IInternalTextureLoader {
  102579. /**
  102580. * Defines wether the loader supports cascade loading the different faces.
  102581. */
  102582. readonly supportCascades: boolean;
  102583. /**
  102584. * This returns if the loader support the current file information.
  102585. * @param extension defines the file extension of the file being loaded
  102586. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102587. * @param fallback defines the fallback internal texture if any
  102588. * @param isBase64 defines whether the texture is encoded as a base64
  102589. * @param isBuffer defines whether the texture data are stored as a buffer
  102590. * @returns true if the loader can load the specified file
  102591. */
  102592. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  102593. /**
  102594. * Transform the url before loading if required.
  102595. * @param rootUrl the url of the texture
  102596. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102597. * @returns the transformed texture
  102598. */
  102599. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  102600. /**
  102601. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  102602. * @param rootUrl the url of the texture
  102603. * @param textureFormatInUse defines the current compressed format in use iun the engine
  102604. * @returns the fallback texture
  102605. */
  102606. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  102607. /**
  102608. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  102609. * @param data contains the texture data
  102610. * @param texture defines the BabylonJS internal texture
  102611. * @param createPolynomials will be true if polynomials have been requested
  102612. * @param onLoad defines the callback to trigger once the texture is ready
  102613. * @param onError defines the callback to trigger in case of error
  102614. */
  102615. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  102616. /**
  102617. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  102618. * @param data contains the texture data
  102619. * @param texture defines the BabylonJS internal texture
  102620. * @param callback defines the method to call once ready to upload
  102621. */
  102622. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  102623. }
  102624. }
  102625. declare module BABYLON {
  102626. /**
  102627. * 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.
  102628. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102629. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102630. */
  102631. export class CustomProceduralTexture extends ProceduralTexture {
  102632. private _animate;
  102633. private _time;
  102634. private _config;
  102635. private _texturePath;
  102636. /**
  102637. * Instantiates a new Custom Procedural Texture.
  102638. * 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.
  102639. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  102640. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  102641. * @param name Define the name of the texture
  102642. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  102643. * @param size Define the size of the texture to create
  102644. * @param scene Define the scene the texture belongs to
  102645. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  102646. * @param generateMipMaps Define if the texture should creates mip maps or not
  102647. */
  102648. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102649. private _loadJson;
  102650. /**
  102651. * Is the texture ready to be used ? (rendered at least once)
  102652. * @returns true if ready, otherwise, false.
  102653. */
  102654. isReady(): boolean;
  102655. /**
  102656. * Render the texture to its associated render target.
  102657. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  102658. */
  102659. render(useCameraPostProcess?: boolean): void;
  102660. /**
  102661. * Update the list of dependant textures samplers in the shader.
  102662. */
  102663. updateTextures(): void;
  102664. /**
  102665. * Update the uniform values of the procedural texture in the shader.
  102666. */
  102667. updateShaderUniforms(): void;
  102668. /**
  102669. * Define if the texture animates or not.
  102670. */
  102671. animate: boolean;
  102672. }
  102673. }
  102674. declare module BABYLON {
  102675. /** @hidden */
  102676. export var noisePixelShader: {
  102677. name: string;
  102678. shader: string;
  102679. };
  102680. }
  102681. declare module BABYLON {
  102682. /**
  102683. * Class used to generate noise procedural textures
  102684. */
  102685. export class NoiseProceduralTexture extends ProceduralTexture {
  102686. private _time;
  102687. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  102688. brightness: number;
  102689. /** Defines the number of octaves to process */
  102690. octaves: number;
  102691. /** Defines the level of persistence (0.8 by default) */
  102692. persistence: number;
  102693. /** Gets or sets animation speed factor (default is 1) */
  102694. animationSpeedFactor: number;
  102695. /**
  102696. * Creates a new NoiseProceduralTexture
  102697. * @param name defines the name fo the texture
  102698. * @param size defines the size of the texture (default is 256)
  102699. * @param scene defines the hosting scene
  102700. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  102701. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  102702. */
  102703. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  102704. private _updateShaderUniforms;
  102705. protected _getDefines(): string;
  102706. /** Generate the current state of the procedural texture */
  102707. render(useCameraPostProcess?: boolean): void;
  102708. /**
  102709. * Serializes this noise procedural texture
  102710. * @returns a serialized noise procedural texture object
  102711. */
  102712. serialize(): any;
  102713. /**
  102714. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  102715. * @param parsedTexture defines parsed texture data
  102716. * @param scene defines the current scene
  102717. * @param rootUrl defines the root URL containing noise procedural texture information
  102718. * @returns a parsed NoiseProceduralTexture
  102719. */
  102720. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  102721. }
  102722. }
  102723. declare module BABYLON {
  102724. /**
  102725. * Raw cube texture where the raw buffers are passed in
  102726. */
  102727. export class RawCubeTexture extends CubeTexture {
  102728. /**
  102729. * Creates a cube texture where the raw buffers are passed in.
  102730. * @param scene defines the scene the texture is attached to
  102731. * @param data defines the array of data to use to create each face
  102732. * @param size defines the size of the textures
  102733. * @param format defines the format of the data
  102734. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  102735. * @param generateMipMaps defines if the engine should generate the mip levels
  102736. * @param invertY defines if data must be stored with Y axis inverted
  102737. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  102738. * @param compression defines the compression used (null by default)
  102739. */
  102740. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  102741. /**
  102742. * Updates the raw cube texture.
  102743. * @param data defines the data to store
  102744. * @param format defines the data format
  102745. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  102746. * @param invertY defines if data must be stored with Y axis inverted
  102747. * @param compression defines the compression used (null by default)
  102748. * @param level defines which level of the texture to update
  102749. */
  102750. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  102751. /**
  102752. * Updates a raw cube texture with RGBD encoded data.
  102753. * @param data defines the array of data [mipmap][face] to use to create each face
  102754. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  102755. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  102756. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  102757. * @returns a promsie that resolves when the operation is complete
  102758. */
  102759. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  102760. /**
  102761. * Clones the raw cube texture.
  102762. * @return a new cube texture
  102763. */
  102764. clone(): CubeTexture;
  102765. /** @hidden */
  102766. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  102767. }
  102768. }
  102769. declare module BABYLON {
  102770. /**
  102771. * Class used to store 3D textures containing user data
  102772. */
  102773. export class RawTexture3D extends Texture {
  102774. /** Gets or sets the texture format to use */
  102775. format: number;
  102776. private _engine;
  102777. /**
  102778. * Create a new RawTexture3D
  102779. * @param data defines the data of the texture
  102780. * @param width defines the width of the texture
  102781. * @param height defines the height of the texture
  102782. * @param depth defines the depth of the texture
  102783. * @param format defines the texture format to use
  102784. * @param scene defines the hosting scene
  102785. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  102786. * @param invertY defines if texture must be stored with Y axis inverted
  102787. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  102788. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  102789. */
  102790. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  102791. /** Gets or sets the texture format to use */
  102792. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  102793. /**
  102794. * Update the texture with new data
  102795. * @param data defines the data to store in the texture
  102796. */
  102797. update(data: ArrayBufferView): void;
  102798. }
  102799. }
  102800. declare module BABYLON {
  102801. /**
  102802. * Creates a refraction texture used by refraction channel of the standard material.
  102803. * It is like a mirror but to see through a material.
  102804. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102805. */
  102806. export class RefractionTexture extends RenderTargetTexture {
  102807. /**
  102808. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  102809. * 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.
  102810. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102811. */
  102812. refractionPlane: Plane;
  102813. /**
  102814. * Define how deep under the surface we should see.
  102815. */
  102816. depth: number;
  102817. /**
  102818. * Creates a refraction texture used by refraction channel of the standard material.
  102819. * It is like a mirror but to see through a material.
  102820. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  102821. * @param name Define the texture name
  102822. * @param size Define the size of the underlying texture
  102823. * @param scene Define the scene the refraction belongs to
  102824. * @param generateMipMaps Define if we need to generate mips level for the refraction
  102825. */
  102826. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  102827. /**
  102828. * Clone the refraction texture.
  102829. * @returns the cloned texture
  102830. */
  102831. clone(): RefractionTexture;
  102832. /**
  102833. * Serialize the texture to a JSON representation you could use in Parse later on
  102834. * @returns the serialized JSON representation
  102835. */
  102836. serialize(): any;
  102837. }
  102838. }
  102839. declare module BABYLON {
  102840. /**
  102841. * Configuration for Draco compression
  102842. */
  102843. export interface IDracoCompressionConfiguration {
  102844. /**
  102845. * Configuration for the decoder.
  102846. */
  102847. decoder?: {
  102848. /**
  102849. * The url to the WebAssembly module.
  102850. */
  102851. wasmUrl?: string;
  102852. /**
  102853. * The url to the WebAssembly binary.
  102854. */
  102855. wasmBinaryUrl?: string;
  102856. /**
  102857. * The url to the fallback JavaScript module.
  102858. */
  102859. fallbackUrl?: string;
  102860. };
  102861. }
  102862. /**
  102863. * Draco compression (https://google.github.io/draco/)
  102864. *
  102865. * This class wraps the Draco module.
  102866. *
  102867. * **Encoder**
  102868. *
  102869. * The encoder is not currently implemented.
  102870. *
  102871. * **Decoder**
  102872. *
  102873. * 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.
  102874. *
  102875. * To update the configuration, use the following code:
  102876. * ```javascript
  102877. * DracoCompression.Configuration = {
  102878. * decoder: {
  102879. * wasmUrl: "<url to the WebAssembly library>",
  102880. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  102881. * fallbackUrl: "<url to the fallback JavaScript library>",
  102882. * }
  102883. * };
  102884. * ```
  102885. *
  102886. * 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.
  102887. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  102888. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  102889. *
  102890. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  102891. * ```javascript
  102892. * var dracoCompression = new DracoCompression();
  102893. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  102894. * [VertexBuffer.PositionKind]: 0
  102895. * });
  102896. * ```
  102897. *
  102898. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  102899. */
  102900. export class DracoCompression implements IDisposable {
  102901. private static _DecoderModulePromise;
  102902. /**
  102903. * The configuration. Defaults to the following urls:
  102904. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  102905. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  102906. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  102907. */
  102908. static Configuration: IDracoCompressionConfiguration;
  102909. /**
  102910. * Returns true if the decoder is available.
  102911. */
  102912. static readonly DecoderAvailable: boolean;
  102913. /**
  102914. * Constructor
  102915. */
  102916. constructor();
  102917. /**
  102918. * Stop all async operations and release resources.
  102919. */
  102920. dispose(): void;
  102921. /**
  102922. * Decode Draco compressed mesh data to vertex data.
  102923. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  102924. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  102925. * @returns A promise that resolves with the decoded vertex data
  102926. */
  102927. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  102928. [kind: string]: number;
  102929. }): Promise<VertexData>;
  102930. private static _GetDecoderModule;
  102931. private static _LoadScriptAsync;
  102932. private static _LoadFileAsync;
  102933. }
  102934. }
  102935. declare module BABYLON {
  102936. /**
  102937. * Class for building Constructive Solid Geometry
  102938. */
  102939. export class CSG {
  102940. private polygons;
  102941. /**
  102942. * The world matrix
  102943. */
  102944. matrix: Matrix;
  102945. /**
  102946. * Stores the position
  102947. */
  102948. position: Vector3;
  102949. /**
  102950. * Stores the rotation
  102951. */
  102952. rotation: Vector3;
  102953. /**
  102954. * Stores the rotation quaternion
  102955. */
  102956. rotationQuaternion: Nullable<Quaternion>;
  102957. /**
  102958. * Stores the scaling vector
  102959. */
  102960. scaling: Vector3;
  102961. /**
  102962. * Convert the Mesh to CSG
  102963. * @param mesh The Mesh to convert to CSG
  102964. * @returns A new CSG from the Mesh
  102965. */
  102966. static FromMesh(mesh: Mesh): CSG;
  102967. /**
  102968. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  102969. * @param polygons Polygons used to construct a CSG solid
  102970. */
  102971. private static FromPolygons;
  102972. /**
  102973. * Clones, or makes a deep copy, of the CSG
  102974. * @returns A new CSG
  102975. */
  102976. clone(): CSG;
  102977. /**
  102978. * Unions this CSG with another CSG
  102979. * @param csg The CSG to union against this CSG
  102980. * @returns The unioned CSG
  102981. */
  102982. union(csg: CSG): CSG;
  102983. /**
  102984. * Unions this CSG with another CSG in place
  102985. * @param csg The CSG to union against this CSG
  102986. */
  102987. unionInPlace(csg: CSG): void;
  102988. /**
  102989. * Subtracts this CSG with another CSG
  102990. * @param csg The CSG to subtract against this CSG
  102991. * @returns A new CSG
  102992. */
  102993. subtract(csg: CSG): CSG;
  102994. /**
  102995. * Subtracts this CSG with another CSG in place
  102996. * @param csg The CSG to subtact against this CSG
  102997. */
  102998. subtractInPlace(csg: CSG): void;
  102999. /**
  103000. * Intersect this CSG with another CSG
  103001. * @param csg The CSG to intersect against this CSG
  103002. * @returns A new CSG
  103003. */
  103004. intersect(csg: CSG): CSG;
  103005. /**
  103006. * Intersects this CSG with another CSG in place
  103007. * @param csg The CSG to intersect against this CSG
  103008. */
  103009. intersectInPlace(csg: CSG): void;
  103010. /**
  103011. * Return a new CSG solid with solid and empty space switched. This solid is
  103012. * not modified.
  103013. * @returns A new CSG solid with solid and empty space switched
  103014. */
  103015. inverse(): CSG;
  103016. /**
  103017. * Inverses the CSG in place
  103018. */
  103019. inverseInPlace(): void;
  103020. /**
  103021. * This is used to keep meshes transformations so they can be restored
  103022. * when we build back a Babylon Mesh
  103023. * NB : All CSG operations are performed in world coordinates
  103024. * @param csg The CSG to copy the transform attributes from
  103025. * @returns This CSG
  103026. */
  103027. copyTransformAttributes(csg: CSG): CSG;
  103028. /**
  103029. * Build Raw mesh from CSG
  103030. * Coordinates here are in world space
  103031. * @param name The name of the mesh geometry
  103032. * @param scene The Scene
  103033. * @param keepSubMeshes Specifies if the submeshes should be kept
  103034. * @returns A new Mesh
  103035. */
  103036. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  103037. /**
  103038. * Build Mesh from CSG taking material and transforms into account
  103039. * @param name The name of the Mesh
  103040. * @param material The material of the Mesh
  103041. * @param scene The Scene
  103042. * @param keepSubMeshes Specifies if submeshes should be kept
  103043. * @returns The new Mesh
  103044. */
  103045. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  103046. }
  103047. }
  103048. declare module BABYLON {
  103049. /**
  103050. * Class containing static functions to help procedurally build meshes
  103051. */
  103052. export class RibbonBuilder {
  103053. /**
  103054. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103055. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103056. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103057. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103058. * * 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
  103059. * * 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
  103060. * * 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
  103061. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103062. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103063. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103064. * * 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
  103065. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103066. * * 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
  103067. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103069. * @param name defines the name of the mesh
  103070. * @param options defines the options used to create the mesh
  103071. * @param scene defines the hosting scene
  103072. * @returns the ribbon mesh
  103073. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103074. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103075. */
  103076. static CreateRibbon(name: string, options: {
  103077. pathArray: Vector3[][];
  103078. closeArray?: boolean;
  103079. closePath?: boolean;
  103080. offset?: number;
  103081. updatable?: boolean;
  103082. sideOrientation?: number;
  103083. frontUVs?: Vector4;
  103084. backUVs?: Vector4;
  103085. instance?: Mesh;
  103086. invertUV?: boolean;
  103087. uvs?: Vector2[];
  103088. colors?: Color4[];
  103089. }, scene?: Nullable<Scene>): Mesh;
  103090. }
  103091. }
  103092. declare module BABYLON {
  103093. /**
  103094. * Class containing static functions to help procedurally build meshes
  103095. */
  103096. export class TorusKnotBuilder {
  103097. /**
  103098. * Creates a torus knot mesh
  103099. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103100. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103101. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103102. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103104. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103105. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103106. * @param name defines the name of the mesh
  103107. * @param options defines the options used to create the mesh
  103108. * @param scene defines the hosting scene
  103109. * @returns the torus knot mesh
  103110. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103111. */
  103112. static CreateTorusKnot(name: string, options: {
  103113. radius?: number;
  103114. tube?: number;
  103115. radialSegments?: number;
  103116. tubularSegments?: number;
  103117. p?: number;
  103118. q?: number;
  103119. updatable?: boolean;
  103120. sideOrientation?: number;
  103121. frontUVs?: Vector4;
  103122. backUVs?: Vector4;
  103123. }, scene: any): Mesh;
  103124. }
  103125. }
  103126. declare module BABYLON {
  103127. /**
  103128. * Polygon
  103129. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  103130. */
  103131. export class Polygon {
  103132. /**
  103133. * Creates a rectangle
  103134. * @param xmin bottom X coord
  103135. * @param ymin bottom Y coord
  103136. * @param xmax top X coord
  103137. * @param ymax top Y coord
  103138. * @returns points that make the resulting rectation
  103139. */
  103140. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  103141. /**
  103142. * Creates a circle
  103143. * @param radius radius of circle
  103144. * @param cx scale in x
  103145. * @param cy scale in y
  103146. * @param numberOfSides number of sides that make up the circle
  103147. * @returns points that make the resulting circle
  103148. */
  103149. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  103150. /**
  103151. * Creates a polygon from input string
  103152. * @param input Input polygon data
  103153. * @returns the parsed points
  103154. */
  103155. static Parse(input: string): Vector2[];
  103156. /**
  103157. * Starts building a polygon from x and y coordinates
  103158. * @param x x coordinate
  103159. * @param y y coordinate
  103160. * @returns the started path2
  103161. */
  103162. static StartingAt(x: number, y: number): Path2;
  103163. }
  103164. /**
  103165. * Builds a polygon
  103166. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  103167. */
  103168. export class PolygonMeshBuilder {
  103169. private _points;
  103170. private _outlinepoints;
  103171. private _holes;
  103172. private _name;
  103173. private _scene;
  103174. private _epoints;
  103175. private _eholes;
  103176. private _addToepoint;
  103177. /**
  103178. * Babylon reference to the earcut plugin.
  103179. */
  103180. bjsEarcut: any;
  103181. /**
  103182. * Creates a PolygonMeshBuilder
  103183. * @param name name of the builder
  103184. * @param contours Path of the polygon
  103185. * @param scene scene to add to
  103186. * @param earcutInjection can be used to inject your own earcut reference
  103187. */
  103188. constructor(name: string, contours: Path2 | Vector2[] | any, scene: Scene, earcutInjection?: any);
  103189. /**
  103190. * Adds a whole within the polygon
  103191. * @param hole Array of points defining the hole
  103192. * @returns this
  103193. */
  103194. addHole(hole: Vector2[]): PolygonMeshBuilder;
  103195. /**
  103196. * Creates the polygon
  103197. * @param updatable If the mesh should be updatable
  103198. * @param depth The depth of the mesh created
  103199. * @returns the created mesh
  103200. */
  103201. build(updatable?: boolean, depth?: number): Mesh;
  103202. /**
  103203. * Adds a side to the polygon
  103204. * @param positions points that make the polygon
  103205. * @param normals normals of the polygon
  103206. * @param uvs uvs of the polygon
  103207. * @param indices indices of the polygon
  103208. * @param bounds bounds of the polygon
  103209. * @param points points of the polygon
  103210. * @param depth depth of the polygon
  103211. * @param flip flip of the polygon
  103212. */
  103213. private addSide;
  103214. }
  103215. }
  103216. declare module BABYLON {
  103217. /**
  103218. * Class containing static functions to help procedurally build meshes
  103219. */
  103220. export class PolygonBuilder {
  103221. /**
  103222. * Creates a polygon mesh
  103223. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  103224. * * 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
  103225. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103226. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103227. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  103228. * * Remember you can only change the shape positions, not their number when updating a polygon
  103229. * @param name defines the name of the mesh
  103230. * @param options defines the options used to create the mesh
  103231. * @param scene defines the hosting scene
  103232. * @param earcutInjection can be used to inject your own earcut reference
  103233. * @returns the polygon mesh
  103234. */
  103235. static CreatePolygon(name: string, options: {
  103236. shape: Vector3[];
  103237. holes?: Vector3[][];
  103238. depth?: number;
  103239. faceUV?: Vector4[];
  103240. faceColors?: Color4[];
  103241. updatable?: boolean;
  103242. sideOrientation?: number;
  103243. frontUVs?: Vector4;
  103244. backUVs?: Vector4;
  103245. }, scene: Scene, earcutInjection?: any): Mesh;
  103246. /**
  103247. * Creates an extruded polygon mesh, with depth in the Y direction.
  103248. * * 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)
  103249. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103250. * @param name defines the name of the mesh
  103251. * @param options defines the options used to create the mesh
  103252. * @param scene defines the hosting scene
  103253. * @param earcutInjection can be used to inject your own earcut reference
  103254. * @returns the polygon mesh
  103255. */
  103256. static ExtrudePolygon(name: string, options: {
  103257. shape: Vector3[];
  103258. holes?: Vector3[][];
  103259. depth?: number;
  103260. faceUV?: Vector4[];
  103261. faceColors?: Color4[];
  103262. updatable?: boolean;
  103263. sideOrientation?: number;
  103264. frontUVs?: Vector4;
  103265. backUVs?: Vector4;
  103266. }, scene: Scene, earcutInjection?: any): Mesh;
  103267. }
  103268. }
  103269. declare module BABYLON {
  103270. /**
  103271. * Class containing static functions to help procedurally build meshes
  103272. */
  103273. export class ShapeBuilder {
  103274. /**
  103275. * 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.
  103276. * * 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.
  103277. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103278. * * 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.
  103279. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103280. * * 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
  103281. * * 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
  103282. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103285. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103287. * @param name defines the name of the mesh
  103288. * @param options defines the options used to create the mesh
  103289. * @param scene defines the hosting scene
  103290. * @returns the extruded shape mesh
  103291. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103293. */
  103294. static ExtrudeShape(name: string, options: {
  103295. shape: Vector3[];
  103296. path: Vector3[];
  103297. scale?: number;
  103298. rotation?: number;
  103299. cap?: number;
  103300. updatable?: boolean;
  103301. sideOrientation?: number;
  103302. frontUVs?: Vector4;
  103303. backUVs?: Vector4;
  103304. instance?: Mesh;
  103305. invertUV?: boolean;
  103306. }, scene?: Nullable<Scene>): Mesh;
  103307. /**
  103308. * Creates an custom extruded shape mesh.
  103309. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103310. * * 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.
  103311. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103312. * * 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
  103313. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103314. * * 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
  103315. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103316. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103317. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103318. * * 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
  103319. * * 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
  103320. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103322. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103325. * @param name defines the name of the mesh
  103326. * @param options defines the options used to create the mesh
  103327. * @param scene defines the hosting scene
  103328. * @returns the custom extruded shape mesh
  103329. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103330. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103331. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103332. */
  103333. static ExtrudeShapeCustom(name: string, options: {
  103334. shape: Vector3[];
  103335. path: Vector3[];
  103336. scaleFunction?: any;
  103337. rotationFunction?: any;
  103338. ribbonCloseArray?: boolean;
  103339. ribbonClosePath?: boolean;
  103340. cap?: number;
  103341. updatable?: boolean;
  103342. sideOrientation?: number;
  103343. frontUVs?: Vector4;
  103344. backUVs?: Vector4;
  103345. instance?: Mesh;
  103346. invertUV?: boolean;
  103347. }, scene: Scene): Mesh;
  103348. private static _ExtrudeShapeGeneric;
  103349. }
  103350. }
  103351. declare module BABYLON {
  103352. /**
  103353. * Class containing static functions to help procedurally build meshes
  103354. */
  103355. export class LatheBuilder {
  103356. /**
  103357. * Creates lathe mesh.
  103358. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103359. * * 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
  103360. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103361. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103362. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103363. * * 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
  103364. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103365. * * 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
  103366. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103367. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103368. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103370. * @param name defines the name of the mesh
  103371. * @param options defines the options used to create the mesh
  103372. * @param scene defines the hosting scene
  103373. * @returns the lathe mesh
  103374. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103375. */
  103376. static CreateLathe(name: string, options: {
  103377. shape: Vector3[];
  103378. radius?: number;
  103379. tessellation?: number;
  103380. clip?: number;
  103381. arc?: number;
  103382. closed?: boolean;
  103383. updatable?: boolean;
  103384. sideOrientation?: number;
  103385. frontUVs?: Vector4;
  103386. backUVs?: Vector4;
  103387. cap?: number;
  103388. invertUV?: boolean;
  103389. }, scene: Scene): Mesh;
  103390. }
  103391. }
  103392. declare module BABYLON {
  103393. /**
  103394. * Class containing static functions to help procedurally build meshes
  103395. */
  103396. export class TubeBuilder {
  103397. /**
  103398. * Creates a tube mesh.
  103399. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103400. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  103401. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  103402. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  103403. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  103404. * * 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)
  103405. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  103406. * * 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
  103407. * * 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
  103408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103412. * @param name defines the name of the mesh
  103413. * @param options defines the options used to create the mesh
  103414. * @param scene defines the hosting scene
  103415. * @returns the tube mesh
  103416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103417. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  103418. */
  103419. static CreateTube(name: string, options: {
  103420. path: Vector3[];
  103421. radius?: number;
  103422. tessellation?: number;
  103423. radiusFunction?: {
  103424. (i: number, distance: number): number;
  103425. };
  103426. cap?: number;
  103427. arc?: number;
  103428. updatable?: boolean;
  103429. sideOrientation?: number;
  103430. frontUVs?: Vector4;
  103431. backUVs?: Vector4;
  103432. instance?: Mesh;
  103433. invertUV?: boolean;
  103434. }, scene: Scene): Mesh;
  103435. }
  103436. }
  103437. declare module BABYLON {
  103438. /**
  103439. * Class containing static functions to help procedurally build meshes
  103440. */
  103441. export class IcoSphereBuilder {
  103442. /**
  103443. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103444. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103445. * * 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`)
  103446. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103447. * * 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
  103448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103449. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103451. * @param name defines the name of the mesh
  103452. * @param options defines the options used to create the mesh
  103453. * @param scene defines the hosting scene
  103454. * @returns the icosahedron mesh
  103455. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103456. */
  103457. static CreateIcoSphere(name: string, options: {
  103458. radius?: number;
  103459. radiusX?: number;
  103460. radiusY?: number;
  103461. radiusZ?: number;
  103462. flat?: boolean;
  103463. subdivisions?: number;
  103464. sideOrientation?: number;
  103465. frontUVs?: Vector4;
  103466. backUVs?: Vector4;
  103467. updatable?: boolean;
  103468. }, scene: Scene): Mesh;
  103469. }
  103470. }
  103471. declare module BABYLON {
  103472. /**
  103473. * Class containing static functions to help procedurally build meshes
  103474. */
  103475. export class DecalBuilder {
  103476. /**
  103477. * Creates a decal mesh.
  103478. * 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
  103479. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  103480. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  103481. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  103482. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  103483. * @param name defines the name of the mesh
  103484. * @param sourceMesh defines the mesh where the decal must be applied
  103485. * @param options defines the options used to create the mesh
  103486. * @param scene defines the hosting scene
  103487. * @returns the decal mesh
  103488. * @see https://doc.babylonjs.com/how_to/decals
  103489. */
  103490. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  103491. position?: Vector3;
  103492. normal?: Vector3;
  103493. size?: Vector3;
  103494. angle?: number;
  103495. }): Mesh;
  103496. }
  103497. }
  103498. declare module BABYLON {
  103499. /**
  103500. * Class containing static functions to help procedurally build meshes
  103501. */
  103502. export class MeshBuilder {
  103503. /**
  103504. * Creates a box mesh
  103505. * * The parameter `size` sets the size (float) of each box side (default 1)
  103506. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103507. * * 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)
  103508. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103510. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103512. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103513. * @param name defines the name of the mesh
  103514. * @param options defines the options used to create the mesh
  103515. * @param scene defines the hosting scene
  103516. * @returns the box mesh
  103517. */
  103518. static CreateBox(name: string, options: {
  103519. size?: number;
  103520. width?: number;
  103521. height?: number;
  103522. depth?: number;
  103523. faceUV?: Vector4[];
  103524. faceColors?: Color4[];
  103525. sideOrientation?: number;
  103526. frontUVs?: Vector4;
  103527. backUVs?: Vector4;
  103528. updatable?: boolean;
  103529. }, scene?: Nullable<Scene>): Mesh;
  103530. /**
  103531. * Creates a sphere mesh
  103532. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103533. * * 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`)
  103534. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103535. * * 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
  103536. * * 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)
  103537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103540. * @param name defines the name of the mesh
  103541. * @param options defines the options used to create the mesh
  103542. * @param scene defines the hosting scene
  103543. * @returns the sphere mesh
  103544. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103545. */
  103546. static CreateSphere(name: string, options: {
  103547. segments?: number;
  103548. diameter?: number;
  103549. diameterX?: number;
  103550. diameterY?: number;
  103551. diameterZ?: number;
  103552. arc?: number;
  103553. slice?: number;
  103554. sideOrientation?: number;
  103555. frontUVs?: Vector4;
  103556. backUVs?: Vector4;
  103557. updatable?: boolean;
  103558. }, scene: any): Mesh;
  103559. /**
  103560. * Creates a plane polygonal mesh. By default, this is a disc
  103561. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  103562. * * 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
  103563. * * 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
  103564. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103565. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103566. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103567. * @param name defines the name of the mesh
  103568. * @param options defines the options used to create the mesh
  103569. * @param scene defines the hosting scene
  103570. * @returns the plane polygonal mesh
  103571. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  103572. */
  103573. static CreateDisc(name: string, options: {
  103574. radius?: number;
  103575. tessellation?: number;
  103576. arc?: number;
  103577. updatable?: boolean;
  103578. sideOrientation?: number;
  103579. frontUVs?: Vector4;
  103580. backUVs?: Vector4;
  103581. }, scene?: Nullable<Scene>): Mesh;
  103582. /**
  103583. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  103584. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  103585. * * 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`)
  103586. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  103587. * * 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
  103588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103589. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103591. * @param name defines the name of the mesh
  103592. * @param options defines the options used to create the mesh
  103593. * @param scene defines the hosting scene
  103594. * @returns the icosahedron mesh
  103595. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  103596. */
  103597. static CreateIcoSphere(name: string, options: {
  103598. radius?: number;
  103599. radiusX?: number;
  103600. radiusY?: number;
  103601. radiusZ?: number;
  103602. flat?: boolean;
  103603. subdivisions?: number;
  103604. sideOrientation?: number;
  103605. frontUVs?: Vector4;
  103606. backUVs?: Vector4;
  103607. updatable?: boolean;
  103608. }, scene: Scene): Mesh;
  103609. /**
  103610. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  103611. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  103612. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  103613. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  103614. * * 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
  103615. * * 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
  103616. * * 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
  103617. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103618. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103619. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103620. * * 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
  103621. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  103622. * * 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
  103623. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  103624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103625. * @param name defines the name of the mesh
  103626. * @param options defines the options used to create the mesh
  103627. * @param scene defines the hosting scene
  103628. * @returns the ribbon mesh
  103629. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  103630. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103631. */
  103632. static CreateRibbon(name: string, options: {
  103633. pathArray: Vector3[][];
  103634. closeArray?: boolean;
  103635. closePath?: boolean;
  103636. offset?: number;
  103637. updatable?: boolean;
  103638. sideOrientation?: number;
  103639. frontUVs?: Vector4;
  103640. backUVs?: Vector4;
  103641. instance?: Mesh;
  103642. invertUV?: boolean;
  103643. uvs?: Vector2[];
  103644. colors?: Color4[];
  103645. }, scene?: Nullable<Scene>): Mesh;
  103646. /**
  103647. * Creates a cylinder or a cone mesh
  103648. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  103649. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  103650. * * 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.
  103651. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  103652. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  103653. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  103654. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  103655. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  103656. * * 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).
  103657. * * 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
  103658. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  103659. * * 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
  103660. * * 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.
  103661. * * If `enclose` is false, a ring surface is one element.
  103662. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  103663. * * 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
  103664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103667. * @param name defines the name of the mesh
  103668. * @param options defines the options used to create the mesh
  103669. * @param scene defines the hosting scene
  103670. * @returns the cylinder mesh
  103671. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  103672. */
  103673. static CreateCylinder(name: string, options: {
  103674. height?: number;
  103675. diameterTop?: number;
  103676. diameterBottom?: number;
  103677. diameter?: number;
  103678. tessellation?: number;
  103679. subdivisions?: number;
  103680. arc?: number;
  103681. faceColors?: Color4[];
  103682. faceUV?: Vector4[];
  103683. updatable?: boolean;
  103684. hasRings?: boolean;
  103685. enclose?: boolean;
  103686. sideOrientation?: number;
  103687. frontUVs?: Vector4;
  103688. backUVs?: Vector4;
  103689. }, scene: any): Mesh;
  103690. /**
  103691. * Creates a torus mesh
  103692. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  103693. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  103694. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  103695. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103696. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103698. * @param name defines the name of the mesh
  103699. * @param options defines the options used to create the mesh
  103700. * @param scene defines the hosting scene
  103701. * @returns the torus mesh
  103702. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  103703. */
  103704. static CreateTorus(name: string, options: {
  103705. diameter?: number;
  103706. thickness?: number;
  103707. tessellation?: number;
  103708. updatable?: boolean;
  103709. sideOrientation?: number;
  103710. frontUVs?: Vector4;
  103711. backUVs?: Vector4;
  103712. }, scene: any): Mesh;
  103713. /**
  103714. * Creates a torus knot mesh
  103715. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  103716. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  103717. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  103718. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  103719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103722. * @param name defines the name of the mesh
  103723. * @param options defines the options used to create the mesh
  103724. * @param scene defines the hosting scene
  103725. * @returns the torus knot mesh
  103726. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  103727. */
  103728. static CreateTorusKnot(name: string, options: {
  103729. radius?: number;
  103730. tube?: number;
  103731. radialSegments?: number;
  103732. tubularSegments?: number;
  103733. p?: number;
  103734. q?: number;
  103735. updatable?: boolean;
  103736. sideOrientation?: number;
  103737. frontUVs?: Vector4;
  103738. backUVs?: Vector4;
  103739. }, scene: any): Mesh;
  103740. /**
  103741. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103742. * * 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
  103743. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103744. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103745. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103746. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103747. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103748. * * 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
  103749. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103751. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103752. * @param name defines the name of the new line system
  103753. * @param options defines the options used to create the line system
  103754. * @param scene defines the hosting scene
  103755. * @returns a new line system mesh
  103756. */
  103757. static CreateLineSystem(name: string, options: {
  103758. lines: Vector3[][];
  103759. updatable?: boolean;
  103760. instance?: Nullable<LinesMesh>;
  103761. colors?: Nullable<Color4[][]>;
  103762. useVertexAlpha?: boolean;
  103763. }, scene: Nullable<Scene>): LinesMesh;
  103764. /**
  103765. * Creates a line mesh
  103766. * 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
  103767. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103768. * * The parameter `points` is an array successive Vector3
  103769. * * 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
  103770. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103771. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103772. * * When updating an instance, remember that only point positions can change, not the number of points
  103773. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103774. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103775. * @param name defines the name of the new line system
  103776. * @param options defines the options used to create the line system
  103777. * @param scene defines the hosting scene
  103778. * @returns a new line mesh
  103779. */
  103780. static CreateLines(name: string, options: {
  103781. points: Vector3[];
  103782. updatable?: boolean;
  103783. instance?: Nullable<LinesMesh>;
  103784. colors?: Color4[];
  103785. useVertexAlpha?: boolean;
  103786. }, scene?: Nullable<Scene>): LinesMesh;
  103787. /**
  103788. * Creates a dashed line mesh
  103789. * * 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
  103790. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103791. * * The parameter `points` is an array successive Vector3
  103792. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103793. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103794. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103795. * * 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
  103796. * * When updating an instance, remember that only point positions can change, not the number of points
  103797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103798. * @param name defines the name of the mesh
  103799. * @param options defines the options used to create the mesh
  103800. * @param scene defines the hosting scene
  103801. * @returns the dashed line mesh
  103802. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103803. */
  103804. static CreateDashedLines(name: string, options: {
  103805. points: Vector3[];
  103806. dashSize?: number;
  103807. gapSize?: number;
  103808. dashNb?: number;
  103809. updatable?: boolean;
  103810. instance?: LinesMesh;
  103811. }, scene?: Nullable<Scene>): LinesMesh;
  103812. /**
  103813. * 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.
  103814. * * 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.
  103815. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103816. * * 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.
  103817. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  103818. * * 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
  103819. * * 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
  103820. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  103821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  103824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103825. * @param name defines the name of the mesh
  103826. * @param options defines the options used to create the mesh
  103827. * @param scene defines the hosting scene
  103828. * @returns the extruded shape mesh
  103829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103830. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103831. */
  103832. static ExtrudeShape(name: string, options: {
  103833. shape: Vector3[];
  103834. path: Vector3[];
  103835. scale?: number;
  103836. rotation?: number;
  103837. cap?: number;
  103838. updatable?: boolean;
  103839. sideOrientation?: number;
  103840. frontUVs?: Vector4;
  103841. backUVs?: Vector4;
  103842. instance?: Mesh;
  103843. invertUV?: boolean;
  103844. }, scene?: Nullable<Scene>): Mesh;
  103845. /**
  103846. * Creates an custom extruded shape mesh.
  103847. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  103848. * * 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.
  103849. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  103850. * * 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
  103851. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  103852. * * 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
  103853. * * It must returns a float value that will be the scale value applied to the shape on each path point
  103854. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  103855. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  103856. * * 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
  103857. * * 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
  103858. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  103859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103863. * @param name defines the name of the mesh
  103864. * @param options defines the options used to create the mesh
  103865. * @param scene defines the hosting scene
  103866. * @returns the custom extruded shape mesh
  103867. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  103868. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  103869. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  103870. */
  103871. static ExtrudeShapeCustom(name: string, options: {
  103872. shape: Vector3[];
  103873. path: Vector3[];
  103874. scaleFunction?: any;
  103875. rotationFunction?: any;
  103876. ribbonCloseArray?: boolean;
  103877. ribbonClosePath?: boolean;
  103878. cap?: number;
  103879. updatable?: boolean;
  103880. sideOrientation?: number;
  103881. frontUVs?: Vector4;
  103882. backUVs?: Vector4;
  103883. instance?: Mesh;
  103884. invertUV?: boolean;
  103885. }, scene: Scene): Mesh;
  103886. /**
  103887. * Creates lathe mesh.
  103888. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  103889. * * 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
  103890. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  103891. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  103892. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  103893. * * 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
  103894. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  103895. * * 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
  103896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103898. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  103899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103900. * @param name defines the name of the mesh
  103901. * @param options defines the options used to create the mesh
  103902. * @param scene defines the hosting scene
  103903. * @returns the lathe mesh
  103904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  103905. */
  103906. static CreateLathe(name: string, options: {
  103907. shape: Vector3[];
  103908. radius?: number;
  103909. tessellation?: number;
  103910. clip?: number;
  103911. arc?: number;
  103912. closed?: boolean;
  103913. updatable?: boolean;
  103914. sideOrientation?: number;
  103915. frontUVs?: Vector4;
  103916. backUVs?: Vector4;
  103917. cap?: number;
  103918. invertUV?: boolean;
  103919. }, scene: Scene): Mesh;
  103920. /**
  103921. * Creates a plane mesh
  103922. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103923. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103924. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103925. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103926. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103928. * @param name defines the name of the mesh
  103929. * @param options defines the options used to create the mesh
  103930. * @param scene defines the hosting scene
  103931. * @returns the plane mesh
  103932. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103933. */
  103934. static CreatePlane(name: string, options: {
  103935. size?: number;
  103936. width?: number;
  103937. height?: number;
  103938. sideOrientation?: number;
  103939. frontUVs?: Vector4;
  103940. backUVs?: Vector4;
  103941. updatable?: boolean;
  103942. sourcePlane?: Plane;
  103943. }, scene: Scene): Mesh;
  103944. /**
  103945. * Creates a ground mesh
  103946. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  103947. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  103948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103949. * @param name defines the name of the mesh
  103950. * @param options defines the options used to create the mesh
  103951. * @param scene defines the hosting scene
  103952. * @returns the ground mesh
  103953. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  103954. */
  103955. static CreateGround(name: string, options: {
  103956. width?: number;
  103957. height?: number;
  103958. subdivisions?: number;
  103959. subdivisionsX?: number;
  103960. subdivisionsY?: number;
  103961. updatable?: boolean;
  103962. }, scene: any): Mesh;
  103963. /**
  103964. * Creates a tiled ground mesh
  103965. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  103966. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  103967. * * 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
  103968. * * 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
  103969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  103970. * @param name defines the name of the mesh
  103971. * @param options defines the options used to create the mesh
  103972. * @param scene defines the hosting scene
  103973. * @returns the tiled ground mesh
  103974. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  103975. */
  103976. static CreateTiledGround(name: string, options: {
  103977. xmin: number;
  103978. zmin: number;
  103979. xmax: number;
  103980. zmax: number;
  103981. subdivisions?: {
  103982. w: number;
  103983. h: number;
  103984. };
  103985. precision?: {
  103986. w: number;
  103987. h: number;
  103988. };
  103989. updatable?: boolean;
  103990. }, scene: Scene): Mesh;
  103991. /**
  103992. * Creates a ground mesh from a height map
  103993. * * The parameter `url` sets the URL of the height map image resource.
  103994. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  103995. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  103996. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  103997. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  103998. * * 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.
  103999. * * 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).
  104000. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  104001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  104002. * @param name defines the name of the mesh
  104003. * @param url defines the url to the height map
  104004. * @param options defines the options used to create the mesh
  104005. * @param scene defines the hosting scene
  104006. * @returns the ground mesh
  104007. * @see https://doc.babylonjs.com/babylon101/height_map
  104008. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  104009. */
  104010. static CreateGroundFromHeightMap(name: string, url: string, options: {
  104011. width?: number;
  104012. height?: number;
  104013. subdivisions?: number;
  104014. minHeight?: number;
  104015. maxHeight?: number;
  104016. colorFilter?: Color3;
  104017. alphaFilter?: number;
  104018. updatable?: boolean;
  104019. onReady?: (mesh: GroundMesh) => void;
  104020. }, scene: Scene): GroundMesh;
  104021. /**
  104022. * Creates a polygon mesh
  104023. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  104024. * * 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
  104025. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  104026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  104028. * * Remember you can only change the shape positions, not their number when updating a polygon
  104029. * @param name defines the name of the mesh
  104030. * @param options defines the options used to create the mesh
  104031. * @param scene defines the hosting scene
  104032. * @param earcutInjection can be used to inject your own earcut reference
  104033. * @returns the polygon mesh
  104034. */
  104035. static CreatePolygon(name: string, options: {
  104036. shape: Vector3[];
  104037. holes?: Vector3[][];
  104038. depth?: number;
  104039. faceUV?: Vector4[];
  104040. faceColors?: Color4[];
  104041. updatable?: boolean;
  104042. sideOrientation?: number;
  104043. frontUVs?: Vector4;
  104044. backUVs?: Vector4;
  104045. }, scene: Scene, earcutInjection?: any): Mesh;
  104046. /**
  104047. * Creates an extruded polygon mesh, with depth in the Y direction.
  104048. * * 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)
  104049. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104050. * @param name defines the name of the mesh
  104051. * @param options defines the options used to create the mesh
  104052. * @param scene defines the hosting scene
  104053. * @param earcutInjection can be used to inject your own earcut reference
  104054. * @returns the polygon mesh
  104055. */
  104056. static ExtrudePolygon(name: string, options: {
  104057. shape: Vector3[];
  104058. holes?: Vector3[][];
  104059. depth?: number;
  104060. faceUV?: Vector4[];
  104061. faceColors?: Color4[];
  104062. updatable?: boolean;
  104063. sideOrientation?: number;
  104064. frontUVs?: Vector4;
  104065. backUVs?: Vector4;
  104066. }, scene: Scene, earcutInjection?: any): Mesh;
  104067. /**
  104068. * Creates a tube mesh.
  104069. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  104070. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  104071. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  104072. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  104073. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  104074. * * 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)
  104075. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  104076. * * 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
  104077. * * 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
  104078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  104081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104082. * @param name defines the name of the mesh
  104083. * @param options defines the options used to create the mesh
  104084. * @param scene defines the hosting scene
  104085. * @returns the tube mesh
  104086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  104087. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  104088. */
  104089. static CreateTube(name: string, options: {
  104090. path: Vector3[];
  104091. radius?: number;
  104092. tessellation?: number;
  104093. radiusFunction?: {
  104094. (i: number, distance: number): number;
  104095. };
  104096. cap?: number;
  104097. arc?: number;
  104098. updatable?: boolean;
  104099. sideOrientation?: number;
  104100. frontUVs?: Vector4;
  104101. backUVs?: Vector4;
  104102. instance?: Mesh;
  104103. invertUV?: boolean;
  104104. }, scene: Scene): Mesh;
  104105. /**
  104106. * Creates a polyhedron mesh
  104107. * * 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
  104108. * * The parameter `size` (positive float, default 1) sets the polygon size
  104109. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104110. * * 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`
  104111. * * 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
  104112. * * 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)`)
  104113. * * 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
  104114. * * 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
  104115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104118. * @param name defines the name of the mesh
  104119. * @param options defines the options used to create the mesh
  104120. * @param scene defines the hosting scene
  104121. * @returns the polyhedron mesh
  104122. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104123. */
  104124. static CreatePolyhedron(name: string, options: {
  104125. type?: number;
  104126. size?: number;
  104127. sizeX?: number;
  104128. sizeY?: number;
  104129. sizeZ?: number;
  104130. custom?: any;
  104131. faceUV?: Vector4[];
  104132. faceColors?: Color4[];
  104133. flat?: boolean;
  104134. updatable?: boolean;
  104135. sideOrientation?: number;
  104136. frontUVs?: Vector4;
  104137. backUVs?: Vector4;
  104138. }, scene: Scene): Mesh;
  104139. /**
  104140. * Creates a decal mesh.
  104141. * 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
  104142. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  104143. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  104144. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  104145. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  104146. * @param name defines the name of the mesh
  104147. * @param sourceMesh defines the mesh where the decal must be applied
  104148. * @param options defines the options used to create the mesh
  104149. * @param scene defines the hosting scene
  104150. * @returns the decal mesh
  104151. * @see https://doc.babylonjs.com/how_to/decals
  104152. */
  104153. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  104154. position?: Vector3;
  104155. normal?: Vector3;
  104156. size?: Vector3;
  104157. angle?: number;
  104158. }): Mesh;
  104159. }
  104160. }
  104161. declare module BABYLON {
  104162. /**
  104163. * A simplifier interface for future simplification implementations
  104164. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104165. */
  104166. export interface ISimplifier {
  104167. /**
  104168. * Simplification of a given mesh according to the given settings.
  104169. * Since this requires computation, it is assumed that the function runs async.
  104170. * @param settings The settings of the simplification, including quality and distance
  104171. * @param successCallback A callback that will be called after the mesh was simplified.
  104172. * @param errorCallback in case of an error, this callback will be called. optional.
  104173. */
  104174. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  104175. }
  104176. /**
  104177. * Expected simplification settings.
  104178. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  104179. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104180. */
  104181. export interface ISimplificationSettings {
  104182. /**
  104183. * Gets or sets the expected quality
  104184. */
  104185. quality: number;
  104186. /**
  104187. * Gets or sets the distance when this optimized version should be used
  104188. */
  104189. distance: number;
  104190. /**
  104191. * Gets an already optimized mesh
  104192. */
  104193. optimizeMesh?: boolean;
  104194. }
  104195. /**
  104196. * Class used to specify simplification options
  104197. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104198. */
  104199. export class SimplificationSettings implements ISimplificationSettings {
  104200. /** expected quality */
  104201. quality: number;
  104202. /** distance when this optimized version should be used */
  104203. distance: number;
  104204. /** already optimized mesh */
  104205. optimizeMesh?: boolean | undefined;
  104206. /**
  104207. * Creates a SimplificationSettings
  104208. * @param quality expected quality
  104209. * @param distance distance when this optimized version should be used
  104210. * @param optimizeMesh already optimized mesh
  104211. */
  104212. constructor(
  104213. /** expected quality */
  104214. quality: number,
  104215. /** distance when this optimized version should be used */
  104216. distance: number,
  104217. /** already optimized mesh */
  104218. optimizeMesh?: boolean | undefined);
  104219. }
  104220. /**
  104221. * Interface used to define a simplification task
  104222. */
  104223. export interface ISimplificationTask {
  104224. /**
  104225. * Array of settings
  104226. */
  104227. settings: Array<ISimplificationSettings>;
  104228. /**
  104229. * Simplification type
  104230. */
  104231. simplificationType: SimplificationType;
  104232. /**
  104233. * Mesh to simplify
  104234. */
  104235. mesh: Mesh;
  104236. /**
  104237. * Callback called on success
  104238. */
  104239. successCallback?: () => void;
  104240. /**
  104241. * Defines if parallel processing can be used
  104242. */
  104243. parallelProcessing: boolean;
  104244. }
  104245. /**
  104246. * Queue used to order the simplification tasks
  104247. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104248. */
  104249. export class SimplificationQueue {
  104250. private _simplificationArray;
  104251. /**
  104252. * Gets a boolean indicating that the process is still running
  104253. */
  104254. running: boolean;
  104255. /**
  104256. * Creates a new queue
  104257. */
  104258. constructor();
  104259. /**
  104260. * Adds a new simplification task
  104261. * @param task defines a task to add
  104262. */
  104263. addTask(task: ISimplificationTask): void;
  104264. /**
  104265. * Execute next task
  104266. */
  104267. executeNext(): void;
  104268. /**
  104269. * Execute a simplification task
  104270. * @param task defines the task to run
  104271. */
  104272. runSimplification(task: ISimplificationTask): void;
  104273. private getSimplifier;
  104274. }
  104275. /**
  104276. * The implemented types of simplification
  104277. * At the moment only Quadratic Error Decimation is implemented
  104278. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104279. */
  104280. export enum SimplificationType {
  104281. /** Quadratic error decimation */
  104282. QUADRATIC = 0
  104283. }
  104284. }
  104285. declare module BABYLON {
  104286. interface Scene {
  104287. /** @hidden (Backing field) */
  104288. _simplificationQueue: SimplificationQueue;
  104289. /**
  104290. * Gets or sets the simplification queue attached to the scene
  104291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  104292. */
  104293. simplificationQueue: SimplificationQueue;
  104294. }
  104295. interface Mesh {
  104296. /**
  104297. * Simplify the mesh according to the given array of settings.
  104298. * Function will return immediately and will simplify async
  104299. * @param settings a collection of simplification settings
  104300. * @param parallelProcessing should all levels calculate parallel or one after the other
  104301. * @param simplificationType the type of simplification to run
  104302. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  104303. * @returns the current mesh
  104304. */
  104305. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  104306. }
  104307. /**
  104308. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  104309. * created in a scene
  104310. */
  104311. export class SimplicationQueueSceneComponent implements ISceneComponent {
  104312. /**
  104313. * The component name helpfull to identify the component in the list of scene components.
  104314. */
  104315. readonly name: string;
  104316. /**
  104317. * The scene the component belongs to.
  104318. */
  104319. scene: Scene;
  104320. /**
  104321. * Creates a new instance of the component for the given scene
  104322. * @param scene Defines the scene to register the component in
  104323. */
  104324. constructor(scene: Scene);
  104325. /**
  104326. * Registers the component in a given scene
  104327. */
  104328. register(): void;
  104329. /**
  104330. * Rebuilds the elements related to this component in case of
  104331. * context lost for instance.
  104332. */
  104333. rebuild(): void;
  104334. /**
  104335. * Disposes the component and the associated ressources
  104336. */
  104337. dispose(): void;
  104338. private _beforeCameraUpdate;
  104339. }
  104340. }
  104341. declare module BABYLON {
  104342. /**
  104343. * Class used to enable access to IndexedDB
  104344. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  104345. */
  104346. export class Database implements IOfflineProvider {
  104347. private _callbackManifestChecked;
  104348. private _currentSceneUrl;
  104349. private _db;
  104350. private _enableSceneOffline;
  104351. private _enableTexturesOffline;
  104352. private _manifestVersionFound;
  104353. private _mustUpdateRessources;
  104354. private _hasReachedQuota;
  104355. private _isSupported;
  104356. private _idbFactory;
  104357. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  104358. private static IsUASupportingBlobStorage;
  104359. /**
  104360. * Gets a boolean indicating if Database storate is enabled (off by default)
  104361. */
  104362. static IDBStorageEnabled: boolean;
  104363. /**
  104364. * Gets a boolean indicating if scene must be saved in the database
  104365. */
  104366. readonly enableSceneOffline: boolean;
  104367. /**
  104368. * Gets a boolean indicating if textures must be saved in the database
  104369. */
  104370. readonly enableTexturesOffline: boolean;
  104371. /**
  104372. * Creates a new Database
  104373. * @param urlToScene defines the url to load the scene
  104374. * @param callbackManifestChecked defines the callback to use when manifest is checked
  104375. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  104376. */
  104377. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  104378. private static _ParseURL;
  104379. private static _ReturnFullUrlLocation;
  104380. private _checkManifestFile;
  104381. /**
  104382. * Open the database and make it available
  104383. * @param successCallback defines the callback to call on success
  104384. * @param errorCallback defines the callback to call on error
  104385. */
  104386. open(successCallback: () => void, errorCallback: () => void): void;
  104387. /**
  104388. * Loads an image from the database
  104389. * @param url defines the url to load from
  104390. * @param image defines the target DOM image
  104391. */
  104392. loadImage(url: string, image: HTMLImageElement): void;
  104393. private _loadImageFromDBAsync;
  104394. private _saveImageIntoDBAsync;
  104395. private _checkVersionFromDB;
  104396. private _loadVersionFromDBAsync;
  104397. private _saveVersionIntoDBAsync;
  104398. /**
  104399. * Loads a file from database
  104400. * @param url defines the URL to load from
  104401. * @param sceneLoaded defines a callback to call on success
  104402. * @param progressCallBack defines a callback to call when progress changed
  104403. * @param errorCallback defines a callback to call on error
  104404. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  104405. */
  104406. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  104407. private _loadFileAsync;
  104408. private _saveFileAsync;
  104409. /**
  104410. * Validates if xhr data is correct
  104411. * @param xhr defines the request to validate
  104412. * @param dataType defines the expected data type
  104413. * @returns true if data is correct
  104414. */
  104415. private static _ValidateXHRData;
  104416. }
  104417. }
  104418. declare module BABYLON {
  104419. /** @hidden */
  104420. export var gpuUpdateParticlesPixelShader: {
  104421. name: string;
  104422. shader: string;
  104423. };
  104424. }
  104425. declare module BABYLON {
  104426. /** @hidden */
  104427. export var gpuUpdateParticlesVertexShader: {
  104428. name: string;
  104429. shader: string;
  104430. };
  104431. }
  104432. declare module BABYLON {
  104433. /** @hidden */
  104434. export var clipPlaneFragmentDeclaration2: {
  104435. name: string;
  104436. shader: string;
  104437. };
  104438. }
  104439. declare module BABYLON {
  104440. /** @hidden */
  104441. export var gpuRenderParticlesPixelShader: {
  104442. name: string;
  104443. shader: string;
  104444. };
  104445. }
  104446. declare module BABYLON {
  104447. /** @hidden */
  104448. export var clipPlaneVertexDeclaration2: {
  104449. name: string;
  104450. shader: string;
  104451. };
  104452. }
  104453. declare module BABYLON {
  104454. /** @hidden */
  104455. export var gpuRenderParticlesVertexShader: {
  104456. name: string;
  104457. shader: string;
  104458. };
  104459. }
  104460. declare module BABYLON {
  104461. /**
  104462. * This represents a GPU particle system in Babylon
  104463. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  104464. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  104465. */
  104466. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  104467. /**
  104468. * The layer mask we are rendering the particles through.
  104469. */
  104470. layerMask: number;
  104471. private _capacity;
  104472. private _activeCount;
  104473. private _currentActiveCount;
  104474. private _accumulatedCount;
  104475. private _renderEffect;
  104476. private _updateEffect;
  104477. private _buffer0;
  104478. private _buffer1;
  104479. private _spriteBuffer;
  104480. private _updateVAO;
  104481. private _renderVAO;
  104482. private _targetIndex;
  104483. private _sourceBuffer;
  104484. private _targetBuffer;
  104485. private _engine;
  104486. private _currentRenderId;
  104487. private _started;
  104488. private _stopped;
  104489. private _timeDelta;
  104490. private _randomTexture;
  104491. private _randomTexture2;
  104492. private _attributesStrideSize;
  104493. private _updateEffectOptions;
  104494. private _randomTextureSize;
  104495. private _actualFrame;
  104496. private readonly _rawTextureWidth;
  104497. /**
  104498. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  104499. */
  104500. static readonly IsSupported: boolean;
  104501. /**
  104502. * An event triggered when the system is disposed.
  104503. */
  104504. onDisposeObservable: Observable<GPUParticleSystem>;
  104505. /**
  104506. * Gets the maximum number of particles active at the same time.
  104507. * @returns The max number of active particles.
  104508. */
  104509. getCapacity(): number;
  104510. /**
  104511. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104512. * to override the particles.
  104513. */
  104514. forceDepthWrite: boolean;
  104515. /**
  104516. * Gets or set the number of active particles
  104517. */
  104518. activeParticleCount: number;
  104519. private _preWarmDone;
  104520. /**
  104521. * Is this system ready to be used/rendered
  104522. * @return true if the system is ready
  104523. */
  104524. isReady(): boolean;
  104525. /**
  104526. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104527. * @returns True if it has been started, otherwise false.
  104528. */
  104529. isStarted(): boolean;
  104530. /**
  104531. * Starts the particle system and begins to emit
  104532. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104533. */
  104534. start(delay?: number): void;
  104535. /**
  104536. * Stops the particle system.
  104537. */
  104538. stop(): void;
  104539. /**
  104540. * Remove all active particles
  104541. */
  104542. reset(): void;
  104543. /**
  104544. * Returns the string "GPUParticleSystem"
  104545. * @returns a string containing the class name
  104546. */
  104547. getClassName(): string;
  104548. private _colorGradientsTexture;
  104549. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  104550. /**
  104551. * Adds a new color gradient
  104552. * @param gradient defines the gradient to use (between 0 and 1)
  104553. * @param color1 defines the color to affect to the specified gradient
  104554. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104555. * @returns the current particle system
  104556. */
  104557. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  104558. /**
  104559. * Remove a specific color gradient
  104560. * @param gradient defines the gradient to remove
  104561. * @returns the current particle system
  104562. */
  104563. removeColorGradient(gradient: number): GPUParticleSystem;
  104564. private _angularSpeedGradientsTexture;
  104565. private _sizeGradientsTexture;
  104566. private _velocityGradientsTexture;
  104567. private _limitVelocityGradientsTexture;
  104568. private _dragGradientsTexture;
  104569. private _addFactorGradient;
  104570. /**
  104571. * Adds a new size gradient
  104572. * @param gradient defines the gradient to use (between 0 and 1)
  104573. * @param factor defines the size factor to affect to the specified gradient
  104574. * @returns the current particle system
  104575. */
  104576. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  104577. /**
  104578. * Remove a specific size gradient
  104579. * @param gradient defines the gradient to remove
  104580. * @returns the current particle system
  104581. */
  104582. removeSizeGradient(gradient: number): GPUParticleSystem;
  104583. /**
  104584. * Adds a new angular speed gradient
  104585. * @param gradient defines the gradient to use (between 0 and 1)
  104586. * @param factor defines the angular speed to affect to the specified gradient
  104587. * @returns the current particle system
  104588. */
  104589. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  104590. /**
  104591. * Remove a specific angular speed gradient
  104592. * @param gradient defines the gradient to remove
  104593. * @returns the current particle system
  104594. */
  104595. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  104596. /**
  104597. * Adds a new velocity gradient
  104598. * @param gradient defines the gradient to use (between 0 and 1)
  104599. * @param factor defines the velocity to affect to the specified gradient
  104600. * @returns the current particle system
  104601. */
  104602. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104603. /**
  104604. * Remove a specific velocity gradient
  104605. * @param gradient defines the gradient to remove
  104606. * @returns the current particle system
  104607. */
  104608. removeVelocityGradient(gradient: number): GPUParticleSystem;
  104609. /**
  104610. * Adds a new limit velocity gradient
  104611. * @param gradient defines the gradient to use (between 0 and 1)
  104612. * @param factor defines the limit velocity value to affect to the specified gradient
  104613. * @returns the current particle system
  104614. */
  104615. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  104616. /**
  104617. * Remove a specific limit velocity gradient
  104618. * @param gradient defines the gradient to remove
  104619. * @returns the current particle system
  104620. */
  104621. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  104622. /**
  104623. * Adds a new drag gradient
  104624. * @param gradient defines the gradient to use (between 0 and 1)
  104625. * @param factor defines the drag value to affect to the specified gradient
  104626. * @returns the current particle system
  104627. */
  104628. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  104629. /**
  104630. * Remove a specific drag gradient
  104631. * @param gradient defines the gradient to remove
  104632. * @returns the current particle system
  104633. */
  104634. removeDragGradient(gradient: number): GPUParticleSystem;
  104635. /**
  104636. * Not supported by GPUParticleSystem
  104637. * @param gradient defines the gradient to use (between 0 and 1)
  104638. * @param factor defines the emit rate value to affect to the specified gradient
  104639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104640. * @returns the current particle system
  104641. */
  104642. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104643. /**
  104644. * Not supported by GPUParticleSystem
  104645. * @param gradient defines the gradient to remove
  104646. * @returns the current particle system
  104647. */
  104648. removeEmitRateGradient(gradient: number): IParticleSystem;
  104649. /**
  104650. * Not supported by GPUParticleSystem
  104651. * @param gradient defines the gradient to use (between 0 and 1)
  104652. * @param factor defines the start size value to affect to the specified gradient
  104653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104654. * @returns the current particle system
  104655. */
  104656. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104657. /**
  104658. * Not supported by GPUParticleSystem
  104659. * @param gradient defines the gradient to remove
  104660. * @returns the current particle system
  104661. */
  104662. removeStartSizeGradient(gradient: number): IParticleSystem;
  104663. /**
  104664. * Not supported by GPUParticleSystem
  104665. * @param gradient defines the gradient to use (between 0 and 1)
  104666. * @param min defines the color remap minimal range
  104667. * @param max defines the color remap maximal range
  104668. * @returns the current particle system
  104669. */
  104670. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104671. /**
  104672. * Not supported by GPUParticleSystem
  104673. * @param gradient defines the gradient to remove
  104674. * @returns the current particle system
  104675. */
  104676. removeColorRemapGradient(): IParticleSystem;
  104677. /**
  104678. * Not supported by GPUParticleSystem
  104679. * @param gradient defines the gradient to use (between 0 and 1)
  104680. * @param min defines the alpha remap minimal range
  104681. * @param max defines the alpha remap maximal range
  104682. * @returns the current particle system
  104683. */
  104684. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  104685. /**
  104686. * Not supported by GPUParticleSystem
  104687. * @param gradient defines the gradient to remove
  104688. * @returns the current particle system
  104689. */
  104690. removeAlphaRemapGradient(): IParticleSystem;
  104691. /**
  104692. * Not supported by GPUParticleSystem
  104693. * @param gradient defines the gradient to use (between 0 and 1)
  104694. * @param color defines the color to affect to the specified gradient
  104695. * @returns the current particle system
  104696. */
  104697. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  104698. /**
  104699. * Not supported by GPUParticleSystem
  104700. * @param gradient defines the gradient to remove
  104701. * @returns the current particle system
  104702. */
  104703. removeRampGradient(): IParticleSystem;
  104704. /**
  104705. * Not supported by GPUParticleSystem
  104706. * @returns the list of ramp gradients
  104707. */
  104708. getRampGradients(): Nullable<Array<Color3Gradient>>;
  104709. /**
  104710. * Not supported by GPUParticleSystem
  104711. * Gets or sets a boolean indicating that ramp gradients must be used
  104712. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104713. */
  104714. useRampGradients: boolean;
  104715. /**
  104716. * Not supported by GPUParticleSystem
  104717. * @param gradient defines the gradient to use (between 0 and 1)
  104718. * @param factor defines the life time factor to affect to the specified gradient
  104719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104720. * @returns the current particle system
  104721. */
  104722. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  104723. /**
  104724. * Not supported by GPUParticleSystem
  104725. * @param gradient defines the gradient to remove
  104726. * @returns the current particle system
  104727. */
  104728. removeLifeTimeGradient(gradient: number): IParticleSystem;
  104729. /**
  104730. * Instantiates a GPU particle system.
  104731. * 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.
  104732. * @param name The name of the particle system
  104733. * @param options The options used to create the system
  104734. * @param scene The scene the particle system belongs to
  104735. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104736. */
  104737. constructor(name: string, options: Partial<{
  104738. capacity: number;
  104739. randomTextureSize: number;
  104740. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  104741. protected _reset(): void;
  104742. private _createUpdateVAO;
  104743. private _createRenderVAO;
  104744. private _initialize;
  104745. /** @hidden */
  104746. _recreateUpdateEffect(): void;
  104747. /** @hidden */
  104748. _recreateRenderEffect(): void;
  104749. /**
  104750. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  104751. * @param preWarm defines if we are in the pre-warmimg phase
  104752. */
  104753. animate(preWarm?: boolean): void;
  104754. private _createFactorGradientTexture;
  104755. private _createSizeGradientTexture;
  104756. private _createAngularSpeedGradientTexture;
  104757. private _createVelocityGradientTexture;
  104758. private _createLimitVelocityGradientTexture;
  104759. private _createDragGradientTexture;
  104760. private _createColorGradientTexture;
  104761. /**
  104762. * Renders the particle system in its current state
  104763. * @param preWarm defines if the system should only update the particles but not render them
  104764. * @returns the current number of particles
  104765. */
  104766. render(preWarm?: boolean): number;
  104767. /**
  104768. * Rebuilds the particle system
  104769. */
  104770. rebuild(): void;
  104771. private _releaseBuffers;
  104772. private _releaseVAOs;
  104773. /**
  104774. * Disposes the particle system and free the associated resources
  104775. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  104776. */
  104777. dispose(disposeTexture?: boolean): void;
  104778. /**
  104779. * Clones the particle system.
  104780. * @param name The name of the cloned object
  104781. * @param newEmitter The new emitter to use
  104782. * @returns the cloned particle system
  104783. */
  104784. clone(name: string, newEmitter: any): GPUParticleSystem;
  104785. /**
  104786. * Serializes the particle system to a JSON object.
  104787. * @returns the JSON object
  104788. */
  104789. serialize(): any;
  104790. /**
  104791. * Parses a JSON object to create a GPU particle system.
  104792. * @param parsedParticleSystem The JSON object to parse
  104793. * @param scene The scene to create the particle system in
  104794. * @param rootUrl The root url to use to load external dependencies like texture
  104795. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  104796. * @returns the parsed GPU particle system
  104797. */
  104798. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  104799. }
  104800. }
  104801. declare module BABYLON {
  104802. /**
  104803. * Represents a set of particle systems working together to create a specific effect
  104804. */
  104805. export class ParticleSystemSet implements IDisposable {
  104806. private _emitterCreationOptions;
  104807. private _emitterNode;
  104808. /**
  104809. * Gets the particle system list
  104810. */
  104811. systems: IParticleSystem[];
  104812. /**
  104813. * Gets the emitter node used with this set
  104814. */
  104815. readonly emitterNode: Nullable<TransformNode>;
  104816. /**
  104817. * Creates a new emitter mesh as a sphere
  104818. * @param options defines the options used to create the sphere
  104819. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  104820. * @param scene defines the hosting scene
  104821. */
  104822. setEmitterAsSphere(options: {
  104823. diameter: number;
  104824. segments: number;
  104825. color: Color3;
  104826. }, renderingGroupId: number, scene: Scene): void;
  104827. /**
  104828. * Starts all particle systems of the set
  104829. * @param emitter defines an optional mesh to use as emitter for the particle systems
  104830. */
  104831. start(emitter?: AbstractMesh): void;
  104832. /**
  104833. * Release all associated resources
  104834. */
  104835. dispose(): void;
  104836. /**
  104837. * Serialize the set into a JSON compatible object
  104838. * @returns a JSON compatible representation of the set
  104839. */
  104840. serialize(): any;
  104841. /**
  104842. * Parse a new ParticleSystemSet from a serialized source
  104843. * @param data defines a JSON compatible representation of the set
  104844. * @param scene defines the hosting scene
  104845. * @param gpu defines if we want GPU particles or CPU particles
  104846. * @returns a new ParticleSystemSet
  104847. */
  104848. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  104849. }
  104850. }
  104851. declare module BABYLON {
  104852. /**
  104853. * This class is made for on one-liner static method to help creating particle system set.
  104854. */
  104855. export class ParticleHelper {
  104856. /**
  104857. * Gets or sets base Assets URL
  104858. */
  104859. static BaseAssetsUrl: string;
  104860. /**
  104861. * Create a default particle system that you can tweak
  104862. * @param emitter defines the emitter to use
  104863. * @param capacity defines the system capacity (default is 500 particles)
  104864. * @param scene defines the hosting scene
  104865. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  104866. * @returns the new Particle system
  104867. */
  104868. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  104869. /**
  104870. * This is the main static method (one-liner) of this helper to create different particle systems
  104871. * @param type This string represents the type to the particle system to create
  104872. * @param scene The scene where the particle system should live
  104873. * @param gpu If the system will use gpu
  104874. * @returns the ParticleSystemSet created
  104875. */
  104876. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  104877. /**
  104878. * Static function used to export a particle system to a ParticleSystemSet variable.
  104879. * Please note that the emitter shape is not exported
  104880. * @param systems defines the particle systems to export
  104881. * @returns the created particle system set
  104882. */
  104883. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  104884. }
  104885. }
  104886. declare module BABYLON {
  104887. interface Engine {
  104888. /**
  104889. * Create an effect to use with particle systems.
  104890. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  104891. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  104892. * @param uniformsNames defines a list of attribute names
  104893. * @param samplers defines an array of string used to represent textures
  104894. * @param defines defines the string containing the defines to use to compile the shaders
  104895. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104896. * @param onCompiled defines a function to call when the effect creation is successful
  104897. * @param onError defines a function to call when the effect creation has failed
  104898. * @returns the new Effect
  104899. */
  104900. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  104901. }
  104902. interface Mesh {
  104903. /**
  104904. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  104905. * @returns an array of IParticleSystem
  104906. */
  104907. getEmittedParticleSystems(): IParticleSystem[];
  104908. /**
  104909. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  104910. * @returns an array of IParticleSystem
  104911. */
  104912. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  104913. }
  104914. /**
  104915. * @hidden
  104916. */
  104917. export var _IDoNeedToBeInTheBuild: number;
  104918. }
  104919. declare module BABYLON {
  104920. interface Scene {
  104921. /** @hidden (Backing field) */
  104922. _physicsEngine: Nullable<IPhysicsEngine>;
  104923. /**
  104924. * Gets the current physics engine
  104925. * @returns a IPhysicsEngine or null if none attached
  104926. */
  104927. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  104928. /**
  104929. * Enables physics to the current scene
  104930. * @param gravity defines the scene's gravity for the physics engine
  104931. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  104932. * @return a boolean indicating if the physics engine was initialized
  104933. */
  104934. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  104935. /**
  104936. * Disables and disposes the physics engine associated with the scene
  104937. */
  104938. disablePhysicsEngine(): void;
  104939. /**
  104940. * Gets a boolean indicating if there is an active physics engine
  104941. * @returns a boolean indicating if there is an active physics engine
  104942. */
  104943. isPhysicsEnabled(): boolean;
  104944. /**
  104945. * Deletes a physics compound impostor
  104946. * @param compound defines the compound to delete
  104947. */
  104948. deleteCompoundImpostor(compound: any): void;
  104949. /**
  104950. * An event triggered when physic simulation is about to be run
  104951. */
  104952. onBeforePhysicsObservable: Observable<Scene>;
  104953. /**
  104954. * An event triggered when physic simulation has been done
  104955. */
  104956. onAfterPhysicsObservable: Observable<Scene>;
  104957. }
  104958. interface AbstractMesh {
  104959. /** @hidden */
  104960. _physicsImpostor: Nullable<PhysicsImpostor>;
  104961. /**
  104962. * Gets or sets impostor used for physic simulation
  104963. * @see http://doc.babylonjs.com/features/physics_engine
  104964. */
  104965. physicsImpostor: Nullable<PhysicsImpostor>;
  104966. /**
  104967. * Gets the current physics impostor
  104968. * @see http://doc.babylonjs.com/features/physics_engine
  104969. * @returns a physics impostor or null
  104970. */
  104971. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  104972. /** Apply a physic impulse to the mesh
  104973. * @param force defines the force to apply
  104974. * @param contactPoint defines where to apply the force
  104975. * @returns the current mesh
  104976. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  104977. */
  104978. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  104979. /**
  104980. * Creates a physic joint between two meshes
  104981. * @param otherMesh defines the other mesh to use
  104982. * @param pivot1 defines the pivot to use on this mesh
  104983. * @param pivot2 defines the pivot to use on the other mesh
  104984. * @param options defines additional options (can be plugin dependent)
  104985. * @returns the current mesh
  104986. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  104987. */
  104988. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  104989. /** @hidden */
  104990. _disposePhysicsObserver: Nullable<Observer<Node>>;
  104991. }
  104992. /**
  104993. * Defines the physics engine scene component responsible to manage a physics engine
  104994. */
  104995. export class PhysicsEngineSceneComponent implements ISceneComponent {
  104996. /**
  104997. * The component name helpful to identify the component in the list of scene components.
  104998. */
  104999. readonly name: string;
  105000. /**
  105001. * The scene the component belongs to.
  105002. */
  105003. scene: Scene;
  105004. /**
  105005. * Creates a new instance of the component for the given scene
  105006. * @param scene Defines the scene to register the component in
  105007. */
  105008. constructor(scene: Scene);
  105009. /**
  105010. * Registers the component in a given scene
  105011. */
  105012. register(): void;
  105013. /**
  105014. * Rebuilds the elements related to this component in case of
  105015. * context lost for instance.
  105016. */
  105017. rebuild(): void;
  105018. /**
  105019. * Disposes the component and the associated ressources
  105020. */
  105021. dispose(): void;
  105022. }
  105023. }
  105024. declare module BABYLON {
  105025. /**
  105026. * A helper for physics simulations
  105027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105028. */
  105029. export class PhysicsHelper {
  105030. private _scene;
  105031. private _physicsEngine;
  105032. /**
  105033. * Initializes the Physics helper
  105034. * @param scene Babylon.js scene
  105035. */
  105036. constructor(scene: Scene);
  105037. /**
  105038. * Applies a radial explosion impulse
  105039. * @param origin the origin of the explosion
  105040. * @param radius the explosion radius
  105041. * @param strength the explosion strength
  105042. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105043. * @returns A physics radial explosion event, or null
  105044. */
  105045. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105046. /**
  105047. * Applies a radial explosion force
  105048. * @param origin the origin of the explosion
  105049. * @param radius the explosion radius
  105050. * @param strength the explosion strength
  105051. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105052. * @returns A physics radial explosion event, or null
  105053. */
  105054. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  105055. /**
  105056. * Creates a gravitational field
  105057. * @param origin the origin of the explosion
  105058. * @param radius the explosion radius
  105059. * @param strength the explosion strength
  105060. * @param falloff possible options: Constant & Linear. Defaults to Constant
  105061. * @returns A physics gravitational field event, or null
  105062. */
  105063. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  105064. /**
  105065. * Creates a physics updraft event
  105066. * @param origin the origin of the updraft
  105067. * @param radius the radius of the updraft
  105068. * @param strength the strength of the updraft
  105069. * @param height the height of the updraft
  105070. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  105071. * @returns A physics updraft event, or null
  105072. */
  105073. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  105074. /**
  105075. * Creates a physics vortex event
  105076. * @param origin the of the vortex
  105077. * @param radius the radius of the vortex
  105078. * @param strength the strength of the vortex
  105079. * @param height the height of the vortex
  105080. * @returns a Physics vortex event, or null
  105081. * A physics vortex event or null
  105082. */
  105083. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  105084. }
  105085. /**
  105086. * Represents a physics radial explosion event
  105087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105088. */
  105089. export class PhysicsRadialExplosionEvent {
  105090. private _scene;
  105091. private _sphere;
  105092. private _sphereOptions;
  105093. private _rays;
  105094. private _dataFetched;
  105095. /**
  105096. * Initializes a radial explosioin event
  105097. * @param scene BabylonJS scene
  105098. */
  105099. constructor(scene: Scene);
  105100. /**
  105101. * Returns the data related to the radial explosion event (sphere & rays).
  105102. * @returns The radial explosion event data
  105103. */
  105104. getData(): PhysicsRadialExplosionEventData;
  105105. /**
  105106. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  105107. * @param impostor A physics imposter
  105108. * @param origin the origin of the explosion
  105109. * @param radius the explosion radius
  105110. * @param strength the explosion strength
  105111. * @param falloff possible options: Constant & Linear
  105112. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  105113. */
  105114. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  105115. /**
  105116. * Disposes the sphere.
  105117. * @param force Specifies if the sphere should be disposed by force
  105118. */
  105119. dispose(force?: boolean): void;
  105120. /*** Helpers ***/
  105121. private _prepareSphere;
  105122. private _intersectsWithSphere;
  105123. }
  105124. /**
  105125. * Represents a gravitational field event
  105126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105127. */
  105128. export class PhysicsGravitationalFieldEvent {
  105129. private _physicsHelper;
  105130. private _scene;
  105131. private _origin;
  105132. private _radius;
  105133. private _strength;
  105134. private _falloff;
  105135. private _tickCallback;
  105136. private _sphere;
  105137. private _dataFetched;
  105138. /**
  105139. * Initializes the physics gravitational field event
  105140. * @param physicsHelper A physics helper
  105141. * @param scene BabylonJS scene
  105142. * @param origin The origin position of the gravitational field event
  105143. * @param radius The radius of the gravitational field event
  105144. * @param strength The strength of the gravitational field event
  105145. * @param falloff The falloff for the gravitational field event
  105146. */
  105147. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  105148. /**
  105149. * Returns the data related to the gravitational field event (sphere).
  105150. * @returns A gravitational field event
  105151. */
  105152. getData(): PhysicsGravitationalFieldEventData;
  105153. /**
  105154. * Enables the gravitational field.
  105155. */
  105156. enable(): void;
  105157. /**
  105158. * Disables the gravitational field.
  105159. */
  105160. disable(): void;
  105161. /**
  105162. * Disposes the sphere.
  105163. * @param force The force to dispose from the gravitational field event
  105164. */
  105165. dispose(force?: boolean): void;
  105166. private _tick;
  105167. }
  105168. /**
  105169. * Represents a physics updraft event
  105170. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105171. */
  105172. export class PhysicsUpdraftEvent {
  105173. private _scene;
  105174. private _origin;
  105175. private _radius;
  105176. private _strength;
  105177. private _height;
  105178. private _updraftMode;
  105179. private _physicsEngine;
  105180. private _originTop;
  105181. private _originDirection;
  105182. private _tickCallback;
  105183. private _cylinder;
  105184. private _cylinderPosition;
  105185. private _dataFetched;
  105186. /**
  105187. * Initializes the physics updraft event
  105188. * @param _scene BabylonJS scene
  105189. * @param _origin The origin position of the updraft
  105190. * @param _radius The radius of the updraft
  105191. * @param _strength The strength of the updraft
  105192. * @param _height The height of the updraft
  105193. * @param _updraftMode The mode of the updraft
  105194. */
  105195. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  105196. /**
  105197. * Returns the data related to the updraft event (cylinder).
  105198. * @returns A physics updraft event
  105199. */
  105200. getData(): PhysicsUpdraftEventData;
  105201. /**
  105202. * Enables the updraft.
  105203. */
  105204. enable(): void;
  105205. /**
  105206. * Disables the cortex.
  105207. */
  105208. disable(): void;
  105209. /**
  105210. * Disposes the sphere.
  105211. * @param force Specifies if the updraft should be disposed by force
  105212. */
  105213. dispose(force?: boolean): void;
  105214. private getImpostorForceAndContactPoint;
  105215. private _tick;
  105216. /*** Helpers ***/
  105217. private _prepareCylinder;
  105218. private _intersectsWithCylinder;
  105219. }
  105220. /**
  105221. * Represents a physics vortex event
  105222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105223. */
  105224. export class PhysicsVortexEvent {
  105225. private _scene;
  105226. private _origin;
  105227. private _radius;
  105228. private _strength;
  105229. private _height;
  105230. private _physicsEngine;
  105231. private _originTop;
  105232. private _centripetalForceThreshold;
  105233. private _updraftMultiplier;
  105234. private _tickCallback;
  105235. private _cylinder;
  105236. private _cylinderPosition;
  105237. private _dataFetched;
  105238. /**
  105239. * Initializes the physics vortex event
  105240. * @param _scene The BabylonJS scene
  105241. * @param _origin The origin position of the vortex
  105242. * @param _radius The radius of the vortex
  105243. * @param _strength The strength of the vortex
  105244. * @param _height The height of the vortex
  105245. */
  105246. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  105247. /**
  105248. * Returns the data related to the vortex event (cylinder).
  105249. * @returns The physics vortex event data
  105250. */
  105251. getData(): PhysicsVortexEventData;
  105252. /**
  105253. * Enables the vortex.
  105254. */
  105255. enable(): void;
  105256. /**
  105257. * Disables the cortex.
  105258. */
  105259. disable(): void;
  105260. /**
  105261. * Disposes the sphere.
  105262. * @param force
  105263. */
  105264. dispose(force?: boolean): void;
  105265. private getImpostorForceAndContactPoint;
  105266. private _tick;
  105267. /*** Helpers ***/
  105268. private _prepareCylinder;
  105269. private _intersectsWithCylinder;
  105270. }
  105271. /**
  105272. * The strenght of the force in correspondence to the distance of the affected object
  105273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105274. */
  105275. export enum PhysicsRadialImpulseFalloff {
  105276. /** Defines that impulse is constant in strength across it's whole radius */
  105277. Constant = 0,
  105278. /** DEfines that impulse gets weaker if it's further from the origin */
  105279. Linear = 1
  105280. }
  105281. /**
  105282. * The strength of the force in correspondence to the distance of the affected object
  105283. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105284. */
  105285. export enum PhysicsUpdraftMode {
  105286. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  105287. Center = 0,
  105288. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  105289. Perpendicular = 1
  105290. }
  105291. /**
  105292. * Interface for a physics force and contact point
  105293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105294. */
  105295. export interface PhysicsForceAndContactPoint {
  105296. /**
  105297. * The force applied at the contact point
  105298. */
  105299. force: Vector3;
  105300. /**
  105301. * The contact point
  105302. */
  105303. contactPoint: Vector3;
  105304. }
  105305. /**
  105306. * Interface for radial explosion event data
  105307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105308. */
  105309. export interface PhysicsRadialExplosionEventData {
  105310. /**
  105311. * A sphere used for the radial explosion event
  105312. */
  105313. sphere: Mesh;
  105314. /**
  105315. * An array of rays for the radial explosion event
  105316. */
  105317. rays: Array<Ray>;
  105318. }
  105319. /**
  105320. * Interface for gravitational field event data
  105321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105322. */
  105323. export interface PhysicsGravitationalFieldEventData {
  105324. /**
  105325. * A sphere mesh used for the gravitational field event
  105326. */
  105327. sphere: Mesh;
  105328. }
  105329. /**
  105330. * Interface for updraft event data
  105331. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105332. */
  105333. export interface PhysicsUpdraftEventData {
  105334. /**
  105335. * A cylinder used for the updraft event
  105336. */
  105337. cylinder: Mesh;
  105338. }
  105339. /**
  105340. * Interface for vortex event data
  105341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105342. */
  105343. export interface PhysicsVortexEventData {
  105344. /**
  105345. * A cylinder used for the vortex event
  105346. */
  105347. cylinder: Mesh;
  105348. }
  105349. }
  105350. declare module BABYLON {
  105351. /**
  105352. * AmmoJS Physics plugin
  105353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105354. * @see https://github.com/kripken/ammo.js/
  105355. */
  105356. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  105357. private _useDeltaForWorldStep;
  105358. /**
  105359. * Reference to the Ammo library
  105360. */
  105361. bjsAMMO: any;
  105362. /**
  105363. * Created ammoJS world which physics bodies are added to
  105364. */
  105365. world: any;
  105366. /**
  105367. * Name of the plugin
  105368. */
  105369. name: string;
  105370. private _timeStep;
  105371. private _fixedTimeStep;
  105372. private _maxSteps;
  105373. private _tmpQuaternion;
  105374. private _tmpAmmoTransform;
  105375. private _tmpAmmoQuaternion;
  105376. private _tmpAmmoConcreteContactResultCallback;
  105377. private _collisionConfiguration;
  105378. private _dispatcher;
  105379. private _overlappingPairCache;
  105380. private _solver;
  105381. private _tmpAmmoVectorA;
  105382. private _tmpAmmoVectorB;
  105383. private _tmpAmmoVectorC;
  105384. private _tmpContactCallbackResult;
  105385. private static readonly DISABLE_COLLISION_FLAG;
  105386. private static readonly KINEMATIC_FLAG;
  105387. private static readonly DISABLE_DEACTIVATION_FLAG;
  105388. /**
  105389. * Initializes the ammoJS plugin
  105390. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  105391. * @param ammoInjection can be used to inject your own ammo reference
  105392. */
  105393. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  105394. /**
  105395. * Sets the gravity of the physics world (m/(s^2))
  105396. * @param gravity Gravity to set
  105397. */
  105398. setGravity(gravity: Vector3): void;
  105399. /**
  105400. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  105401. * @param timeStep timestep to use in seconds
  105402. */
  105403. setTimeStep(timeStep: number): void;
  105404. /**
  105405. * 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)
  105406. * @param fixedTimeStep fixedTimeStep to use in seconds
  105407. */
  105408. setFixedTimeStep(fixedTimeStep: number): void;
  105409. /**
  105410. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  105411. * @param maxSteps the maximum number of steps by the physics engine per frame
  105412. */
  105413. setMaxSteps(maxSteps: number): void;
  105414. /**
  105415. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  105416. * @returns the current timestep in seconds
  105417. */
  105418. getTimeStep(): number;
  105419. private _isImpostorInContact;
  105420. private _isImpostorPairInContact;
  105421. private _stepSimulation;
  105422. /**
  105423. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  105424. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  105425. * After the step the babylon meshes are set to the position of the physics imposters
  105426. * @param delta amount of time to step forward
  105427. * @param impostors array of imposters to update before/after the step
  105428. */
  105429. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  105430. private _tmpVector;
  105431. private _tmpMatrix;
  105432. /**
  105433. * Applies an implulse on the imposter
  105434. * @param impostor imposter to apply impulse
  105435. * @param force amount of force to be applied to the imposter
  105436. * @param contactPoint the location to apply the impulse on the imposter
  105437. */
  105438. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105439. /**
  105440. * Applies a force on the imposter
  105441. * @param impostor imposter to apply force
  105442. * @param force amount of force to be applied to the imposter
  105443. * @param contactPoint the location to apply the force on the imposter
  105444. */
  105445. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  105446. /**
  105447. * Creates a physics body using the plugin
  105448. * @param impostor the imposter to create the physics body on
  105449. */
  105450. generatePhysicsBody(impostor: PhysicsImpostor): void;
  105451. /**
  105452. * Removes the physics body from the imposter and disposes of the body's memory
  105453. * @param impostor imposter to remove the physics body from
  105454. */
  105455. removePhysicsBody(impostor: PhysicsImpostor): void;
  105456. /**
  105457. * Generates a joint
  105458. * @param impostorJoint the imposter joint to create the joint with
  105459. */
  105460. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  105461. /**
  105462. * Removes a joint
  105463. * @param impostorJoint the imposter joint to remove the joint from
  105464. */
  105465. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  105466. private _addMeshVerts;
  105467. private _createShape;
  105468. /**
  105469. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  105470. * @param impostor imposter containing the physics body and babylon object
  105471. */
  105472. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  105473. /**
  105474. * Sets the babylon object's position/rotation from the physics body's position/rotation
  105475. * @param impostor imposter containing the physics body and babylon object
  105476. * @param newPosition new position
  105477. * @param newRotation new rotation
  105478. */
  105479. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  105480. /**
  105481. * If this plugin is supported
  105482. * @returns true if its supported
  105483. */
  105484. isSupported(): boolean;
  105485. /**
  105486. * Sets the linear velocity of the physics body
  105487. * @param impostor imposter to set the velocity on
  105488. * @param velocity velocity to set
  105489. */
  105490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105491. /**
  105492. * Sets the angular velocity of the physics body
  105493. * @param impostor imposter to set the velocity on
  105494. * @param velocity velocity to set
  105495. */
  105496. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  105497. /**
  105498. * gets the linear velocity
  105499. * @param impostor imposter to get linear velocity from
  105500. * @returns linear velocity
  105501. */
  105502. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105503. /**
  105504. * gets the angular velocity
  105505. * @param impostor imposter to get angular velocity from
  105506. * @returns angular velocity
  105507. */
  105508. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  105509. /**
  105510. * Sets the mass of physics body
  105511. * @param impostor imposter to set the mass on
  105512. * @param mass mass to set
  105513. */
  105514. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  105515. /**
  105516. * Gets the mass of the physics body
  105517. * @param impostor imposter to get the mass from
  105518. * @returns mass
  105519. */
  105520. getBodyMass(impostor: PhysicsImpostor): number;
  105521. /**
  105522. * Gets friction of the impostor
  105523. * @param impostor impostor to get friction from
  105524. * @returns friction value
  105525. */
  105526. getBodyFriction(impostor: PhysicsImpostor): number;
  105527. /**
  105528. * Sets friction of the impostor
  105529. * @param impostor impostor to set friction on
  105530. * @param friction friction value
  105531. */
  105532. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  105533. /**
  105534. * Gets restitution of the impostor
  105535. * @param impostor impostor to get restitution from
  105536. * @returns restitution value
  105537. */
  105538. getBodyRestitution(impostor: PhysicsImpostor): number;
  105539. /**
  105540. * Sets resitution of the impostor
  105541. * @param impostor impostor to set resitution on
  105542. * @param restitution resitution value
  105543. */
  105544. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  105545. /**
  105546. * Sleeps the physics body and stops it from being active
  105547. * @param impostor impostor to sleep
  105548. */
  105549. sleepBody(impostor: PhysicsImpostor): void;
  105550. /**
  105551. * Activates the physics body
  105552. * @param impostor impostor to activate
  105553. */
  105554. wakeUpBody(impostor: PhysicsImpostor): void;
  105555. /**
  105556. * Updates the distance parameters of the joint
  105557. * @param joint joint to update
  105558. * @param maxDistance maximum distance of the joint
  105559. * @param minDistance minimum distance of the joint
  105560. */
  105561. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  105562. /**
  105563. * Sets a motor on the joint
  105564. * @param joint joint to set motor on
  105565. * @param speed speed of the motor
  105566. * @param maxForce maximum force of the motor
  105567. * @param motorIndex index of the motor
  105568. */
  105569. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  105570. /**
  105571. * Sets the motors limit
  105572. * @param joint joint to set limit on
  105573. * @param upperLimit upper limit
  105574. * @param lowerLimit lower limit
  105575. */
  105576. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  105577. /**
  105578. * Syncs the position and rotation of a mesh with the impostor
  105579. * @param mesh mesh to sync
  105580. * @param impostor impostor to update the mesh with
  105581. */
  105582. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  105583. /**
  105584. * Gets the radius of the impostor
  105585. * @param impostor impostor to get radius from
  105586. * @returns the radius
  105587. */
  105588. getRadius(impostor: PhysicsImpostor): number;
  105589. /**
  105590. * Gets the box size of the impostor
  105591. * @param impostor impostor to get box size from
  105592. * @param result the resulting box size
  105593. */
  105594. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  105595. /**
  105596. * Disposes of the impostor
  105597. */
  105598. dispose(): void;
  105599. }
  105600. }
  105601. declare module BABYLON {
  105602. /** @hidden */
  105603. export var blackAndWhitePixelShader: {
  105604. name: string;
  105605. shader: string;
  105606. };
  105607. }
  105608. declare module BABYLON {
  105609. /**
  105610. * Post process used to render in black and white
  105611. */
  105612. export class BlackAndWhitePostProcess extends PostProcess {
  105613. /**
  105614. * Linear about to convert he result to black and white (default: 1)
  105615. */
  105616. degree: number;
  105617. /**
  105618. * Creates a black and white post process
  105619. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  105620. * @param name The name of the effect.
  105621. * @param options The required width/height ratio to downsize to before computing the render pass.
  105622. * @param camera The camera to apply the render pass to.
  105623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105624. * @param engine The engine which the post process will be applied. (default: current engine)
  105625. * @param reusable If the post process can be reused on the same frame. (default: false)
  105626. */
  105627. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105628. }
  105629. }
  105630. declare module BABYLON {
  105631. /**
  105632. * This represents a set of one or more post processes in Babylon.
  105633. * A post process can be used to apply a shader to a texture after it is rendered.
  105634. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  105635. */
  105636. export class PostProcessRenderEffect {
  105637. private _postProcesses;
  105638. private _getPostProcesses;
  105639. private _singleInstance;
  105640. private _cameras;
  105641. private _indicesForCamera;
  105642. /**
  105643. * Name of the effect
  105644. * @hidden
  105645. */
  105646. _name: string;
  105647. /**
  105648. * Instantiates a post process render effect.
  105649. * A post process can be used to apply a shader to a texture after it is rendered.
  105650. * @param engine The engine the effect is tied to
  105651. * @param name The name of the effect
  105652. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  105653. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  105654. */
  105655. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  105656. /**
  105657. * Checks if all the post processes in the effect are supported.
  105658. */
  105659. readonly isSupported: boolean;
  105660. /**
  105661. * Updates the current state of the effect
  105662. * @hidden
  105663. */
  105664. _update(): void;
  105665. /**
  105666. * Attaches the effect on cameras
  105667. * @param cameras The camera to attach to.
  105668. * @hidden
  105669. */
  105670. _attachCameras(cameras: Camera): void;
  105671. /**
  105672. * Attaches the effect on cameras
  105673. * @param cameras The camera to attach to.
  105674. * @hidden
  105675. */
  105676. _attachCameras(cameras: Camera[]): void;
  105677. /**
  105678. * Detatches the effect on cameras
  105679. * @param cameras The camera to detatch from.
  105680. * @hidden
  105681. */
  105682. _detachCameras(cameras: Camera): void;
  105683. /**
  105684. * Detatches the effect on cameras
  105685. * @param cameras The camera to detatch from.
  105686. * @hidden
  105687. */
  105688. _detachCameras(cameras: Camera[]): void;
  105689. /**
  105690. * Enables the effect on given cameras
  105691. * @param cameras The camera to enable.
  105692. * @hidden
  105693. */
  105694. _enable(cameras: Camera): void;
  105695. /**
  105696. * Enables the effect on given cameras
  105697. * @param cameras The camera to enable.
  105698. * @hidden
  105699. */
  105700. _enable(cameras: Nullable<Camera[]>): void;
  105701. /**
  105702. * Disables the effect on the given cameras
  105703. * @param cameras The camera to disable.
  105704. * @hidden
  105705. */
  105706. _disable(cameras: Camera): void;
  105707. /**
  105708. * Disables the effect on the given cameras
  105709. * @param cameras The camera to disable.
  105710. * @hidden
  105711. */
  105712. _disable(cameras: Nullable<Camera[]>): void;
  105713. /**
  105714. * Gets a list of the post processes contained in the effect.
  105715. * @param camera The camera to get the post processes on.
  105716. * @returns The list of the post processes in the effect.
  105717. */
  105718. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  105719. }
  105720. }
  105721. declare module BABYLON {
  105722. /** @hidden */
  105723. export var extractHighlightsPixelShader: {
  105724. name: string;
  105725. shader: string;
  105726. };
  105727. }
  105728. declare module BABYLON {
  105729. /**
  105730. * 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.
  105731. */
  105732. export class ExtractHighlightsPostProcess extends PostProcess {
  105733. /**
  105734. * The luminance threshold, pixels below this value will be set to black.
  105735. */
  105736. threshold: number;
  105737. /** @hidden */
  105738. _exposure: number;
  105739. /**
  105740. * Post process which has the input texture to be used when performing highlight extraction
  105741. * @hidden
  105742. */
  105743. _inputPostProcess: Nullable<PostProcess>;
  105744. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105745. }
  105746. }
  105747. declare module BABYLON {
  105748. /** @hidden */
  105749. export var bloomMergePixelShader: {
  105750. name: string;
  105751. shader: string;
  105752. };
  105753. }
  105754. declare module BABYLON {
  105755. /**
  105756. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  105757. */
  105758. export class BloomMergePostProcess extends PostProcess {
  105759. /** Weight of the bloom to be added to the original input. */
  105760. weight: number;
  105761. /**
  105762. * Creates a new instance of @see BloomMergePostProcess
  105763. * @param name The name of the effect.
  105764. * @param originalFromInput Post process which's input will be used for the merge.
  105765. * @param blurred Blurred highlights post process which's output will be used.
  105766. * @param weight Weight of the bloom to be added to the original input.
  105767. * @param options The required width/height ratio to downsize to before computing the render pass.
  105768. * @param camera The camera to apply the render pass to.
  105769. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105770. * @param engine The engine which the post process will be applied. (default: current engine)
  105771. * @param reusable If the post process can be reused on the same frame. (default: false)
  105772. * @param textureType Type of textures used when performing the post process. (default: 0)
  105773. * @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)
  105774. */
  105775. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  105776. /** Weight of the bloom to be added to the original input. */
  105777. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105778. }
  105779. }
  105780. declare module BABYLON {
  105781. /**
  105782. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  105783. */
  105784. export class BloomEffect extends PostProcessRenderEffect {
  105785. private bloomScale;
  105786. /**
  105787. * @hidden Internal
  105788. */
  105789. _effects: Array<PostProcess>;
  105790. /**
  105791. * @hidden Internal
  105792. */
  105793. _downscale: ExtractHighlightsPostProcess;
  105794. private _blurX;
  105795. private _blurY;
  105796. private _merge;
  105797. /**
  105798. * The luminance threshold to find bright areas of the image to bloom.
  105799. */
  105800. threshold: number;
  105801. /**
  105802. * The strength of the bloom.
  105803. */
  105804. weight: number;
  105805. /**
  105806. * Specifies the size of the bloom blur kernel, relative to the final output size
  105807. */
  105808. kernel: number;
  105809. /**
  105810. * Creates a new instance of @see BloomEffect
  105811. * @param scene The scene the effect belongs to.
  105812. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  105813. * @param bloomKernel The size of the kernel to be used when applying the blur.
  105814. * @param bloomWeight The the strength of bloom.
  105815. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  105816. * @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)
  105817. */
  105818. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  105819. /**
  105820. * Disposes each of the internal effects for a given camera.
  105821. * @param camera The camera to dispose the effect on.
  105822. */
  105823. disposeEffects(camera: Camera): void;
  105824. /**
  105825. * @hidden Internal
  105826. */
  105827. _updateEffects(): void;
  105828. /**
  105829. * Internal
  105830. * @returns if all the contained post processes are ready.
  105831. * @hidden
  105832. */
  105833. _isReady(): boolean;
  105834. }
  105835. }
  105836. declare module BABYLON {
  105837. /** @hidden */
  105838. export var chromaticAberrationPixelShader: {
  105839. name: string;
  105840. shader: string;
  105841. };
  105842. }
  105843. declare module BABYLON {
  105844. /**
  105845. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  105846. */
  105847. export class ChromaticAberrationPostProcess extends PostProcess {
  105848. /**
  105849. * The amount of seperation of rgb channels (default: 30)
  105850. */
  105851. aberrationAmount: number;
  105852. /**
  105853. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  105854. */
  105855. radialIntensity: number;
  105856. /**
  105857. * 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))
  105858. */
  105859. direction: Vector2;
  105860. /**
  105861. * 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))
  105862. */
  105863. centerPosition: Vector2;
  105864. /**
  105865. * Creates a new instance ChromaticAberrationPostProcess
  105866. * @param name The name of the effect.
  105867. * @param screenWidth The width of the screen to apply the effect on.
  105868. * @param screenHeight The height of the screen to apply the effect on.
  105869. * @param options The required width/height ratio to downsize to before computing the render pass.
  105870. * @param camera The camera to apply the render pass to.
  105871. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105872. * @param engine The engine which the post process will be applied. (default: current engine)
  105873. * @param reusable If the post process can be reused on the same frame. (default: false)
  105874. * @param textureType Type of textures used when performing the post process. (default: 0)
  105875. * @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)
  105876. */
  105877. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105878. }
  105879. }
  105880. declare module BABYLON {
  105881. /** @hidden */
  105882. export var circleOfConfusionPixelShader: {
  105883. name: string;
  105884. shader: string;
  105885. };
  105886. }
  105887. declare module BABYLON {
  105888. /**
  105889. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  105890. */
  105891. export class CircleOfConfusionPostProcess extends PostProcess {
  105892. /**
  105893. * 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.
  105894. */
  105895. lensSize: number;
  105896. /**
  105897. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  105898. */
  105899. fStop: number;
  105900. /**
  105901. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  105902. */
  105903. focusDistance: number;
  105904. /**
  105905. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  105906. */
  105907. focalLength: number;
  105908. private _depthTexture;
  105909. /**
  105910. * Creates a new instance CircleOfConfusionPostProcess
  105911. * @param name The name of the effect.
  105912. * @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.
  105913. * @param options The required width/height ratio to downsize to before computing the render pass.
  105914. * @param camera The camera to apply the render pass to.
  105915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105916. * @param engine The engine which the post process will be applied. (default: current engine)
  105917. * @param reusable If the post process can be reused on the same frame. (default: false)
  105918. * @param textureType Type of textures used when performing the post process. (default: 0)
  105919. * @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)
  105920. */
  105921. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  105922. /**
  105923. * 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.
  105924. */
  105925. depthTexture: RenderTargetTexture;
  105926. }
  105927. }
  105928. declare module BABYLON {
  105929. /** @hidden */
  105930. export var colorCorrectionPixelShader: {
  105931. name: string;
  105932. shader: string;
  105933. };
  105934. }
  105935. declare module BABYLON {
  105936. /**
  105937. *
  105938. * This post-process allows the modification of rendered colors by using
  105939. * a 'look-up table' (LUT). This effect is also called Color Grading.
  105940. *
  105941. * The object needs to be provided an url to a texture containing the color
  105942. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  105943. * Use an image editing software to tweak the LUT to match your needs.
  105944. *
  105945. * For an example of a color LUT, see here:
  105946. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  105947. * For explanations on color grading, see here:
  105948. * @see http://udn.epicgames.com/Three/ColorGrading.html
  105949. *
  105950. */
  105951. export class ColorCorrectionPostProcess extends PostProcess {
  105952. private _colorTableTexture;
  105953. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  105954. }
  105955. }
  105956. declare module BABYLON {
  105957. /** @hidden */
  105958. export var convolutionPixelShader: {
  105959. name: string;
  105960. shader: string;
  105961. };
  105962. }
  105963. declare module BABYLON {
  105964. /**
  105965. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  105966. * input texture to perform effects such as edge detection or sharpening
  105967. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  105968. */
  105969. export class ConvolutionPostProcess extends PostProcess {
  105970. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  105971. kernel: number[];
  105972. /**
  105973. * Creates a new instance ConvolutionPostProcess
  105974. * @param name The name of the effect.
  105975. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  105976. * @param options The required width/height ratio to downsize to before computing the render pass.
  105977. * @param camera The camera to apply the render pass to.
  105978. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  105979. * @param engine The engine which the post process will be applied. (default: current engine)
  105980. * @param reusable If the post process can be reused on the same frame. (default: false)
  105981. * @param textureType Type of textures used when performing the post process. (default: 0)
  105982. */
  105983. constructor(name: string,
  105984. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  105985. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  105986. /**
  105987. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105988. */
  105989. static EdgeDetect0Kernel: number[];
  105990. /**
  105991. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105992. */
  105993. static EdgeDetect1Kernel: number[];
  105994. /**
  105995. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  105996. */
  105997. static EdgeDetect2Kernel: number[];
  105998. /**
  105999. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106000. */
  106001. static SharpenKernel: number[];
  106002. /**
  106003. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106004. */
  106005. static EmbossKernel: number[];
  106006. /**
  106007. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  106008. */
  106009. static GaussianKernel: number[];
  106010. }
  106011. }
  106012. declare module BABYLON {
  106013. /**
  106014. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  106015. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  106016. * based on samples that have a large difference in distance than the center pixel.
  106017. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  106018. */
  106019. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  106020. direction: Vector2;
  106021. /**
  106022. * Creates a new instance CircleOfConfusionPostProcess
  106023. * @param name The name of the effect.
  106024. * @param scene The scene the effect belongs to.
  106025. * @param direction The direction the blur should be applied.
  106026. * @param kernel The size of the kernel used to blur.
  106027. * @param options The required width/height ratio to downsize to before computing the render pass.
  106028. * @param camera The camera to apply the render pass to.
  106029. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  106030. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  106031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106032. * @param engine The engine which the post process will be applied. (default: current engine)
  106033. * @param reusable If the post process can be reused on the same frame. (default: false)
  106034. * @param textureType Type of textures used when performing the post process. (default: 0)
  106035. * @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)
  106036. */
  106037. 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);
  106038. }
  106039. }
  106040. declare module BABYLON {
  106041. /** @hidden */
  106042. export var depthOfFieldMergePixelShader: {
  106043. name: string;
  106044. shader: string;
  106045. };
  106046. }
  106047. declare module BABYLON {
  106048. /**
  106049. * Options to be set when merging outputs from the default pipeline.
  106050. */
  106051. export class DepthOfFieldMergePostProcessOptions {
  106052. /**
  106053. * The original image to merge on top of
  106054. */
  106055. originalFromInput: PostProcess;
  106056. /**
  106057. * Parameters to perform the merge of the depth of field effect
  106058. */
  106059. depthOfField?: {
  106060. circleOfConfusion: PostProcess;
  106061. blurSteps: Array<PostProcess>;
  106062. };
  106063. /**
  106064. * Parameters to perform the merge of bloom effect
  106065. */
  106066. bloom?: {
  106067. blurred: PostProcess;
  106068. weight: number;
  106069. };
  106070. }
  106071. /**
  106072. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  106073. */
  106074. export class DepthOfFieldMergePostProcess extends PostProcess {
  106075. private blurSteps;
  106076. /**
  106077. * Creates a new instance of DepthOfFieldMergePostProcess
  106078. * @param name The name of the effect.
  106079. * @param originalFromInput Post process which's input will be used for the merge.
  106080. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  106081. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  106082. * @param options The required width/height ratio to downsize to before computing the render pass.
  106083. * @param camera The camera to apply the render pass to.
  106084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106085. * @param engine The engine which the post process will be applied. (default: current engine)
  106086. * @param reusable If the post process can be reused on the same frame. (default: false)
  106087. * @param textureType Type of textures used when performing the post process. (default: 0)
  106088. * @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)
  106089. */
  106090. 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);
  106091. /**
  106092. * Updates the effect with the current post process compile time values and recompiles the shader.
  106093. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  106094. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  106095. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  106096. * @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
  106097. * @param onCompiled Called when the shader has been compiled.
  106098. * @param onError Called if there is an error when compiling a shader.
  106099. */
  106100. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  106101. }
  106102. }
  106103. declare module BABYLON {
  106104. /**
  106105. * Specifies the level of max blur that should be applied when using the depth of field effect
  106106. */
  106107. export enum DepthOfFieldEffectBlurLevel {
  106108. /**
  106109. * Subtle blur
  106110. */
  106111. Low = 0,
  106112. /**
  106113. * Medium blur
  106114. */
  106115. Medium = 1,
  106116. /**
  106117. * Large blur
  106118. */
  106119. High = 2
  106120. }
  106121. /**
  106122. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  106123. */
  106124. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  106125. private _circleOfConfusion;
  106126. /**
  106127. * @hidden Internal, blurs from high to low
  106128. */
  106129. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  106130. private _depthOfFieldBlurY;
  106131. private _dofMerge;
  106132. /**
  106133. * @hidden Internal post processes in depth of field effect
  106134. */
  106135. _effects: Array<PostProcess>;
  106136. /**
  106137. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  106138. */
  106139. focalLength: number;
  106140. /**
  106141. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  106142. */
  106143. fStop: number;
  106144. /**
  106145. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  106146. */
  106147. focusDistance: number;
  106148. /**
  106149. * 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.
  106150. */
  106151. lensSize: number;
  106152. /**
  106153. * Creates a new instance DepthOfFieldEffect
  106154. * @param scene The scene the effect belongs to.
  106155. * @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.
  106156. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  106157. * @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)
  106158. */
  106159. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  106160. /**
  106161. * 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.
  106162. */
  106163. depthTexture: RenderTargetTexture;
  106164. /**
  106165. * Disposes each of the internal effects for a given camera.
  106166. * @param camera The camera to dispose the effect on.
  106167. */
  106168. disposeEffects(camera: Camera): void;
  106169. /**
  106170. * @hidden Internal
  106171. */
  106172. _updateEffects(): void;
  106173. /**
  106174. * Internal
  106175. * @returns if all the contained post processes are ready.
  106176. * @hidden
  106177. */
  106178. _isReady(): boolean;
  106179. }
  106180. }
  106181. declare module BABYLON {
  106182. /** @hidden */
  106183. export var displayPassPixelShader: {
  106184. name: string;
  106185. shader: string;
  106186. };
  106187. }
  106188. declare module BABYLON {
  106189. /**
  106190. * DisplayPassPostProcess which produces an output the same as it's input
  106191. */
  106192. export class DisplayPassPostProcess extends PostProcess {
  106193. /**
  106194. * Creates the DisplayPassPostProcess
  106195. * @param name The name of the effect.
  106196. * @param options The required width/height ratio to downsize to before computing the render pass.
  106197. * @param camera The camera to apply the render pass to.
  106198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106199. * @param engine The engine which the post process will be applied. (default: current engine)
  106200. * @param reusable If the post process can be reused on the same frame. (default: false)
  106201. */
  106202. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106203. }
  106204. }
  106205. declare module BABYLON {
  106206. /** @hidden */
  106207. export var filterPixelShader: {
  106208. name: string;
  106209. shader: string;
  106210. };
  106211. }
  106212. declare module BABYLON {
  106213. /**
  106214. * Applies a kernel filter to the image
  106215. */
  106216. export class FilterPostProcess extends PostProcess {
  106217. /** The matrix to be applied to the image */
  106218. kernelMatrix: Matrix;
  106219. /**
  106220. *
  106221. * @param name The name of the effect.
  106222. * @param kernelMatrix The matrix to be applied to the image
  106223. * @param options The required width/height ratio to downsize to before computing the render pass.
  106224. * @param camera The camera to apply the render pass to.
  106225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106226. * @param engine The engine which the post process will be applied. (default: current engine)
  106227. * @param reusable If the post process can be reused on the same frame. (default: false)
  106228. */
  106229. constructor(name: string,
  106230. /** The matrix to be applied to the image */
  106231. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106232. }
  106233. }
  106234. declare module BABYLON {
  106235. /** @hidden */
  106236. export var fxaaPixelShader: {
  106237. name: string;
  106238. shader: string;
  106239. };
  106240. }
  106241. declare module BABYLON {
  106242. /** @hidden */
  106243. export var fxaaVertexShader: {
  106244. name: string;
  106245. shader: string;
  106246. };
  106247. }
  106248. declare module BABYLON {
  106249. /**
  106250. * Fxaa post process
  106251. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  106252. */
  106253. export class FxaaPostProcess extends PostProcess {
  106254. /** @hidden */
  106255. texelWidth: number;
  106256. /** @hidden */
  106257. texelHeight: number;
  106258. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106259. private _getDefines;
  106260. }
  106261. }
  106262. declare module BABYLON {
  106263. /** @hidden */
  106264. export var grainPixelShader: {
  106265. name: string;
  106266. shader: string;
  106267. };
  106268. }
  106269. declare module BABYLON {
  106270. /**
  106271. * The GrainPostProcess adds noise to the image at mid luminance levels
  106272. */
  106273. export class GrainPostProcess extends PostProcess {
  106274. /**
  106275. * The intensity of the grain added (default: 30)
  106276. */
  106277. intensity: number;
  106278. /**
  106279. * If the grain should be randomized on every frame
  106280. */
  106281. animated: boolean;
  106282. /**
  106283. * Creates a new instance of @see GrainPostProcess
  106284. * @param name The name of the effect.
  106285. * @param options The required width/height ratio to downsize to before computing the render pass.
  106286. * @param camera The camera to apply the render pass to.
  106287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106288. * @param engine The engine which the post process will be applied. (default: current engine)
  106289. * @param reusable If the post process can be reused on the same frame. (default: false)
  106290. * @param textureType Type of textures used when performing the post process. (default: 0)
  106291. * @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)
  106292. */
  106293. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106294. }
  106295. }
  106296. declare module BABYLON {
  106297. /** @hidden */
  106298. export var highlightsPixelShader: {
  106299. name: string;
  106300. shader: string;
  106301. };
  106302. }
  106303. declare module BABYLON {
  106304. /**
  106305. * Extracts highlights from the image
  106306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106307. */
  106308. export class HighlightsPostProcess extends PostProcess {
  106309. /**
  106310. * Extracts highlights from the image
  106311. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  106312. * @param name The name of the effect.
  106313. * @param options The required width/height ratio to downsize to before computing the render pass.
  106314. * @param camera The camera to apply the render pass to.
  106315. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106316. * @param engine The engine which the post process will be applied. (default: current engine)
  106317. * @param reusable If the post process can be reused on the same frame. (default: false)
  106318. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  106319. */
  106320. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  106321. }
  106322. }
  106323. declare module BABYLON {
  106324. /** @hidden */
  106325. export var mrtFragmentDeclaration: {
  106326. name: string;
  106327. shader: string;
  106328. };
  106329. }
  106330. declare module BABYLON {
  106331. /** @hidden */
  106332. export var geometryPixelShader: {
  106333. name: string;
  106334. shader: string;
  106335. };
  106336. }
  106337. declare module BABYLON {
  106338. /** @hidden */
  106339. export var geometryVertexShader: {
  106340. name: string;
  106341. shader: string;
  106342. };
  106343. }
  106344. declare module BABYLON {
  106345. /**
  106346. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  106347. */
  106348. export class GeometryBufferRenderer {
  106349. /**
  106350. * Constant used to retrieve the position texture index in the G-Buffer textures array
  106351. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  106352. */
  106353. static readonly POSITION_TEXTURE_TYPE: number;
  106354. /**
  106355. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  106356. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  106357. */
  106358. static readonly VELOCITY_TEXTURE_TYPE: number;
  106359. /**
  106360. * Dictionary used to store the previous transformation matrices of each rendered mesh
  106361. * in order to compute objects velocities when enableVelocity is set to "true"
  106362. * @hidden
  106363. */
  106364. _previousTransformationMatrices: {
  106365. [index: number]: Matrix;
  106366. };
  106367. private _scene;
  106368. private _multiRenderTarget;
  106369. private _ratio;
  106370. private _enablePosition;
  106371. private _enableVelocity;
  106372. private _positionIndex;
  106373. private _velocityIndex;
  106374. protected _effect: Effect;
  106375. protected _cachedDefines: string;
  106376. /**
  106377. * Set the render list (meshes to be rendered) used in the G buffer.
  106378. */
  106379. renderList: Mesh[];
  106380. /**
  106381. * Gets wether or not G buffer are supported by the running hardware.
  106382. * This requires draw buffer supports
  106383. */
  106384. readonly isSupported: boolean;
  106385. /**
  106386. * Returns the index of the given texture type in the G-Buffer textures array
  106387. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  106388. * @returns the index of the given texture type in the G-Buffer textures array
  106389. */
  106390. getTextureIndex(textureType: number): number;
  106391. /**
  106392. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  106393. */
  106394. /**
  106395. * Sets whether or not objects positions are enabled for the G buffer.
  106396. */
  106397. enablePosition: boolean;
  106398. /**
  106399. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  106400. */
  106401. /**
  106402. * Sets wether or not objects velocities are enabled for the G buffer.
  106403. */
  106404. enableVelocity: boolean;
  106405. /**
  106406. * Gets the scene associated with the buffer.
  106407. */
  106408. readonly scene: Scene;
  106409. /**
  106410. * Gets the ratio used by the buffer during its creation.
  106411. * How big is the buffer related to the main canvas.
  106412. */
  106413. readonly ratio: number;
  106414. /** @hidden */
  106415. static _SceneComponentInitialization: (scene: Scene) => void;
  106416. /**
  106417. * Creates a new G Buffer for the scene
  106418. * @param scene The scene the buffer belongs to
  106419. * @param ratio How big is the buffer related to the main canvas.
  106420. */
  106421. constructor(scene: Scene, ratio?: number);
  106422. /**
  106423. * Checks wether everything is ready to render a submesh to the G buffer.
  106424. * @param subMesh the submesh to check readiness for
  106425. * @param useInstances is the mesh drawn using instance or not
  106426. * @returns true if ready otherwise false
  106427. */
  106428. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106429. /**
  106430. * Gets the current underlying G Buffer.
  106431. * @returns the buffer
  106432. */
  106433. getGBuffer(): MultiRenderTarget;
  106434. /**
  106435. * Gets the number of samples used to render the buffer (anti aliasing).
  106436. */
  106437. /**
  106438. * Sets the number of samples used to render the buffer (anti aliasing).
  106439. */
  106440. samples: number;
  106441. /**
  106442. * Disposes the renderer and frees up associated resources.
  106443. */
  106444. dispose(): void;
  106445. protected _createRenderTargets(): void;
  106446. }
  106447. }
  106448. declare module BABYLON {
  106449. /** @hidden */
  106450. export var motionBlurPixelShader: {
  106451. name: string;
  106452. shader: string;
  106453. };
  106454. }
  106455. declare module BABYLON {
  106456. /**
  106457. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  106458. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  106459. * As an example, all you have to do is to create the post-process:
  106460. * var mb = new BABYLON.MotionBlurPostProcess(
  106461. * 'mb', // The name of the effect.
  106462. * scene, // The scene containing the objects to blur according to their velocity.
  106463. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  106464. * camera // The camera to apply the render pass to.
  106465. * );
  106466. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  106467. */
  106468. export class MotionBlurPostProcess extends PostProcess {
  106469. /**
  106470. * Defines how much the image is blurred by the movement. Default value is equal to 1
  106471. */
  106472. motionStrength: number;
  106473. /**
  106474. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  106475. */
  106476. /**
  106477. * Sets the number of iterations to be used for motion blur quality
  106478. */
  106479. motionBlurSamples: number;
  106480. private _motionBlurSamples;
  106481. private _geometryBufferRenderer;
  106482. /**
  106483. * Creates a new instance MotionBlurPostProcess
  106484. * @param name The name of the effect.
  106485. * @param scene The scene containing the objects to blur according to their velocity.
  106486. * @param options The required width/height ratio to downsize to before computing the render pass.
  106487. * @param camera The camera to apply the render pass to.
  106488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106489. * @param engine The engine which the post process will be applied. (default: current engine)
  106490. * @param reusable If the post process can be reused on the same frame. (default: false)
  106491. * @param textureType Type of textures used when performing the post process. (default: 0)
  106492. * @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)
  106493. */
  106494. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106495. /**
  106496. * Disposes the post process.
  106497. * @param camera The camera to dispose the post process on.
  106498. */
  106499. dispose(camera?: Camera): void;
  106500. }
  106501. }
  106502. declare module BABYLON {
  106503. /** @hidden */
  106504. export var refractionPixelShader: {
  106505. name: string;
  106506. shader: string;
  106507. };
  106508. }
  106509. declare module BABYLON {
  106510. /**
  106511. * Post process which applies a refractin texture
  106512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106513. */
  106514. export class RefractionPostProcess extends PostProcess {
  106515. /** the base color of the refraction (used to taint the rendering) */
  106516. color: Color3;
  106517. /** simulated refraction depth */
  106518. depth: number;
  106519. /** the coefficient of the base color (0 to remove base color tainting) */
  106520. colorLevel: number;
  106521. private _refTexture;
  106522. private _ownRefractionTexture;
  106523. /**
  106524. * Gets or sets the refraction texture
  106525. * Please note that you are responsible for disposing the texture if you set it manually
  106526. */
  106527. refractionTexture: Texture;
  106528. /**
  106529. * Initializes the RefractionPostProcess
  106530. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  106531. * @param name The name of the effect.
  106532. * @param refractionTextureUrl Url of the refraction texture to use
  106533. * @param color the base color of the refraction (used to taint the rendering)
  106534. * @param depth simulated refraction depth
  106535. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  106536. * @param camera The camera to apply the render pass to.
  106537. * @param options The required width/height ratio to downsize to before computing the render pass.
  106538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106539. * @param engine The engine which the post process will be applied. (default: current engine)
  106540. * @param reusable If the post process can be reused on the same frame. (default: false)
  106541. */
  106542. constructor(name: string, refractionTextureUrl: string,
  106543. /** the base color of the refraction (used to taint the rendering) */
  106544. color: Color3,
  106545. /** simulated refraction depth */
  106546. depth: number,
  106547. /** the coefficient of the base color (0 to remove base color tainting) */
  106548. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106549. /**
  106550. * Disposes of the post process
  106551. * @param camera Camera to dispose post process on
  106552. */
  106553. dispose(camera: Camera): void;
  106554. }
  106555. }
  106556. declare module BABYLON {
  106557. /** @hidden */
  106558. export var sharpenPixelShader: {
  106559. name: string;
  106560. shader: string;
  106561. };
  106562. }
  106563. declare module BABYLON {
  106564. /**
  106565. * The SharpenPostProcess applies a sharpen kernel to every pixel
  106566. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  106567. */
  106568. export class SharpenPostProcess extends PostProcess {
  106569. /**
  106570. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  106571. */
  106572. colorAmount: number;
  106573. /**
  106574. * How much sharpness should be applied (default: 0.3)
  106575. */
  106576. edgeAmount: number;
  106577. /**
  106578. * Creates a new instance ConvolutionPostProcess
  106579. * @param name The name of the effect.
  106580. * @param options The required width/height ratio to downsize to before computing the render pass.
  106581. * @param camera The camera to apply the render pass to.
  106582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106583. * @param engine The engine which the post process will be applied. (default: current engine)
  106584. * @param reusable If the post process can be reused on the same frame. (default: false)
  106585. * @param textureType Type of textures used when performing the post process. (default: 0)
  106586. * @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)
  106587. */
  106588. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106589. }
  106590. }
  106591. declare module BABYLON {
  106592. /**
  106593. * PostProcessRenderPipeline
  106594. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  106595. */
  106596. export class PostProcessRenderPipeline {
  106597. private engine;
  106598. private _renderEffects;
  106599. private _renderEffectsForIsolatedPass;
  106600. /**
  106601. * @hidden
  106602. */
  106603. protected _cameras: Camera[];
  106604. /** @hidden */
  106605. _name: string;
  106606. /**
  106607. * Initializes a PostProcessRenderPipeline
  106608. * @param engine engine to add the pipeline to
  106609. * @param name name of the pipeline
  106610. */
  106611. constructor(engine: Engine, name: string);
  106612. /**
  106613. * "PostProcessRenderPipeline"
  106614. * @returns "PostProcessRenderPipeline"
  106615. */
  106616. getClassName(): string;
  106617. /**
  106618. * If all the render effects in the pipeline are support
  106619. */
  106620. readonly isSupported: boolean;
  106621. /**
  106622. * Adds an effect to the pipeline
  106623. * @param renderEffect the effect to add
  106624. */
  106625. addEffect(renderEffect: PostProcessRenderEffect): void;
  106626. /** @hidden */
  106627. _rebuild(): void;
  106628. /** @hidden */
  106629. _enableEffect(renderEffectName: string, cameras: Camera): void;
  106630. /** @hidden */
  106631. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  106632. /** @hidden */
  106633. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106634. /** @hidden */
  106635. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  106636. /** @hidden */
  106637. _attachCameras(cameras: Camera, unique: boolean): void;
  106638. /** @hidden */
  106639. _attachCameras(cameras: Camera[], unique: boolean): void;
  106640. /** @hidden */
  106641. _detachCameras(cameras: Camera): void;
  106642. /** @hidden */
  106643. _detachCameras(cameras: Nullable<Camera[]>): void;
  106644. /** @hidden */
  106645. _update(): void;
  106646. /** @hidden */
  106647. _reset(): void;
  106648. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  106649. /**
  106650. * Disposes of the pipeline
  106651. */
  106652. dispose(): void;
  106653. }
  106654. }
  106655. declare module BABYLON {
  106656. /**
  106657. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  106658. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  106659. */
  106660. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  106661. private _scene;
  106662. private _camerasToBeAttached;
  106663. /**
  106664. * ID of the sharpen post process,
  106665. */
  106666. private readonly SharpenPostProcessId;
  106667. /**
  106668. * @ignore
  106669. * ID of the image processing post process;
  106670. */
  106671. readonly ImageProcessingPostProcessId: string;
  106672. /**
  106673. * @ignore
  106674. * ID of the Fast Approximate Anti-Aliasing post process;
  106675. */
  106676. readonly FxaaPostProcessId: string;
  106677. /**
  106678. * ID of the chromatic aberration post process,
  106679. */
  106680. private readonly ChromaticAberrationPostProcessId;
  106681. /**
  106682. * ID of the grain post process
  106683. */
  106684. private readonly GrainPostProcessId;
  106685. /**
  106686. * Sharpen post process which will apply a sharpen convolution to enhance edges
  106687. */
  106688. sharpen: SharpenPostProcess;
  106689. private _sharpenEffect;
  106690. private bloom;
  106691. /**
  106692. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  106693. */
  106694. depthOfField: DepthOfFieldEffect;
  106695. /**
  106696. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  106697. */
  106698. fxaa: FxaaPostProcess;
  106699. /**
  106700. * Image post processing pass used to perform operations such as tone mapping or color grading.
  106701. */
  106702. imageProcessing: ImageProcessingPostProcess;
  106703. /**
  106704. * Chromatic aberration post process which will shift rgb colors in the image
  106705. */
  106706. chromaticAberration: ChromaticAberrationPostProcess;
  106707. private _chromaticAberrationEffect;
  106708. /**
  106709. * Grain post process which add noise to the image
  106710. */
  106711. grain: GrainPostProcess;
  106712. private _grainEffect;
  106713. /**
  106714. * Glow post process which adds a glow to emmisive areas of the image
  106715. */
  106716. private _glowLayer;
  106717. /**
  106718. * Animations which can be used to tweak settings over a period of time
  106719. */
  106720. animations: Animation[];
  106721. private _imageProcessingConfigurationObserver;
  106722. private _sharpenEnabled;
  106723. private _bloomEnabled;
  106724. private _depthOfFieldEnabled;
  106725. private _depthOfFieldBlurLevel;
  106726. private _fxaaEnabled;
  106727. private _imageProcessingEnabled;
  106728. private _defaultPipelineTextureType;
  106729. private _bloomScale;
  106730. private _chromaticAberrationEnabled;
  106731. private _grainEnabled;
  106732. private _buildAllowed;
  106733. /**
  106734. * Enable or disable the sharpen process from the pipeline
  106735. */
  106736. sharpenEnabled: boolean;
  106737. private _resizeObserver;
  106738. private _hardwareScaleLevel;
  106739. private _bloomKernel;
  106740. /**
  106741. * Specifies the size of the bloom blur kernel, relative to the final output size
  106742. */
  106743. bloomKernel: number;
  106744. /**
  106745. * Specifies the weight of the bloom in the final rendering
  106746. */
  106747. private _bloomWeight;
  106748. /**
  106749. * Specifies the luma threshold for the area that will be blurred by the bloom
  106750. */
  106751. private _bloomThreshold;
  106752. private _hdr;
  106753. /**
  106754. * The strength of the bloom.
  106755. */
  106756. bloomWeight: number;
  106757. /**
  106758. * The strength of the bloom.
  106759. */
  106760. bloomThreshold: number;
  106761. /**
  106762. * The scale of the bloom, lower value will provide better performance.
  106763. */
  106764. bloomScale: number;
  106765. /**
  106766. * Enable or disable the bloom from the pipeline
  106767. */
  106768. bloomEnabled: boolean;
  106769. private _rebuildBloom;
  106770. /**
  106771. * If the depth of field is enabled.
  106772. */
  106773. depthOfFieldEnabled: boolean;
  106774. /**
  106775. * Blur level of the depth of field effect. (Higher blur will effect performance)
  106776. */
  106777. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  106778. /**
  106779. * If the anti aliasing is enabled.
  106780. */
  106781. fxaaEnabled: boolean;
  106782. private _samples;
  106783. /**
  106784. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  106785. */
  106786. samples: number;
  106787. /**
  106788. * If image processing is enabled.
  106789. */
  106790. imageProcessingEnabled: boolean;
  106791. /**
  106792. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  106793. */
  106794. glowLayerEnabled: boolean;
  106795. /**
  106796. * Enable or disable the chromaticAberration process from the pipeline
  106797. */
  106798. chromaticAberrationEnabled: boolean;
  106799. /**
  106800. * Enable or disable the grain process from the pipeline
  106801. */
  106802. grainEnabled: boolean;
  106803. /**
  106804. * @constructor
  106805. * @param name - The rendering pipeline name (default: "")
  106806. * @param hdr - If high dynamic range textures should be used (default: true)
  106807. * @param scene - The scene linked to this pipeline (default: the last created scene)
  106808. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  106809. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  106810. */
  106811. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  106812. /**
  106813. * Force the compilation of the entire pipeline.
  106814. */
  106815. prepare(): void;
  106816. private _hasCleared;
  106817. private _prevPostProcess;
  106818. private _prevPrevPostProcess;
  106819. private _setAutoClearAndTextureSharing;
  106820. private _depthOfFieldSceneObserver;
  106821. private _buildPipeline;
  106822. private _disposePostProcesses;
  106823. /**
  106824. * Adds a camera to the pipeline
  106825. * @param camera the camera to be added
  106826. */
  106827. addCamera(camera: Camera): void;
  106828. /**
  106829. * Removes a camera from the pipeline
  106830. * @param camera the camera to remove
  106831. */
  106832. removeCamera(camera: Camera): void;
  106833. /**
  106834. * Dispose of the pipeline and stop all post processes
  106835. */
  106836. dispose(): void;
  106837. /**
  106838. * Serialize the rendering pipeline (Used when exporting)
  106839. * @returns the serialized object
  106840. */
  106841. serialize(): any;
  106842. /**
  106843. * Parse the serialized pipeline
  106844. * @param source Source pipeline.
  106845. * @param scene The scene to load the pipeline to.
  106846. * @param rootUrl The URL of the serialized pipeline.
  106847. * @returns An instantiated pipeline from the serialized object.
  106848. */
  106849. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  106850. }
  106851. }
  106852. declare module BABYLON {
  106853. /** @hidden */
  106854. export var lensHighlightsPixelShader: {
  106855. name: string;
  106856. shader: string;
  106857. };
  106858. }
  106859. declare module BABYLON {
  106860. /** @hidden */
  106861. export var depthOfFieldPixelShader: {
  106862. name: string;
  106863. shader: string;
  106864. };
  106865. }
  106866. declare module BABYLON {
  106867. /**
  106868. * BABYLON.JS Chromatic Aberration GLSL Shader
  106869. * Author: Olivier Guyot
  106870. * Separates very slightly R, G and B colors on the edges of the screen
  106871. * Inspired by Francois Tarlier & Martins Upitis
  106872. */
  106873. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  106874. /**
  106875. * @ignore
  106876. * The chromatic aberration PostProcess id in the pipeline
  106877. */
  106878. LensChromaticAberrationEffect: string;
  106879. /**
  106880. * @ignore
  106881. * The highlights enhancing PostProcess id in the pipeline
  106882. */
  106883. HighlightsEnhancingEffect: string;
  106884. /**
  106885. * @ignore
  106886. * The depth-of-field PostProcess id in the pipeline
  106887. */
  106888. LensDepthOfFieldEffect: string;
  106889. private _scene;
  106890. private _depthTexture;
  106891. private _grainTexture;
  106892. private _chromaticAberrationPostProcess;
  106893. private _highlightsPostProcess;
  106894. private _depthOfFieldPostProcess;
  106895. private _edgeBlur;
  106896. private _grainAmount;
  106897. private _chromaticAberration;
  106898. private _distortion;
  106899. private _highlightsGain;
  106900. private _highlightsThreshold;
  106901. private _dofDistance;
  106902. private _dofAperture;
  106903. private _dofDarken;
  106904. private _dofPentagon;
  106905. private _blurNoise;
  106906. /**
  106907. * @constructor
  106908. *
  106909. * Effect parameters are as follow:
  106910. * {
  106911. * chromatic_aberration: number; // from 0 to x (1 for realism)
  106912. * edge_blur: number; // from 0 to x (1 for realism)
  106913. * distortion: number; // from 0 to x (1 for realism)
  106914. * grain_amount: number; // from 0 to 1
  106915. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  106916. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  106917. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  106918. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  106919. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  106920. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  106921. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  106922. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  106923. * }
  106924. * Note: if an effect parameter is unset, effect is disabled
  106925. *
  106926. * @param name The rendering pipeline name
  106927. * @param parameters - An object containing all parameters (see above)
  106928. * @param scene The scene linked to this pipeline
  106929. * @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)
  106930. * @param cameras The array of cameras that the rendering pipeline will be attached to
  106931. */
  106932. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  106933. /**
  106934. * Sets the amount of blur at the edges
  106935. * @param amount blur amount
  106936. */
  106937. setEdgeBlur(amount: number): void;
  106938. /**
  106939. * Sets edge blur to 0
  106940. */
  106941. disableEdgeBlur(): void;
  106942. /**
  106943. * Sets the amout of grain
  106944. * @param amount Amount of grain
  106945. */
  106946. setGrainAmount(amount: number): void;
  106947. /**
  106948. * Set grain amount to 0
  106949. */
  106950. disableGrain(): void;
  106951. /**
  106952. * Sets the chromatic aberration amount
  106953. * @param amount amount of chromatic aberration
  106954. */
  106955. setChromaticAberration(amount: number): void;
  106956. /**
  106957. * Sets chromatic aberration amount to 0
  106958. */
  106959. disableChromaticAberration(): void;
  106960. /**
  106961. * Sets the EdgeDistortion amount
  106962. * @param amount amount of EdgeDistortion
  106963. */
  106964. setEdgeDistortion(amount: number): void;
  106965. /**
  106966. * Sets edge distortion to 0
  106967. */
  106968. disableEdgeDistortion(): void;
  106969. /**
  106970. * Sets the FocusDistance amount
  106971. * @param amount amount of FocusDistance
  106972. */
  106973. setFocusDistance(amount: number): void;
  106974. /**
  106975. * Disables depth of field
  106976. */
  106977. disableDepthOfField(): void;
  106978. /**
  106979. * Sets the Aperture amount
  106980. * @param amount amount of Aperture
  106981. */
  106982. setAperture(amount: number): void;
  106983. /**
  106984. * Sets the DarkenOutOfFocus amount
  106985. * @param amount amount of DarkenOutOfFocus
  106986. */
  106987. setDarkenOutOfFocus(amount: number): void;
  106988. /**
  106989. * Creates a pentagon bokeh effect
  106990. */
  106991. enablePentagonBokeh(): void;
  106992. /**
  106993. * Disables the pentagon bokeh effect
  106994. */
  106995. disablePentagonBokeh(): void;
  106996. /**
  106997. * Enables noise blur
  106998. */
  106999. enableNoiseBlur(): void;
  107000. /**
  107001. * Disables noise blur
  107002. */
  107003. disableNoiseBlur(): void;
  107004. /**
  107005. * Sets the HighlightsGain amount
  107006. * @param amount amount of HighlightsGain
  107007. */
  107008. setHighlightsGain(amount: number): void;
  107009. /**
  107010. * Sets the HighlightsThreshold amount
  107011. * @param amount amount of HighlightsThreshold
  107012. */
  107013. setHighlightsThreshold(amount: number): void;
  107014. /**
  107015. * Disables highlights
  107016. */
  107017. disableHighlights(): void;
  107018. /**
  107019. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  107020. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  107021. */
  107022. dispose(disableDepthRender?: boolean): void;
  107023. private _createChromaticAberrationPostProcess;
  107024. private _createHighlightsPostProcess;
  107025. private _createDepthOfFieldPostProcess;
  107026. private _createGrainTexture;
  107027. }
  107028. }
  107029. declare module BABYLON {
  107030. /** @hidden */
  107031. export var ssao2PixelShader: {
  107032. name: string;
  107033. shader: string;
  107034. };
  107035. }
  107036. declare module BABYLON {
  107037. /** @hidden */
  107038. export var ssaoCombinePixelShader: {
  107039. name: string;
  107040. shader: string;
  107041. };
  107042. }
  107043. declare module BABYLON {
  107044. /**
  107045. * Render pipeline to produce ssao effect
  107046. */
  107047. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  107048. /**
  107049. * @ignore
  107050. * The PassPostProcess id in the pipeline that contains the original scene color
  107051. */
  107052. SSAOOriginalSceneColorEffect: string;
  107053. /**
  107054. * @ignore
  107055. * The SSAO PostProcess id in the pipeline
  107056. */
  107057. SSAORenderEffect: string;
  107058. /**
  107059. * @ignore
  107060. * The horizontal blur PostProcess id in the pipeline
  107061. */
  107062. SSAOBlurHRenderEffect: string;
  107063. /**
  107064. * @ignore
  107065. * The vertical blur PostProcess id in the pipeline
  107066. */
  107067. SSAOBlurVRenderEffect: string;
  107068. /**
  107069. * @ignore
  107070. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107071. */
  107072. SSAOCombineRenderEffect: string;
  107073. /**
  107074. * The output strength of the SSAO post-process. Default value is 1.0.
  107075. */
  107076. totalStrength: number;
  107077. /**
  107078. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  107079. */
  107080. maxZ: number;
  107081. /**
  107082. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  107083. */
  107084. minZAspect: number;
  107085. private _samples;
  107086. /**
  107087. * Number of samples used for the SSAO calculations. Default value is 8
  107088. */
  107089. samples: number;
  107090. private _textureSamples;
  107091. /**
  107092. * Number of samples to use for antialiasing
  107093. */
  107094. textureSamples: number;
  107095. /**
  107096. * Ratio object used for SSAO ratio and blur ratio
  107097. */
  107098. private _ratio;
  107099. /**
  107100. * Dynamically generated sphere sampler.
  107101. */
  107102. private _sampleSphere;
  107103. /**
  107104. * Blur filter offsets
  107105. */
  107106. private _samplerOffsets;
  107107. private _expensiveBlur;
  107108. /**
  107109. * If bilateral blur should be used
  107110. */
  107111. expensiveBlur: boolean;
  107112. /**
  107113. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  107114. */
  107115. radius: number;
  107116. /**
  107117. * The base color of the SSAO post-process
  107118. * The final result is "base + ssao" between [0, 1]
  107119. */
  107120. base: number;
  107121. /**
  107122. * Support test.
  107123. */
  107124. static readonly IsSupported: boolean;
  107125. private _scene;
  107126. private _depthTexture;
  107127. private _normalTexture;
  107128. private _randomTexture;
  107129. private _originalColorPostProcess;
  107130. private _ssaoPostProcess;
  107131. private _blurHPostProcess;
  107132. private _blurVPostProcess;
  107133. private _ssaoCombinePostProcess;
  107134. private _firstUpdate;
  107135. /**
  107136. * @constructor
  107137. * @param name The rendering pipeline name
  107138. * @param scene The scene linked to this pipeline
  107139. * @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 }
  107140. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107141. */
  107142. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107143. /**
  107144. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107145. */
  107146. dispose(disableGeometryBufferRenderer?: boolean): void;
  107147. private _createBlurPostProcess;
  107148. /** @hidden */
  107149. _rebuild(): void;
  107150. private _bits;
  107151. private _radicalInverse_VdC;
  107152. private _hammersley;
  107153. private _hemisphereSample_uniform;
  107154. private _generateHemisphere;
  107155. private _createSSAOPostProcess;
  107156. private _createSSAOCombinePostProcess;
  107157. private _createRandomTexture;
  107158. /**
  107159. * Serialize the rendering pipeline (Used when exporting)
  107160. * @returns the serialized object
  107161. */
  107162. serialize(): any;
  107163. /**
  107164. * Parse the serialized pipeline
  107165. * @param source Source pipeline.
  107166. * @param scene The scene to load the pipeline to.
  107167. * @param rootUrl The URL of the serialized pipeline.
  107168. * @returns An instantiated pipeline from the serialized object.
  107169. */
  107170. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  107171. }
  107172. }
  107173. declare module BABYLON {
  107174. /** @hidden */
  107175. export var ssaoPixelShader: {
  107176. name: string;
  107177. shader: string;
  107178. };
  107179. }
  107180. declare module BABYLON {
  107181. /**
  107182. * Render pipeline to produce ssao effect
  107183. */
  107184. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  107185. /**
  107186. * @ignore
  107187. * The PassPostProcess id in the pipeline that contains the original scene color
  107188. */
  107189. SSAOOriginalSceneColorEffect: string;
  107190. /**
  107191. * @ignore
  107192. * The SSAO PostProcess id in the pipeline
  107193. */
  107194. SSAORenderEffect: string;
  107195. /**
  107196. * @ignore
  107197. * The horizontal blur PostProcess id in the pipeline
  107198. */
  107199. SSAOBlurHRenderEffect: string;
  107200. /**
  107201. * @ignore
  107202. * The vertical blur PostProcess id in the pipeline
  107203. */
  107204. SSAOBlurVRenderEffect: string;
  107205. /**
  107206. * @ignore
  107207. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  107208. */
  107209. SSAOCombineRenderEffect: string;
  107210. /**
  107211. * The output strength of the SSAO post-process. Default value is 1.0.
  107212. */
  107213. totalStrength: number;
  107214. /**
  107215. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  107216. */
  107217. radius: number;
  107218. /**
  107219. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  107220. * Must not be equal to fallOff and superior to fallOff.
  107221. * Default value is 0.975
  107222. */
  107223. area: number;
  107224. /**
  107225. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  107226. * Must not be equal to area and inferior to area.
  107227. * Default value is 0.0
  107228. */
  107229. fallOff: number;
  107230. /**
  107231. * The base color of the SSAO post-process
  107232. * The final result is "base + ssao" between [0, 1]
  107233. */
  107234. base: number;
  107235. private _scene;
  107236. private _depthTexture;
  107237. private _randomTexture;
  107238. private _originalColorPostProcess;
  107239. private _ssaoPostProcess;
  107240. private _blurHPostProcess;
  107241. private _blurVPostProcess;
  107242. private _ssaoCombinePostProcess;
  107243. private _firstUpdate;
  107244. /**
  107245. * @constructor
  107246. * @param name - The rendering pipeline name
  107247. * @param scene - The scene linked to this pipeline
  107248. * @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 }
  107249. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  107250. */
  107251. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  107252. /**
  107253. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  107254. */
  107255. dispose(disableDepthRender?: boolean): void;
  107256. private _createBlurPostProcess;
  107257. /** @hidden */
  107258. _rebuild(): void;
  107259. private _createSSAOPostProcess;
  107260. private _createSSAOCombinePostProcess;
  107261. private _createRandomTexture;
  107262. }
  107263. }
  107264. declare module BABYLON {
  107265. /** @hidden */
  107266. export var standardPixelShader: {
  107267. name: string;
  107268. shader: string;
  107269. };
  107270. }
  107271. declare module BABYLON {
  107272. /**
  107273. * Standard rendering pipeline
  107274. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107275. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  107276. */
  107277. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  107278. /**
  107279. * Public members
  107280. */
  107281. /**
  107282. * Post-process which contains the original scene color before the pipeline applies all the effects
  107283. */
  107284. originalPostProcess: Nullable<PostProcess>;
  107285. /**
  107286. * Post-process used to down scale an image x4
  107287. */
  107288. downSampleX4PostProcess: Nullable<PostProcess>;
  107289. /**
  107290. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  107291. */
  107292. brightPassPostProcess: Nullable<PostProcess>;
  107293. /**
  107294. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  107295. */
  107296. blurHPostProcesses: PostProcess[];
  107297. /**
  107298. * Post-process array storing all the vertical blur post-processes used by the pipeline
  107299. */
  107300. blurVPostProcesses: PostProcess[];
  107301. /**
  107302. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  107303. */
  107304. textureAdderPostProcess: Nullable<PostProcess>;
  107305. /**
  107306. * Post-process used to create volumetric lighting effect
  107307. */
  107308. volumetricLightPostProcess: Nullable<PostProcess>;
  107309. /**
  107310. * Post-process used to smooth the previous volumetric light post-process on the X axis
  107311. */
  107312. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  107313. /**
  107314. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  107315. */
  107316. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  107317. /**
  107318. * Post-process used to merge the volumetric light effect and the real scene color
  107319. */
  107320. volumetricLightMergePostProces: Nullable<PostProcess>;
  107321. /**
  107322. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  107323. */
  107324. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  107325. /**
  107326. * Base post-process used to calculate the average luminance of the final image for HDR
  107327. */
  107328. luminancePostProcess: Nullable<PostProcess>;
  107329. /**
  107330. * Post-processes used to create down sample post-processes in order to get
  107331. * the average luminance of the final image for HDR
  107332. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  107333. */
  107334. luminanceDownSamplePostProcesses: PostProcess[];
  107335. /**
  107336. * Post-process used to create a HDR effect (light adaptation)
  107337. */
  107338. hdrPostProcess: Nullable<PostProcess>;
  107339. /**
  107340. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  107341. */
  107342. textureAdderFinalPostProcess: Nullable<PostProcess>;
  107343. /**
  107344. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  107345. */
  107346. lensFlareFinalPostProcess: Nullable<PostProcess>;
  107347. /**
  107348. * Post-process used to merge the final HDR post-process and the real scene color
  107349. */
  107350. hdrFinalPostProcess: Nullable<PostProcess>;
  107351. /**
  107352. * Post-process used to create a lens flare effect
  107353. */
  107354. lensFlarePostProcess: Nullable<PostProcess>;
  107355. /**
  107356. * Post-process that merges the result of the lens flare post-process and the real scene color
  107357. */
  107358. lensFlareComposePostProcess: Nullable<PostProcess>;
  107359. /**
  107360. * Post-process used to create a motion blur effect
  107361. */
  107362. motionBlurPostProcess: Nullable<PostProcess>;
  107363. /**
  107364. * Post-process used to create a depth of field effect
  107365. */
  107366. depthOfFieldPostProcess: Nullable<PostProcess>;
  107367. /**
  107368. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  107369. */
  107370. fxaaPostProcess: Nullable<FxaaPostProcess>;
  107371. /**
  107372. * Represents the brightness threshold in order to configure the illuminated surfaces
  107373. */
  107374. brightThreshold: number;
  107375. /**
  107376. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  107377. */
  107378. blurWidth: number;
  107379. /**
  107380. * Sets if the blur for highlighted surfaces must be only horizontal
  107381. */
  107382. horizontalBlur: boolean;
  107383. /**
  107384. * Sets the overall exposure used by the pipeline
  107385. */
  107386. exposure: number;
  107387. /**
  107388. * Texture used typically to simulate "dirty" on camera lens
  107389. */
  107390. lensTexture: Nullable<Texture>;
  107391. /**
  107392. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  107393. */
  107394. volumetricLightCoefficient: number;
  107395. /**
  107396. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  107397. */
  107398. volumetricLightPower: number;
  107399. /**
  107400. * Used the set the blur intensity to smooth the volumetric lights
  107401. */
  107402. volumetricLightBlurScale: number;
  107403. /**
  107404. * Light (spot or directional) used to generate the volumetric lights rays
  107405. * The source light must have a shadow generate so the pipeline can get its
  107406. * depth map
  107407. */
  107408. sourceLight: Nullable<SpotLight | DirectionalLight>;
  107409. /**
  107410. * For eye adaptation, represents the minimum luminance the eye can see
  107411. */
  107412. hdrMinimumLuminance: number;
  107413. /**
  107414. * For eye adaptation, represents the decrease luminance speed
  107415. */
  107416. hdrDecreaseRate: number;
  107417. /**
  107418. * For eye adaptation, represents the increase luminance speed
  107419. */
  107420. hdrIncreaseRate: number;
  107421. /**
  107422. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  107423. */
  107424. lensColorTexture: Nullable<Texture>;
  107425. /**
  107426. * The overall strengh for the lens flare effect
  107427. */
  107428. lensFlareStrength: number;
  107429. /**
  107430. * Dispersion coefficient for lens flare ghosts
  107431. */
  107432. lensFlareGhostDispersal: number;
  107433. /**
  107434. * Main lens flare halo width
  107435. */
  107436. lensFlareHaloWidth: number;
  107437. /**
  107438. * Based on the lens distortion effect, defines how much the lens flare result
  107439. * is distorted
  107440. */
  107441. lensFlareDistortionStrength: number;
  107442. /**
  107443. * Lens star texture must be used to simulate rays on the flares and is available
  107444. * in the documentation
  107445. */
  107446. lensStarTexture: Nullable<Texture>;
  107447. /**
  107448. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  107449. * flare effect by taking account of the dirt texture
  107450. */
  107451. lensFlareDirtTexture: Nullable<Texture>;
  107452. /**
  107453. * Represents the focal length for the depth of field effect
  107454. */
  107455. depthOfFieldDistance: number;
  107456. /**
  107457. * Represents the blur intensity for the blurred part of the depth of field effect
  107458. */
  107459. depthOfFieldBlurWidth: number;
  107460. /**
  107461. * For motion blur, defines how much the image is blurred by the movement
  107462. */
  107463. motionStrength: number;
  107464. /**
  107465. * List of animations for the pipeline (IAnimatable implementation)
  107466. */
  107467. animations: Animation[];
  107468. /**
  107469. * Private members
  107470. */
  107471. private _scene;
  107472. private _currentDepthOfFieldSource;
  107473. private _basePostProcess;
  107474. private _hdrCurrentLuminance;
  107475. private _floatTextureType;
  107476. private _ratio;
  107477. private _bloomEnabled;
  107478. private _depthOfFieldEnabled;
  107479. private _vlsEnabled;
  107480. private _lensFlareEnabled;
  107481. private _hdrEnabled;
  107482. private _motionBlurEnabled;
  107483. private _fxaaEnabled;
  107484. private _motionBlurSamples;
  107485. private _volumetricLightStepsCount;
  107486. private _samples;
  107487. /**
  107488. * @ignore
  107489. * Specifies if the bloom pipeline is enabled
  107490. */
  107491. BloomEnabled: boolean;
  107492. /**
  107493. * @ignore
  107494. * Specifies if the depth of field pipeline is enabed
  107495. */
  107496. DepthOfFieldEnabled: boolean;
  107497. /**
  107498. * @ignore
  107499. * Specifies if the lens flare pipeline is enabed
  107500. */
  107501. LensFlareEnabled: boolean;
  107502. /**
  107503. * @ignore
  107504. * Specifies if the HDR pipeline is enabled
  107505. */
  107506. HDREnabled: boolean;
  107507. /**
  107508. * @ignore
  107509. * Specifies if the volumetric lights scattering effect is enabled
  107510. */
  107511. VLSEnabled: boolean;
  107512. /**
  107513. * @ignore
  107514. * Specifies if the motion blur effect is enabled
  107515. */
  107516. MotionBlurEnabled: boolean;
  107517. /**
  107518. * Specifies if anti-aliasing is enabled
  107519. */
  107520. fxaaEnabled: boolean;
  107521. /**
  107522. * Specifies the number of steps used to calculate the volumetric lights
  107523. * Typically in interval [50, 200]
  107524. */
  107525. volumetricLightStepsCount: number;
  107526. /**
  107527. * Specifies the number of samples used for the motion blur effect
  107528. * Typically in interval [16, 64]
  107529. */
  107530. motionBlurSamples: number;
  107531. /**
  107532. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  107533. */
  107534. samples: number;
  107535. /**
  107536. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  107537. * @constructor
  107538. * @param name The rendering pipeline name
  107539. * @param scene The scene linked to this pipeline
  107540. * @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)
  107541. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  107542. * @param cameras The array of cameras that the rendering pipeline will be attached to
  107543. */
  107544. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  107545. private _buildPipeline;
  107546. private _createDownSampleX4PostProcess;
  107547. private _createBrightPassPostProcess;
  107548. private _createBlurPostProcesses;
  107549. private _createTextureAdderPostProcess;
  107550. private _createVolumetricLightPostProcess;
  107551. private _createLuminancePostProcesses;
  107552. private _createHdrPostProcess;
  107553. private _createLensFlarePostProcess;
  107554. private _createDepthOfFieldPostProcess;
  107555. private _createMotionBlurPostProcess;
  107556. private _getDepthTexture;
  107557. private _disposePostProcesses;
  107558. /**
  107559. * Dispose of the pipeline and stop all post processes
  107560. */
  107561. dispose(): void;
  107562. /**
  107563. * Serialize the rendering pipeline (Used when exporting)
  107564. * @returns the serialized object
  107565. */
  107566. serialize(): any;
  107567. /**
  107568. * Parse the serialized pipeline
  107569. * @param source Source pipeline.
  107570. * @param scene The scene to load the pipeline to.
  107571. * @param rootUrl The URL of the serialized pipeline.
  107572. * @returns An instantiated pipeline from the serialized object.
  107573. */
  107574. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  107575. /**
  107576. * Luminance steps
  107577. */
  107578. static LuminanceSteps: number;
  107579. }
  107580. }
  107581. declare module BABYLON {
  107582. /**
  107583. * PostProcessRenderPipelineManager class
  107584. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107585. */
  107586. export class PostProcessRenderPipelineManager {
  107587. private _renderPipelines;
  107588. /**
  107589. * Initializes a PostProcessRenderPipelineManager
  107590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107591. */
  107592. constructor();
  107593. /**
  107594. * Adds a pipeline to the manager
  107595. * @param renderPipeline The pipeline to add
  107596. */
  107597. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  107598. /**
  107599. * Attaches a camera to the pipeline
  107600. * @param renderPipelineName The name of the pipeline to attach to
  107601. * @param cameras the camera to attach
  107602. * @param unique if the camera can be attached multiple times to the pipeline
  107603. */
  107604. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  107605. /**
  107606. * Detaches a camera from the pipeline
  107607. * @param renderPipelineName The name of the pipeline to detach from
  107608. * @param cameras the camera to detach
  107609. */
  107610. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  107611. /**
  107612. * Enables an effect by name on a pipeline
  107613. * @param renderPipelineName the name of the pipeline to enable the effect in
  107614. * @param renderEffectName the name of the effect to enable
  107615. * @param cameras the cameras that the effect should be enabled on
  107616. */
  107617. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107618. /**
  107619. * Disables an effect by name on a pipeline
  107620. * @param renderPipelineName the name of the pipeline to disable the effect in
  107621. * @param renderEffectName the name of the effect to disable
  107622. * @param cameras the cameras that the effect should be disabled on
  107623. */
  107624. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  107625. /**
  107626. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  107627. */
  107628. update(): void;
  107629. /** @hidden */
  107630. _rebuild(): void;
  107631. /**
  107632. * Disposes of the manager and pipelines
  107633. */
  107634. dispose(): void;
  107635. }
  107636. }
  107637. declare module BABYLON {
  107638. interface Scene {
  107639. /** @hidden (Backing field) */
  107640. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107641. /**
  107642. * Gets the postprocess render pipeline manager
  107643. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  107644. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  107645. */
  107646. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  107647. }
  107648. /**
  107649. * Defines the Render Pipeline scene component responsible to rendering pipelines
  107650. */
  107651. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  107652. /**
  107653. * The component name helpfull to identify the component in the list of scene components.
  107654. */
  107655. readonly name: string;
  107656. /**
  107657. * The scene the component belongs to.
  107658. */
  107659. scene: Scene;
  107660. /**
  107661. * Creates a new instance of the component for the given scene
  107662. * @param scene Defines the scene to register the component in
  107663. */
  107664. constructor(scene: Scene);
  107665. /**
  107666. * Registers the component in a given scene
  107667. */
  107668. register(): void;
  107669. /**
  107670. * Rebuilds the elements related to this component in case of
  107671. * context lost for instance.
  107672. */
  107673. rebuild(): void;
  107674. /**
  107675. * Disposes the component and the associated ressources
  107676. */
  107677. dispose(): void;
  107678. private _gatherRenderTargets;
  107679. }
  107680. }
  107681. declare module BABYLON {
  107682. /** @hidden */
  107683. export var tonemapPixelShader: {
  107684. name: string;
  107685. shader: string;
  107686. };
  107687. }
  107688. declare module BABYLON {
  107689. /** Defines operator used for tonemapping */
  107690. export enum TonemappingOperator {
  107691. /** Hable */
  107692. Hable = 0,
  107693. /** Reinhard */
  107694. Reinhard = 1,
  107695. /** HejiDawson */
  107696. HejiDawson = 2,
  107697. /** Photographic */
  107698. Photographic = 3
  107699. }
  107700. /**
  107701. * Defines a post process to apply tone mapping
  107702. */
  107703. export class TonemapPostProcess extends PostProcess {
  107704. private _operator;
  107705. /** Defines the required exposure adjustement */
  107706. exposureAdjustment: number;
  107707. /**
  107708. * Creates a new TonemapPostProcess
  107709. * @param name defines the name of the postprocess
  107710. * @param _operator defines the operator to use
  107711. * @param exposureAdjustment defines the required exposure adjustement
  107712. * @param camera defines the camera to use (can be null)
  107713. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  107714. * @param engine defines the hosting engine (can be ignore if camera is set)
  107715. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  107716. */
  107717. constructor(name: string, _operator: TonemappingOperator,
  107718. /** Defines the required exposure adjustement */
  107719. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  107720. }
  107721. }
  107722. declare module BABYLON {
  107723. /** @hidden */
  107724. export var depthVertexShader: {
  107725. name: string;
  107726. shader: string;
  107727. };
  107728. }
  107729. declare module BABYLON {
  107730. /** @hidden */
  107731. export var volumetricLightScatteringPixelShader: {
  107732. name: string;
  107733. shader: string;
  107734. };
  107735. }
  107736. declare module BABYLON {
  107737. /** @hidden */
  107738. export var volumetricLightScatteringPassPixelShader: {
  107739. name: string;
  107740. shader: string;
  107741. };
  107742. }
  107743. declare module BABYLON {
  107744. /**
  107745. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  107746. */
  107747. export class VolumetricLightScatteringPostProcess extends PostProcess {
  107748. private _volumetricLightScatteringPass;
  107749. private _volumetricLightScatteringRTT;
  107750. private _viewPort;
  107751. private _screenCoordinates;
  107752. private _cachedDefines;
  107753. /**
  107754. * If not undefined, the mesh position is computed from the attached node position
  107755. */
  107756. attachedNode: {
  107757. position: Vector3;
  107758. };
  107759. /**
  107760. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  107761. */
  107762. customMeshPosition: Vector3;
  107763. /**
  107764. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  107765. */
  107766. useCustomMeshPosition: boolean;
  107767. /**
  107768. * If the post-process should inverse the light scattering direction
  107769. */
  107770. invert: boolean;
  107771. /**
  107772. * The internal mesh used by the post-process
  107773. */
  107774. mesh: Mesh;
  107775. /**
  107776. * @hidden
  107777. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  107778. */
  107779. useDiffuseColor: boolean;
  107780. /**
  107781. * Array containing the excluded meshes not rendered in the internal pass
  107782. */
  107783. excludedMeshes: AbstractMesh[];
  107784. /**
  107785. * Controls the overall intensity of the post-process
  107786. */
  107787. exposure: number;
  107788. /**
  107789. * Dissipates each sample's contribution in range [0, 1]
  107790. */
  107791. decay: number;
  107792. /**
  107793. * Controls the overall intensity of each sample
  107794. */
  107795. weight: number;
  107796. /**
  107797. * Controls the density of each sample
  107798. */
  107799. density: number;
  107800. /**
  107801. * @constructor
  107802. * @param name The post-process name
  107803. * @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)
  107804. * @param camera The camera that the post-process will be attached to
  107805. * @param mesh The mesh used to create the light scattering
  107806. * @param samples The post-process quality, default 100
  107807. * @param samplingModeThe post-process filtering mode
  107808. * @param engine The babylon engine
  107809. * @param reusable If the post-process is reusable
  107810. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  107811. */
  107812. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  107813. /**
  107814. * Returns the string "VolumetricLightScatteringPostProcess"
  107815. * @returns "VolumetricLightScatteringPostProcess"
  107816. */
  107817. getClassName(): string;
  107818. private _isReady;
  107819. /**
  107820. * Sets the new light position for light scattering effect
  107821. * @param position The new custom light position
  107822. */
  107823. setCustomMeshPosition(position: Vector3): void;
  107824. /**
  107825. * Returns the light position for light scattering effect
  107826. * @return Vector3 The custom light position
  107827. */
  107828. getCustomMeshPosition(): Vector3;
  107829. /**
  107830. * Disposes the internal assets and detaches the post-process from the camera
  107831. */
  107832. dispose(camera: Camera): void;
  107833. /**
  107834. * Returns the render target texture used by the post-process
  107835. * @return the render target texture used by the post-process
  107836. */
  107837. getPass(): RenderTargetTexture;
  107838. private _meshExcluded;
  107839. private _createPass;
  107840. private _updateMeshScreenCoordinates;
  107841. /**
  107842. * Creates a default mesh for the Volumeric Light Scattering post-process
  107843. * @param name The mesh name
  107844. * @param scene The scene where to create the mesh
  107845. * @return the default mesh
  107846. */
  107847. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  107848. }
  107849. }
  107850. declare module BABYLON {
  107851. interface Scene {
  107852. /** @hidden (Backing field) */
  107853. _boundingBoxRenderer: BoundingBoxRenderer;
  107854. /** @hidden (Backing field) */
  107855. _forceShowBoundingBoxes: boolean;
  107856. /**
  107857. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  107858. */
  107859. forceShowBoundingBoxes: boolean;
  107860. /**
  107861. * Gets the bounding box renderer associated with the scene
  107862. * @returns a BoundingBoxRenderer
  107863. */
  107864. getBoundingBoxRenderer(): BoundingBoxRenderer;
  107865. }
  107866. interface AbstractMesh {
  107867. /** @hidden (Backing field) */
  107868. _showBoundingBox: boolean;
  107869. /**
  107870. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  107871. */
  107872. showBoundingBox: boolean;
  107873. }
  107874. /**
  107875. * Component responsible of rendering the bounding box of the meshes in a scene.
  107876. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  107877. */
  107878. export class BoundingBoxRenderer implements ISceneComponent {
  107879. /**
  107880. * The component name helpfull to identify the component in the list of scene components.
  107881. */
  107882. readonly name: string;
  107883. /**
  107884. * The scene the component belongs to.
  107885. */
  107886. scene: Scene;
  107887. /**
  107888. * Color of the bounding box lines placed in front of an object
  107889. */
  107890. frontColor: Color3;
  107891. /**
  107892. * Color of the bounding box lines placed behind an object
  107893. */
  107894. backColor: Color3;
  107895. /**
  107896. * Defines if the renderer should show the back lines or not
  107897. */
  107898. showBackLines: boolean;
  107899. /**
  107900. * @hidden
  107901. */
  107902. renderList: SmartArray<BoundingBox>;
  107903. private _colorShader;
  107904. private _vertexBuffers;
  107905. private _indexBuffer;
  107906. /**
  107907. * Instantiates a new bounding box renderer in a scene.
  107908. * @param scene the scene the renderer renders in
  107909. */
  107910. constructor(scene: Scene);
  107911. /**
  107912. * Registers the component in a given scene
  107913. */
  107914. register(): void;
  107915. private _evaluateSubMesh;
  107916. private _activeMesh;
  107917. private _prepareRessources;
  107918. private _createIndexBuffer;
  107919. /**
  107920. * Rebuilds the elements related to this component in case of
  107921. * context lost for instance.
  107922. */
  107923. rebuild(): void;
  107924. /**
  107925. * @hidden
  107926. */
  107927. reset(): void;
  107928. /**
  107929. * Render the bounding boxes of a specific rendering group
  107930. * @param renderingGroupId defines the rendering group to render
  107931. */
  107932. render(renderingGroupId: number): void;
  107933. /**
  107934. * In case of occlusion queries, we can render the occlusion bounding box through this method
  107935. * @param mesh Define the mesh to render the occlusion bounding box for
  107936. */
  107937. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  107938. /**
  107939. * Dispose and release the resources attached to this renderer.
  107940. */
  107941. dispose(): void;
  107942. }
  107943. }
  107944. declare module BABYLON {
  107945. /** @hidden */
  107946. export var depthPixelShader: {
  107947. name: string;
  107948. shader: string;
  107949. };
  107950. }
  107951. declare module BABYLON {
  107952. /**
  107953. * This represents a depth renderer in Babylon.
  107954. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  107955. */
  107956. export class DepthRenderer {
  107957. private _scene;
  107958. private _depthMap;
  107959. private _effect;
  107960. private _cachedDefines;
  107961. private _camera;
  107962. /**
  107963. * Specifiess that the depth renderer will only be used within
  107964. * the camera it is created for.
  107965. * This can help forcing its rendering during the camera processing.
  107966. */
  107967. useOnlyInActiveCamera: boolean;
  107968. /** @hidden */
  107969. static _SceneComponentInitialization: (scene: Scene) => void;
  107970. /**
  107971. * Instantiates a depth renderer
  107972. * @param scene The scene the renderer belongs to
  107973. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  107974. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  107975. */
  107976. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  107977. /**
  107978. * Creates the depth rendering effect and checks if the effect is ready.
  107979. * @param subMesh The submesh to be used to render the depth map of
  107980. * @param useInstances If multiple world instances should be used
  107981. * @returns if the depth renderer is ready to render the depth map
  107982. */
  107983. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  107984. /**
  107985. * Gets the texture which the depth map will be written to.
  107986. * @returns The depth map texture
  107987. */
  107988. getDepthMap(): RenderTargetTexture;
  107989. /**
  107990. * Disposes of the depth renderer.
  107991. */
  107992. dispose(): void;
  107993. }
  107994. }
  107995. declare module BABYLON {
  107996. interface Scene {
  107997. /** @hidden (Backing field) */
  107998. _depthRenderer: {
  107999. [id: string]: DepthRenderer;
  108000. };
  108001. /**
  108002. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  108003. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  108004. * @returns the created depth renderer
  108005. */
  108006. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  108007. /**
  108008. * Disables a depth renderer for a given camera
  108009. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  108010. */
  108011. disableDepthRenderer(camera?: Nullable<Camera>): void;
  108012. }
  108013. /**
  108014. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  108015. * in several rendering techniques.
  108016. */
  108017. export class DepthRendererSceneComponent implements ISceneComponent {
  108018. /**
  108019. * The component name helpfull to identify the component in the list of scene components.
  108020. */
  108021. readonly name: string;
  108022. /**
  108023. * The scene the component belongs to.
  108024. */
  108025. scene: Scene;
  108026. /**
  108027. * Creates a new instance of the component for the given scene
  108028. * @param scene Defines the scene to register the component in
  108029. */
  108030. constructor(scene: Scene);
  108031. /**
  108032. * Registers the component in a given scene
  108033. */
  108034. register(): void;
  108035. /**
  108036. * Rebuilds the elements related to this component in case of
  108037. * context lost for instance.
  108038. */
  108039. rebuild(): void;
  108040. /**
  108041. * Disposes the component and the associated ressources
  108042. */
  108043. dispose(): void;
  108044. private _gatherRenderTargets;
  108045. private _gatherActiveCameraRenderTargets;
  108046. }
  108047. }
  108048. declare module BABYLON {
  108049. interface Scene {
  108050. /** @hidden (Backing field) */
  108051. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108052. /**
  108053. * Gets or Sets the current geometry buffer associated to the scene.
  108054. */
  108055. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  108056. /**
  108057. * Enables a GeometryBufferRender and associates it with the scene
  108058. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  108059. * @returns the GeometryBufferRenderer
  108060. */
  108061. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  108062. /**
  108063. * Disables the GeometryBufferRender associated with the scene
  108064. */
  108065. disableGeometryBufferRenderer(): void;
  108066. }
  108067. /**
  108068. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  108069. * in several rendering techniques.
  108070. */
  108071. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  108072. /**
  108073. * The component name helpful to identify the component in the list of scene components.
  108074. */
  108075. readonly name: string;
  108076. /**
  108077. * The scene the component belongs to.
  108078. */
  108079. scene: Scene;
  108080. /**
  108081. * Creates a new instance of the component for the given scene
  108082. * @param scene Defines the scene to register the component in
  108083. */
  108084. constructor(scene: Scene);
  108085. /**
  108086. * Registers the component in a given scene
  108087. */
  108088. register(): void;
  108089. /**
  108090. * Rebuilds the elements related to this component in case of
  108091. * context lost for instance.
  108092. */
  108093. rebuild(): void;
  108094. /**
  108095. * Disposes the component and the associated ressources
  108096. */
  108097. dispose(): void;
  108098. private _gatherRenderTargets;
  108099. }
  108100. }
  108101. declare module BABYLON {
  108102. /** @hidden */
  108103. export var outlinePixelShader: {
  108104. name: string;
  108105. shader: string;
  108106. };
  108107. }
  108108. declare module BABYLON {
  108109. /** @hidden */
  108110. export var outlineVertexShader: {
  108111. name: string;
  108112. shader: string;
  108113. };
  108114. }
  108115. declare module BABYLON {
  108116. interface Scene {
  108117. /** @hidden */
  108118. _outlineRenderer: OutlineRenderer;
  108119. /**
  108120. * Gets the outline renderer associated with the scene
  108121. * @returns a OutlineRenderer
  108122. */
  108123. getOutlineRenderer(): OutlineRenderer;
  108124. }
  108125. interface AbstractMesh {
  108126. /** @hidden (Backing field) */
  108127. _renderOutline: boolean;
  108128. /**
  108129. * Gets or sets a boolean indicating if the outline must be rendered as well
  108130. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  108131. */
  108132. renderOutline: boolean;
  108133. /** @hidden (Backing field) */
  108134. _renderOverlay: boolean;
  108135. /**
  108136. * Gets or sets a boolean indicating if the overlay must be rendered as well
  108137. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  108138. */
  108139. renderOverlay: boolean;
  108140. }
  108141. /**
  108142. * This class is responsible to draw bothe outline/overlay of meshes.
  108143. * It should not be used directly but through the available method on mesh.
  108144. */
  108145. export class OutlineRenderer implements ISceneComponent {
  108146. /**
  108147. * The name of the component. Each component must have a unique name.
  108148. */
  108149. name: string;
  108150. /**
  108151. * The scene the component belongs to.
  108152. */
  108153. scene: Scene;
  108154. /**
  108155. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  108156. */
  108157. zOffset: number;
  108158. private _engine;
  108159. private _effect;
  108160. private _cachedDefines;
  108161. private _savedDepthWrite;
  108162. /**
  108163. * Instantiates a new outline renderer. (There could be only one per scene).
  108164. * @param scene Defines the scene it belongs to
  108165. */
  108166. constructor(scene: Scene);
  108167. /**
  108168. * Register the component to one instance of a scene.
  108169. */
  108170. register(): void;
  108171. /**
  108172. * Rebuilds the elements related to this component in case of
  108173. * context lost for instance.
  108174. */
  108175. rebuild(): void;
  108176. /**
  108177. * Disposes the component and the associated ressources.
  108178. */
  108179. dispose(): void;
  108180. /**
  108181. * Renders the outline in the canvas.
  108182. * @param subMesh Defines the sumesh to render
  108183. * @param batch Defines the batch of meshes in case of instances
  108184. * @param useOverlay Defines if the rendering is for the overlay or the outline
  108185. */
  108186. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  108187. /**
  108188. * Returns whether or not the outline renderer is ready for a given submesh.
  108189. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  108190. * @param subMesh Defines the submesh to check readyness for
  108191. * @param useInstances Defines wheter wee are trying to render instances or not
  108192. * @returns true if ready otherwise false
  108193. */
  108194. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108195. private _beforeRenderingMesh;
  108196. private _afterRenderingMesh;
  108197. }
  108198. }
  108199. declare module BABYLON {
  108200. /**
  108201. * Defines the list of states available for a task inside a AssetsManager
  108202. */
  108203. export enum AssetTaskState {
  108204. /**
  108205. * Initialization
  108206. */
  108207. INIT = 0,
  108208. /**
  108209. * Running
  108210. */
  108211. RUNNING = 1,
  108212. /**
  108213. * Done
  108214. */
  108215. DONE = 2,
  108216. /**
  108217. * Error
  108218. */
  108219. ERROR = 3
  108220. }
  108221. /**
  108222. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  108223. */
  108224. export abstract class AbstractAssetTask {
  108225. /**
  108226. * Task name
  108227. */ name: string;
  108228. /**
  108229. * Callback called when the task is successful
  108230. */
  108231. onSuccess: (task: any) => void;
  108232. /**
  108233. * Callback called when the task is not successful
  108234. */
  108235. onError: (task: any, message?: string, exception?: any) => void;
  108236. /**
  108237. * Creates a new AssetsManager
  108238. * @param name defines the name of the task
  108239. */
  108240. constructor(
  108241. /**
  108242. * Task name
  108243. */ name: string);
  108244. private _isCompleted;
  108245. private _taskState;
  108246. private _errorObject;
  108247. /**
  108248. * Get if the task is completed
  108249. */
  108250. readonly isCompleted: boolean;
  108251. /**
  108252. * Gets the current state of the task
  108253. */
  108254. readonly taskState: AssetTaskState;
  108255. /**
  108256. * Gets the current error object (if task is in error)
  108257. */
  108258. readonly errorObject: {
  108259. message?: string;
  108260. exception?: any;
  108261. };
  108262. /**
  108263. * Internal only
  108264. * @hidden
  108265. */
  108266. _setErrorObject(message?: string, exception?: any): void;
  108267. /**
  108268. * Execute the current task
  108269. * @param scene defines the scene where you want your assets to be loaded
  108270. * @param onSuccess is a callback called when the task is successfully executed
  108271. * @param onError is a callback called if an error occurs
  108272. */
  108273. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108274. /**
  108275. * Execute the current task
  108276. * @param scene defines the scene where you want your assets to be loaded
  108277. * @param onSuccess is a callback called when the task is successfully executed
  108278. * @param onError is a callback called if an error occurs
  108279. */
  108280. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108281. /**
  108282. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  108283. * This can be used with failed tasks that have the reason for failure fixed.
  108284. */
  108285. reset(): void;
  108286. private onErrorCallback;
  108287. private onDoneCallback;
  108288. }
  108289. /**
  108290. * Define the interface used by progress events raised during assets loading
  108291. */
  108292. export interface IAssetsProgressEvent {
  108293. /**
  108294. * Defines the number of remaining tasks to process
  108295. */
  108296. remainingCount: number;
  108297. /**
  108298. * Defines the total number of tasks
  108299. */
  108300. totalCount: number;
  108301. /**
  108302. * Defines the task that was just processed
  108303. */
  108304. task: AbstractAssetTask;
  108305. }
  108306. /**
  108307. * Class used to share progress information about assets loading
  108308. */
  108309. export class AssetsProgressEvent implements IAssetsProgressEvent {
  108310. /**
  108311. * Defines the number of remaining tasks to process
  108312. */
  108313. remainingCount: number;
  108314. /**
  108315. * Defines the total number of tasks
  108316. */
  108317. totalCount: number;
  108318. /**
  108319. * Defines the task that was just processed
  108320. */
  108321. task: AbstractAssetTask;
  108322. /**
  108323. * Creates a AssetsProgressEvent
  108324. * @param remainingCount defines the number of remaining tasks to process
  108325. * @param totalCount defines the total number of tasks
  108326. * @param task defines the task that was just processed
  108327. */
  108328. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  108329. }
  108330. /**
  108331. * Define a task used by AssetsManager to load meshes
  108332. */
  108333. export class MeshAssetTask extends AbstractAssetTask {
  108334. /**
  108335. * Defines the name of the task
  108336. */
  108337. name: string;
  108338. /**
  108339. * Defines the list of mesh's names you want to load
  108340. */
  108341. meshesNames: any;
  108342. /**
  108343. * Defines the root url to use as a base to load your meshes and associated resources
  108344. */
  108345. rootUrl: string;
  108346. /**
  108347. * Defines the filename of the scene to load from
  108348. */
  108349. sceneFilename: string;
  108350. /**
  108351. * Gets the list of loaded meshes
  108352. */
  108353. loadedMeshes: Array<AbstractMesh>;
  108354. /**
  108355. * Gets the list of loaded particle systems
  108356. */
  108357. loadedParticleSystems: Array<IParticleSystem>;
  108358. /**
  108359. * Gets the list of loaded skeletons
  108360. */
  108361. loadedSkeletons: Array<Skeleton>;
  108362. /**
  108363. * Gets the list of loaded animation groups
  108364. */
  108365. loadedAnimationGroups: Array<AnimationGroup>;
  108366. /**
  108367. * Callback called when the task is successful
  108368. */
  108369. onSuccess: (task: MeshAssetTask) => void;
  108370. /**
  108371. * Callback called when the task is successful
  108372. */
  108373. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  108374. /**
  108375. * Creates a new MeshAssetTask
  108376. * @param name defines the name of the task
  108377. * @param meshesNames defines the list of mesh's names you want to load
  108378. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  108379. * @param sceneFilename defines the filename of the scene to load from
  108380. */
  108381. constructor(
  108382. /**
  108383. * Defines the name of the task
  108384. */
  108385. name: string,
  108386. /**
  108387. * Defines the list of mesh's names you want to load
  108388. */
  108389. meshesNames: any,
  108390. /**
  108391. * Defines the root url to use as a base to load your meshes and associated resources
  108392. */
  108393. rootUrl: string,
  108394. /**
  108395. * Defines the filename of the scene to load from
  108396. */
  108397. sceneFilename: string);
  108398. /**
  108399. * Execute the current task
  108400. * @param scene defines the scene where you want your assets to be loaded
  108401. * @param onSuccess is a callback called when the task is successfully executed
  108402. * @param onError is a callback called if an error occurs
  108403. */
  108404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108405. }
  108406. /**
  108407. * Define a task used by AssetsManager to load text content
  108408. */
  108409. export class TextFileAssetTask extends AbstractAssetTask {
  108410. /**
  108411. * Defines the name of the task
  108412. */
  108413. name: string;
  108414. /**
  108415. * Defines the location of the file to load
  108416. */
  108417. url: string;
  108418. /**
  108419. * Gets the loaded text string
  108420. */
  108421. text: string;
  108422. /**
  108423. * Callback called when the task is successful
  108424. */
  108425. onSuccess: (task: TextFileAssetTask) => void;
  108426. /**
  108427. * Callback called when the task is successful
  108428. */
  108429. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  108430. /**
  108431. * Creates a new TextFileAssetTask object
  108432. * @param name defines the name of the task
  108433. * @param url defines the location of the file to load
  108434. */
  108435. constructor(
  108436. /**
  108437. * Defines the name of the task
  108438. */
  108439. name: string,
  108440. /**
  108441. * Defines the location of the file to load
  108442. */
  108443. url: string);
  108444. /**
  108445. * Execute the current task
  108446. * @param scene defines the scene where you want your assets to be loaded
  108447. * @param onSuccess is a callback called when the task is successfully executed
  108448. * @param onError is a callback called if an error occurs
  108449. */
  108450. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108451. }
  108452. /**
  108453. * Define a task used by AssetsManager to load binary data
  108454. */
  108455. export class BinaryFileAssetTask extends AbstractAssetTask {
  108456. /**
  108457. * Defines the name of the task
  108458. */
  108459. name: string;
  108460. /**
  108461. * Defines the location of the file to load
  108462. */
  108463. url: string;
  108464. /**
  108465. * Gets the lodaded data (as an array buffer)
  108466. */
  108467. data: ArrayBuffer;
  108468. /**
  108469. * Callback called when the task is successful
  108470. */
  108471. onSuccess: (task: BinaryFileAssetTask) => void;
  108472. /**
  108473. * Callback called when the task is successful
  108474. */
  108475. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  108476. /**
  108477. * Creates a new BinaryFileAssetTask object
  108478. * @param name defines the name of the new task
  108479. * @param url defines the location of the file to load
  108480. */
  108481. constructor(
  108482. /**
  108483. * Defines the name of the task
  108484. */
  108485. name: string,
  108486. /**
  108487. * Defines the location of the file to load
  108488. */
  108489. url: string);
  108490. /**
  108491. * Execute the current task
  108492. * @param scene defines the scene where you want your assets to be loaded
  108493. * @param onSuccess is a callback called when the task is successfully executed
  108494. * @param onError is a callback called if an error occurs
  108495. */
  108496. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108497. }
  108498. /**
  108499. * Define a task used by AssetsManager to load images
  108500. */
  108501. export class ImageAssetTask extends AbstractAssetTask {
  108502. /**
  108503. * Defines the name of the task
  108504. */
  108505. name: string;
  108506. /**
  108507. * Defines the location of the image to load
  108508. */
  108509. url: string;
  108510. /**
  108511. * Gets the loaded images
  108512. */
  108513. image: HTMLImageElement;
  108514. /**
  108515. * Callback called when the task is successful
  108516. */
  108517. onSuccess: (task: ImageAssetTask) => void;
  108518. /**
  108519. * Callback called when the task is successful
  108520. */
  108521. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  108522. /**
  108523. * Creates a new ImageAssetTask
  108524. * @param name defines the name of the task
  108525. * @param url defines the location of the image to load
  108526. */
  108527. constructor(
  108528. /**
  108529. * Defines the name of the task
  108530. */
  108531. name: string,
  108532. /**
  108533. * Defines the location of the image to load
  108534. */
  108535. url: string);
  108536. /**
  108537. * Execute the current task
  108538. * @param scene defines the scene where you want your assets to be loaded
  108539. * @param onSuccess is a callback called when the task is successfully executed
  108540. * @param onError is a callback called if an error occurs
  108541. */
  108542. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108543. }
  108544. /**
  108545. * Defines the interface used by texture loading tasks
  108546. */
  108547. export interface ITextureAssetTask<TEX extends BaseTexture> {
  108548. /**
  108549. * Gets the loaded texture
  108550. */
  108551. texture: TEX;
  108552. }
  108553. /**
  108554. * Define a task used by AssetsManager to load 2D textures
  108555. */
  108556. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  108557. /**
  108558. * Defines the name of the task
  108559. */
  108560. name: string;
  108561. /**
  108562. * Defines the location of the file to load
  108563. */
  108564. url: string;
  108565. /**
  108566. * Defines if mipmap should not be generated (default is false)
  108567. */
  108568. noMipmap?: boolean | undefined;
  108569. /**
  108570. * Defines if texture must be inverted on Y axis (default is false)
  108571. */
  108572. invertY?: boolean | undefined;
  108573. /**
  108574. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108575. */
  108576. samplingMode: number;
  108577. /**
  108578. * Gets the loaded texture
  108579. */
  108580. texture: Texture;
  108581. /**
  108582. * Callback called when the task is successful
  108583. */
  108584. onSuccess: (task: TextureAssetTask) => void;
  108585. /**
  108586. * Callback called when the task is successful
  108587. */
  108588. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  108589. /**
  108590. * Creates a new TextureAssetTask object
  108591. * @param name defines the name of the task
  108592. * @param url defines the location of the file to load
  108593. * @param noMipmap defines if mipmap should not be generated (default is false)
  108594. * @param invertY defines if texture must be inverted on Y axis (default is false)
  108595. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108596. */
  108597. constructor(
  108598. /**
  108599. * Defines the name of the task
  108600. */
  108601. name: string,
  108602. /**
  108603. * Defines the location of the file to load
  108604. */
  108605. url: string,
  108606. /**
  108607. * Defines if mipmap should not be generated (default is false)
  108608. */
  108609. noMipmap?: boolean | undefined,
  108610. /**
  108611. * Defines if texture must be inverted on Y axis (default is false)
  108612. */
  108613. invertY?: boolean | undefined,
  108614. /**
  108615. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  108616. */
  108617. samplingMode?: number);
  108618. /**
  108619. * Execute the current task
  108620. * @param scene defines the scene where you want your assets to be loaded
  108621. * @param onSuccess is a callback called when the task is successfully executed
  108622. * @param onError is a callback called if an error occurs
  108623. */
  108624. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108625. }
  108626. /**
  108627. * Define a task used by AssetsManager to load cube textures
  108628. */
  108629. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  108630. /**
  108631. * Defines the name of the task
  108632. */
  108633. name: string;
  108634. /**
  108635. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108636. */
  108637. url: string;
  108638. /**
  108639. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108640. */
  108641. extensions?: string[] | undefined;
  108642. /**
  108643. * Defines if mipmaps should not be generated (default is false)
  108644. */
  108645. noMipmap?: boolean | undefined;
  108646. /**
  108647. * Defines the explicit list of files (undefined by default)
  108648. */
  108649. files?: string[] | undefined;
  108650. /**
  108651. * Gets the loaded texture
  108652. */
  108653. texture: CubeTexture;
  108654. /**
  108655. * Callback called when the task is successful
  108656. */
  108657. onSuccess: (task: CubeTextureAssetTask) => void;
  108658. /**
  108659. * Callback called when the task is successful
  108660. */
  108661. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  108662. /**
  108663. * Creates a new CubeTextureAssetTask
  108664. * @param name defines the name of the task
  108665. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108666. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108667. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108668. * @param files defines the explicit list of files (undefined by default)
  108669. */
  108670. constructor(
  108671. /**
  108672. * Defines the name of the task
  108673. */
  108674. name: string,
  108675. /**
  108676. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  108677. */
  108678. url: string,
  108679. /**
  108680. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  108681. */
  108682. extensions?: string[] | undefined,
  108683. /**
  108684. * Defines if mipmaps should not be generated (default is false)
  108685. */
  108686. noMipmap?: boolean | undefined,
  108687. /**
  108688. * Defines the explicit list of files (undefined by default)
  108689. */
  108690. files?: string[] | undefined);
  108691. /**
  108692. * Execute the current task
  108693. * @param scene defines the scene where you want your assets to be loaded
  108694. * @param onSuccess is a callback called when the task is successfully executed
  108695. * @param onError is a callback called if an error occurs
  108696. */
  108697. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108698. }
  108699. /**
  108700. * Define a task used by AssetsManager to load HDR cube textures
  108701. */
  108702. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  108703. /**
  108704. * Defines the name of the task
  108705. */
  108706. name: string;
  108707. /**
  108708. * Defines the location of the file to load
  108709. */
  108710. url: string;
  108711. /**
  108712. * Defines the desired size (the more it increases the longer the generation will be)
  108713. */
  108714. size: number;
  108715. /**
  108716. * Defines if mipmaps should not be generated (default is false)
  108717. */
  108718. noMipmap: boolean;
  108719. /**
  108720. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108721. */
  108722. generateHarmonics: boolean;
  108723. /**
  108724. * 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)
  108725. */
  108726. gammaSpace: boolean;
  108727. /**
  108728. * Internal Use Only
  108729. */
  108730. reserved: boolean;
  108731. /**
  108732. * Gets the loaded texture
  108733. */
  108734. texture: HDRCubeTexture;
  108735. /**
  108736. * Callback called when the task is successful
  108737. */
  108738. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  108739. /**
  108740. * Callback called when the task is successful
  108741. */
  108742. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  108743. /**
  108744. * Creates a new HDRCubeTextureAssetTask object
  108745. * @param name defines the name of the task
  108746. * @param url defines the location of the file to load
  108747. * @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.
  108748. * @param noMipmap defines if mipmaps should not be generated (default is false)
  108749. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108750. * @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)
  108751. * @param reserved Internal use only
  108752. */
  108753. constructor(
  108754. /**
  108755. * Defines the name of the task
  108756. */
  108757. name: string,
  108758. /**
  108759. * Defines the location of the file to load
  108760. */
  108761. url: string,
  108762. /**
  108763. * Defines the desired size (the more it increases the longer the generation will be)
  108764. */
  108765. size: number,
  108766. /**
  108767. * Defines if mipmaps should not be generated (default is false)
  108768. */
  108769. noMipmap?: boolean,
  108770. /**
  108771. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  108772. */
  108773. generateHarmonics?: boolean,
  108774. /**
  108775. * 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)
  108776. */
  108777. gammaSpace?: boolean,
  108778. /**
  108779. * Internal Use Only
  108780. */
  108781. reserved?: boolean);
  108782. /**
  108783. * Execute the current task
  108784. * @param scene defines the scene where you want your assets to be loaded
  108785. * @param onSuccess is a callback called when the task is successfully executed
  108786. * @param onError is a callback called if an error occurs
  108787. */
  108788. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  108789. }
  108790. /**
  108791. * This class can be used to easily import assets into a scene
  108792. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  108793. */
  108794. export class AssetsManager {
  108795. private _scene;
  108796. private _isLoading;
  108797. protected _tasks: AbstractAssetTask[];
  108798. protected _waitingTasksCount: number;
  108799. protected _totalTasksCount: number;
  108800. /**
  108801. * Callback called when all tasks are processed
  108802. */
  108803. onFinish: (tasks: AbstractAssetTask[]) => void;
  108804. /**
  108805. * Callback called when a task is successful
  108806. */
  108807. onTaskSuccess: (task: AbstractAssetTask) => void;
  108808. /**
  108809. * Callback called when a task had an error
  108810. */
  108811. onTaskError: (task: AbstractAssetTask) => void;
  108812. /**
  108813. * Callback called when a task is done (whatever the result is)
  108814. */
  108815. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  108816. /**
  108817. * Observable called when all tasks are processed
  108818. */
  108819. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  108820. /**
  108821. * Observable called when a task had an error
  108822. */
  108823. onTaskErrorObservable: Observable<AbstractAssetTask>;
  108824. /**
  108825. * Observable called when a task is successful
  108826. */
  108827. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  108828. /**
  108829. * Observable called when a task is done (whatever the result is)
  108830. */
  108831. onProgressObservable: Observable<IAssetsProgressEvent>;
  108832. /**
  108833. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  108834. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108835. */
  108836. useDefaultLoadingScreen: boolean;
  108837. /**
  108838. * Creates a new AssetsManager
  108839. * @param scene defines the scene to work on
  108840. */
  108841. constructor(scene: Scene);
  108842. /**
  108843. * Add a MeshAssetTask to the list of active tasks
  108844. * @param taskName defines the name of the new task
  108845. * @param meshesNames defines the name of meshes to load
  108846. * @param rootUrl defines the root url to use to locate files
  108847. * @param sceneFilename defines the filename of the scene file
  108848. * @returns a new MeshAssetTask object
  108849. */
  108850. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  108851. /**
  108852. * Add a TextFileAssetTask to the list of active tasks
  108853. * @param taskName defines the name of the new task
  108854. * @param url defines the url of the file to load
  108855. * @returns a new TextFileAssetTask object
  108856. */
  108857. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  108858. /**
  108859. * Add a BinaryFileAssetTask to the list of active tasks
  108860. * @param taskName defines the name of the new task
  108861. * @param url defines the url of the file to load
  108862. * @returns a new BinaryFileAssetTask object
  108863. */
  108864. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  108865. /**
  108866. * Add a ImageAssetTask to the list of active tasks
  108867. * @param taskName defines the name of the new task
  108868. * @param url defines the url of the file to load
  108869. * @returns a new ImageAssetTask object
  108870. */
  108871. addImageTask(taskName: string, url: string): ImageAssetTask;
  108872. /**
  108873. * Add a TextureAssetTask to the list of active tasks
  108874. * @param taskName defines the name of the new task
  108875. * @param url defines the url of the file to load
  108876. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108877. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  108878. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108879. * @returns a new TextureAssetTask object
  108880. */
  108881. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  108882. /**
  108883. * Add a CubeTextureAssetTask to the list of active tasks
  108884. * @param taskName defines the name of the new task
  108885. * @param url defines the url of the file to load
  108886. * @param extensions defines the extension to use to load the cube map (can be null)
  108887. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108888. * @param files defines the list of files to load (can be null)
  108889. * @returns a new CubeTextureAssetTask object
  108890. */
  108891. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  108892. /**
  108893. *
  108894. * Add a HDRCubeTextureAssetTask to the list of active tasks
  108895. * @param taskName defines the name of the new task
  108896. * @param url defines the url of the file to load
  108897. * @param size defines the size you want for the cubemap (can be null)
  108898. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  108899. * @param generateHarmonics defines if you want to automatically generate (true by default)
  108900. * @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)
  108901. * @param reserved Internal use only
  108902. * @returns a new HDRCubeTextureAssetTask object
  108903. */
  108904. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  108905. /**
  108906. * Remove a task from the assets manager.
  108907. * @param task the task to remove
  108908. */
  108909. removeTask(task: AbstractAssetTask): void;
  108910. private _decreaseWaitingTasksCount;
  108911. private _runTask;
  108912. /**
  108913. * Reset the AssetsManager and remove all tasks
  108914. * @return the current instance of the AssetsManager
  108915. */
  108916. reset(): AssetsManager;
  108917. /**
  108918. * Start the loading process
  108919. * @return the current instance of the AssetsManager
  108920. */
  108921. load(): AssetsManager;
  108922. }
  108923. }
  108924. declare module BABYLON {
  108925. /**
  108926. * Wrapper class for promise with external resolve and reject.
  108927. */
  108928. export class Deferred<T> {
  108929. /**
  108930. * The promise associated with this deferred object.
  108931. */
  108932. readonly promise: Promise<T>;
  108933. private _resolve;
  108934. private _reject;
  108935. /**
  108936. * The resolve method of the promise associated with this deferred object.
  108937. */
  108938. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  108939. /**
  108940. * The reject method of the promise associated with this deferred object.
  108941. */
  108942. readonly reject: (reason?: any) => void;
  108943. /**
  108944. * Constructor for this deferred object.
  108945. */
  108946. constructor();
  108947. }
  108948. }
  108949. declare module BABYLON {
  108950. /**
  108951. * Class used to help managing file picking and drag'n'drop
  108952. */
  108953. export class FilesInput {
  108954. /**
  108955. * List of files ready to be loaded
  108956. */
  108957. static readonly FilesToLoad: {
  108958. [key: string]: File;
  108959. };
  108960. /**
  108961. * Callback called when a file is processed
  108962. */
  108963. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  108964. private _engine;
  108965. private _currentScene;
  108966. private _sceneLoadedCallback;
  108967. private _progressCallback;
  108968. private _additionalRenderLoopLogicCallback;
  108969. private _textureLoadingCallback;
  108970. private _startingProcessingFilesCallback;
  108971. private _onReloadCallback;
  108972. private _errorCallback;
  108973. private _elementToMonitor;
  108974. private _sceneFileToLoad;
  108975. private _filesToLoad;
  108976. /**
  108977. * Creates a new FilesInput
  108978. * @param engine defines the rendering engine
  108979. * @param scene defines the hosting scene
  108980. * @param sceneLoadedCallback callback called when scene is loaded
  108981. * @param progressCallback callback called to track progress
  108982. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  108983. * @param textureLoadingCallback callback called when a texture is loading
  108984. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  108985. * @param onReloadCallback callback called when a reload is requested
  108986. * @param errorCallback callback call if an error occurs
  108987. */
  108988. 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);
  108989. private _dragEnterHandler;
  108990. private _dragOverHandler;
  108991. private _dropHandler;
  108992. /**
  108993. * Calls this function to listen to drag'n'drop events on a specific DOM element
  108994. * @param elementToMonitor defines the DOM element to track
  108995. */
  108996. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  108997. /**
  108998. * Release all associated resources
  108999. */
  109000. dispose(): void;
  109001. private renderFunction;
  109002. private drag;
  109003. private drop;
  109004. private _traverseFolder;
  109005. private _processFiles;
  109006. /**
  109007. * Load files from a drop event
  109008. * @param event defines the drop event to use as source
  109009. */
  109010. loadFiles(event: any): void;
  109011. private _processReload;
  109012. /**
  109013. * Reload the current scene from the loaded files
  109014. */
  109015. reload(): void;
  109016. }
  109017. }
  109018. declare module BABYLON {
  109019. /**
  109020. * Defines the root class used to create scene optimization to use with SceneOptimizer
  109021. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109022. */
  109023. export class SceneOptimization {
  109024. /**
  109025. * Defines the priority of this optimization (0 by default which means first in the list)
  109026. */
  109027. priority: number;
  109028. /**
  109029. * Gets a string describing the action executed by the current optimization
  109030. * @returns description string
  109031. */
  109032. getDescription(): string;
  109033. /**
  109034. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109035. * @param scene defines the current scene where to apply this optimization
  109036. * @param optimizer defines the current optimizer
  109037. * @returns true if everything that can be done was applied
  109038. */
  109039. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109040. /**
  109041. * Creates the SceneOptimization object
  109042. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109043. * @param desc defines the description associated with the optimization
  109044. */
  109045. constructor(
  109046. /**
  109047. * Defines the priority of this optimization (0 by default which means first in the list)
  109048. */
  109049. priority?: number);
  109050. }
  109051. /**
  109052. * Defines an optimization used to reduce the size of render target textures
  109053. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109054. */
  109055. export class TextureOptimization extends SceneOptimization {
  109056. /**
  109057. * Defines the priority of this optimization (0 by default which means first in the list)
  109058. */
  109059. priority: number;
  109060. /**
  109061. * 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
  109062. */
  109063. maximumSize: number;
  109064. /**
  109065. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109066. */
  109067. step: number;
  109068. /**
  109069. * Gets a string describing the action executed by the current optimization
  109070. * @returns description string
  109071. */
  109072. getDescription(): string;
  109073. /**
  109074. * Creates the TextureOptimization object
  109075. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109076. * @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
  109077. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109078. */
  109079. constructor(
  109080. /**
  109081. * Defines the priority of this optimization (0 by default which means first in the list)
  109082. */
  109083. priority?: number,
  109084. /**
  109085. * 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
  109086. */
  109087. maximumSize?: number,
  109088. /**
  109089. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  109090. */
  109091. step?: number);
  109092. /**
  109093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109094. * @param scene defines the current scene where to apply this optimization
  109095. * @param optimizer defines the current optimizer
  109096. * @returns true if everything that can be done was applied
  109097. */
  109098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109099. }
  109100. /**
  109101. * Defines an optimization used to increase or decrease the rendering resolution
  109102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109103. */
  109104. export class HardwareScalingOptimization extends SceneOptimization {
  109105. /**
  109106. * Defines the priority of this optimization (0 by default which means first in the list)
  109107. */
  109108. priority: number;
  109109. /**
  109110. * Defines the maximum scale to use (2 by default)
  109111. */
  109112. maximumScale: number;
  109113. /**
  109114. * Defines the step to use between two passes (0.5 by default)
  109115. */
  109116. step: number;
  109117. private _currentScale;
  109118. private _directionOffset;
  109119. /**
  109120. * Gets a string describing the action executed by the current optimization
  109121. * @return description string
  109122. */
  109123. getDescription(): string;
  109124. /**
  109125. * Creates the HardwareScalingOptimization object
  109126. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109127. * @param maximumScale defines the maximum scale to use (2 by default)
  109128. * @param step defines the step to use between two passes (0.5 by default)
  109129. */
  109130. constructor(
  109131. /**
  109132. * Defines the priority of this optimization (0 by default which means first in the list)
  109133. */
  109134. priority?: number,
  109135. /**
  109136. * Defines the maximum scale to use (2 by default)
  109137. */
  109138. maximumScale?: number,
  109139. /**
  109140. * Defines the step to use between two passes (0.5 by default)
  109141. */
  109142. step?: number);
  109143. /**
  109144. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109145. * @param scene defines the current scene where to apply this optimization
  109146. * @param optimizer defines the current optimizer
  109147. * @returns true if everything that can be done was applied
  109148. */
  109149. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109150. }
  109151. /**
  109152. * Defines an optimization used to remove shadows
  109153. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109154. */
  109155. export class ShadowsOptimization extends SceneOptimization {
  109156. /**
  109157. * Gets a string describing the action executed by the current optimization
  109158. * @return description string
  109159. */
  109160. getDescription(): string;
  109161. /**
  109162. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109163. * @param scene defines the current scene where to apply this optimization
  109164. * @param optimizer defines the current optimizer
  109165. * @returns true if everything that can be done was applied
  109166. */
  109167. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109168. }
  109169. /**
  109170. * Defines an optimization used to turn post-processes off
  109171. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109172. */
  109173. export class PostProcessesOptimization extends SceneOptimization {
  109174. /**
  109175. * Gets a string describing the action executed by the current optimization
  109176. * @return description string
  109177. */
  109178. getDescription(): string;
  109179. /**
  109180. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109181. * @param scene defines the current scene where to apply this optimization
  109182. * @param optimizer defines the current optimizer
  109183. * @returns true if everything that can be done was applied
  109184. */
  109185. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109186. }
  109187. /**
  109188. * Defines an optimization used to turn lens flares off
  109189. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109190. */
  109191. export class LensFlaresOptimization extends SceneOptimization {
  109192. /**
  109193. * Gets a string describing the action executed by the current optimization
  109194. * @return description string
  109195. */
  109196. getDescription(): string;
  109197. /**
  109198. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109199. * @param scene defines the current scene where to apply this optimization
  109200. * @param optimizer defines the current optimizer
  109201. * @returns true if everything that can be done was applied
  109202. */
  109203. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109204. }
  109205. /**
  109206. * Defines an optimization based on user defined callback.
  109207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109208. */
  109209. export class CustomOptimization extends SceneOptimization {
  109210. /**
  109211. * Callback called to apply the custom optimization.
  109212. */
  109213. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  109214. /**
  109215. * Callback called to get custom description
  109216. */
  109217. onGetDescription: () => string;
  109218. /**
  109219. * Gets a string describing the action executed by the current optimization
  109220. * @returns description string
  109221. */
  109222. getDescription(): string;
  109223. /**
  109224. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109225. * @param scene defines the current scene where to apply this optimization
  109226. * @param optimizer defines the current optimizer
  109227. * @returns true if everything that can be done was applied
  109228. */
  109229. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109230. }
  109231. /**
  109232. * Defines an optimization used to turn particles off
  109233. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109234. */
  109235. export class ParticlesOptimization extends SceneOptimization {
  109236. /**
  109237. * Gets a string describing the action executed by the current optimization
  109238. * @return description string
  109239. */
  109240. getDescription(): string;
  109241. /**
  109242. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109243. * @param scene defines the current scene where to apply this optimization
  109244. * @param optimizer defines the current optimizer
  109245. * @returns true if everything that can be done was applied
  109246. */
  109247. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109248. }
  109249. /**
  109250. * Defines an optimization used to turn render targets off
  109251. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109252. */
  109253. export class RenderTargetsOptimization extends SceneOptimization {
  109254. /**
  109255. * Gets a string describing the action executed by the current optimization
  109256. * @return description string
  109257. */
  109258. getDescription(): string;
  109259. /**
  109260. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109261. * @param scene defines the current scene where to apply this optimization
  109262. * @param optimizer defines the current optimizer
  109263. * @returns true if everything that can be done was applied
  109264. */
  109265. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  109266. }
  109267. /**
  109268. * Defines an optimization used to merge meshes with compatible materials
  109269. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109270. */
  109271. export class MergeMeshesOptimization extends SceneOptimization {
  109272. private static _UpdateSelectionTree;
  109273. /**
  109274. * Gets or sets a boolean which defines if optimization octree has to be updated
  109275. */
  109276. /**
  109277. * Gets or sets a boolean which defines if optimization octree has to be updated
  109278. */
  109279. static UpdateSelectionTree: boolean;
  109280. /**
  109281. * Gets a string describing the action executed by the current optimization
  109282. * @return description string
  109283. */
  109284. getDescription(): string;
  109285. private _canBeMerged;
  109286. /**
  109287. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  109288. * @param scene defines the current scene where to apply this optimization
  109289. * @param optimizer defines the current optimizer
  109290. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  109291. * @returns true if everything that can be done was applied
  109292. */
  109293. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  109294. }
  109295. /**
  109296. * Defines a list of options used by SceneOptimizer
  109297. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109298. */
  109299. export class SceneOptimizerOptions {
  109300. /**
  109301. * Defines the target frame rate to reach (60 by default)
  109302. */
  109303. targetFrameRate: number;
  109304. /**
  109305. * Defines the interval between two checkes (2000ms by default)
  109306. */
  109307. trackerDuration: number;
  109308. /**
  109309. * Gets the list of optimizations to apply
  109310. */
  109311. optimizations: SceneOptimization[];
  109312. /**
  109313. * Creates a new list of options used by SceneOptimizer
  109314. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  109315. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  109316. */
  109317. constructor(
  109318. /**
  109319. * Defines the target frame rate to reach (60 by default)
  109320. */
  109321. targetFrameRate?: number,
  109322. /**
  109323. * Defines the interval between two checkes (2000ms by default)
  109324. */
  109325. trackerDuration?: number);
  109326. /**
  109327. * Add a new optimization
  109328. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  109329. * @returns the current SceneOptimizerOptions
  109330. */
  109331. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  109332. /**
  109333. * Add a new custom optimization
  109334. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  109335. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  109336. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  109337. * @returns the current SceneOptimizerOptions
  109338. */
  109339. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  109340. /**
  109341. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  109342. * @param targetFrameRate defines the target frame rate (60 by default)
  109343. * @returns a SceneOptimizerOptions object
  109344. */
  109345. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109346. /**
  109347. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  109348. * @param targetFrameRate defines the target frame rate (60 by default)
  109349. * @returns a SceneOptimizerOptions object
  109350. */
  109351. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109352. /**
  109353. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  109354. * @param targetFrameRate defines the target frame rate (60 by default)
  109355. * @returns a SceneOptimizerOptions object
  109356. */
  109357. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  109358. }
  109359. /**
  109360. * Class used to run optimizations in order to reach a target frame rate
  109361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  109362. */
  109363. export class SceneOptimizer implements IDisposable {
  109364. private _isRunning;
  109365. private _options;
  109366. private _scene;
  109367. private _currentPriorityLevel;
  109368. private _targetFrameRate;
  109369. private _trackerDuration;
  109370. private _currentFrameRate;
  109371. private _sceneDisposeObserver;
  109372. private _improvementMode;
  109373. /**
  109374. * Defines an observable called when the optimizer reaches the target frame rate
  109375. */
  109376. onSuccessObservable: Observable<SceneOptimizer>;
  109377. /**
  109378. * Defines an observable called when the optimizer enables an optimization
  109379. */
  109380. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  109381. /**
  109382. * Defines an observable called when the optimizer is not able to reach the target frame rate
  109383. */
  109384. onFailureObservable: Observable<SceneOptimizer>;
  109385. /**
  109386. * Gets a boolean indicating if the optimizer is in improvement mode
  109387. */
  109388. readonly isInImprovementMode: boolean;
  109389. /**
  109390. * Gets the current priority level (0 at start)
  109391. */
  109392. readonly currentPriorityLevel: number;
  109393. /**
  109394. * Gets the current frame rate checked by the SceneOptimizer
  109395. */
  109396. readonly currentFrameRate: number;
  109397. /**
  109398. * Gets or sets the current target frame rate (60 by default)
  109399. */
  109400. /**
  109401. * Gets or sets the current target frame rate (60 by default)
  109402. */
  109403. targetFrameRate: number;
  109404. /**
  109405. * Gets or sets the current interval between two checks (every 2000ms by default)
  109406. */
  109407. /**
  109408. * Gets or sets the current interval between two checks (every 2000ms by default)
  109409. */
  109410. trackerDuration: number;
  109411. /**
  109412. * Gets the list of active optimizations
  109413. */
  109414. readonly optimizations: SceneOptimization[];
  109415. /**
  109416. * Creates a new SceneOptimizer
  109417. * @param scene defines the scene to work on
  109418. * @param options defines the options to use with the SceneOptimizer
  109419. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  109420. * @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)
  109421. */
  109422. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  109423. /**
  109424. * Stops the current optimizer
  109425. */
  109426. stop(): void;
  109427. /**
  109428. * Reset the optimizer to initial step (current priority level = 0)
  109429. */
  109430. reset(): void;
  109431. /**
  109432. * Start the optimizer. By default it will try to reach a specific framerate
  109433. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  109434. */
  109435. start(): void;
  109436. private _checkCurrentState;
  109437. /**
  109438. * Release all resources
  109439. */
  109440. dispose(): void;
  109441. /**
  109442. * Helper function to create a SceneOptimizer with one single line of code
  109443. * @param scene defines the scene to work on
  109444. * @param options defines the options to use with the SceneOptimizer
  109445. * @param onSuccess defines a callback to call on success
  109446. * @param onFailure defines a callback to call on failure
  109447. * @returns the new SceneOptimizer object
  109448. */
  109449. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  109450. }
  109451. }
  109452. declare module BABYLON {
  109453. /**
  109454. * Class used to serialize a scene into a string
  109455. */
  109456. export class SceneSerializer {
  109457. /**
  109458. * Clear cache used by a previous serialization
  109459. */
  109460. static ClearCache(): void;
  109461. /**
  109462. * Serialize a scene into a JSON compatible object
  109463. * @param scene defines the scene to serialize
  109464. * @returns a JSON compatible object
  109465. */
  109466. static Serialize(scene: Scene): any;
  109467. /**
  109468. * Serialize a mesh into a JSON compatible object
  109469. * @param toSerialize defines the mesh to serialize
  109470. * @param withParents defines if parents must be serialized as well
  109471. * @param withChildren defines if children must be serialized as well
  109472. * @returns a JSON compatible object
  109473. */
  109474. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  109475. }
  109476. }
  109477. declare module BABYLON {
  109478. /**
  109479. * This represents the different options avilable for the video capture.
  109480. */
  109481. export interface VideoRecorderOptions {
  109482. /** Defines the mime type of the video */
  109483. mimeType: string;
  109484. /** Defines the video the video should be recorded at */
  109485. fps: number;
  109486. /** Defines the chunk size for the recording data */
  109487. recordChunckSize: number;
  109488. }
  109489. /**
  109490. * This can helps recording videos from BabylonJS.
  109491. * This is based on the available WebRTC functionalities of the browser.
  109492. *
  109493. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  109494. */
  109495. export class VideoRecorder {
  109496. private static readonly _defaultOptions;
  109497. /**
  109498. * Returns wehther or not the VideoRecorder is available in your browser.
  109499. * @param engine Defines the Babylon Engine to check the support for
  109500. * @returns true if supported otherwise false
  109501. */
  109502. static IsSupported(engine: Engine): boolean;
  109503. private readonly _options;
  109504. private _canvas;
  109505. private _mediaRecorder;
  109506. private _recordedChunks;
  109507. private _fileName;
  109508. private _resolve;
  109509. private _reject;
  109510. /**
  109511. * True wether a recording is already in progress.
  109512. */
  109513. readonly isRecording: boolean;
  109514. /**
  109515. * Create a new VideoCapture object which can help converting what you see in Babylon to
  109516. * a video file.
  109517. * @param engine Defines the BabylonJS Engine you wish to record
  109518. * @param options Defines options that can be used to customized the capture
  109519. */
  109520. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  109521. /**
  109522. * Stops the current recording before the default capture timeout passed in the startRecording
  109523. * functions.
  109524. */
  109525. stopRecording(): void;
  109526. /**
  109527. * Starts recording the canvas for a max duration specified in parameters.
  109528. * @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.
  109529. * @param maxDuration Defines the maximum recording time in seconds.
  109530. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  109531. * @return a promise callback at the end of the recording with the video data in Blob.
  109532. */
  109533. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  109534. /**
  109535. * Releases internal resources used during the recording.
  109536. */
  109537. dispose(): void;
  109538. private _handleDataAvailable;
  109539. private _handleError;
  109540. private _handleStop;
  109541. }
  109542. }
  109543. declare module BABYLON {
  109544. /**
  109545. * Helper class to push actions to a pool of workers.
  109546. */
  109547. export class WorkerPool implements IDisposable {
  109548. private _workerInfos;
  109549. private _pendingActions;
  109550. /**
  109551. * Constructor
  109552. * @param workers Array of workers to use for actions
  109553. */
  109554. constructor(workers: Array<Worker>);
  109555. /**
  109556. * Terminates all workers and clears any pending actions.
  109557. */
  109558. dispose(): void;
  109559. /**
  109560. * Pushes an action to the worker pool. If all the workers are active, the action will be
  109561. * pended until a worker has completed its action.
  109562. * @param action The action to perform. Call onComplete when the action is complete.
  109563. */
  109564. push(action: (worker: Worker, onComplete: () => void) => void): void;
  109565. private _execute;
  109566. }
  109567. }
  109568. declare module BABYLON {
  109569. /**
  109570. * Class containing a set of static utilities functions for screenshots
  109571. */
  109572. export class ScreenshotTools {
  109573. /**
  109574. * Captures a screenshot of the current rendering
  109575. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109576. * @param engine defines the rendering engine
  109577. * @param camera defines the source camera
  109578. * @param size This parameter can be set to a single number or to an object with the
  109579. * following (optional) properties: precision, width, height. If a single number is passed,
  109580. * it will be used for both width and height. If an object is passed, the screenshot size
  109581. * will be derived from the parameters. The precision property is a multiplier allowing
  109582. * rendering at a higher or lower resolution
  109583. * @param successCallback defines the callback receives a single parameter which contains the
  109584. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109585. * src parameter of an <img> to display it
  109586. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  109587. * Check your browser for supported MIME types
  109588. */
  109589. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  109590. /**
  109591. * Generates an image screenshot from the specified camera.
  109592. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  109593. * @param engine The engine to use for rendering
  109594. * @param camera The camera to use for rendering
  109595. * @param size This parameter can be set to a single number or to an object with the
  109596. * following (optional) properties: precision, width, height. If a single number is passed,
  109597. * it will be used for both width and height. If an object is passed, the screenshot size
  109598. * will be derived from the parameters. The precision property is a multiplier allowing
  109599. * rendering at a higher or lower resolution
  109600. * @param successCallback The callback receives a single parameter which contains the
  109601. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  109602. * src parameter of an <img> to display it
  109603. * @param mimeType The MIME type of the screenshot image (default: image/png).
  109604. * Check your browser for supported MIME types
  109605. * @param samples Texture samples (default: 1)
  109606. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  109607. * @param fileName A name for for the downloaded file.
  109608. */
  109609. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  109610. }
  109611. }
  109612. declare module BABYLON {
  109613. /**
  109614. * A cursor which tracks a point on a path
  109615. */
  109616. export class PathCursor {
  109617. private path;
  109618. /**
  109619. * Stores path cursor callbacks for when an onchange event is triggered
  109620. */
  109621. private _onchange;
  109622. /**
  109623. * The value of the path cursor
  109624. */
  109625. value: number;
  109626. /**
  109627. * The animation array of the path cursor
  109628. */
  109629. animations: Animation[];
  109630. /**
  109631. * Initializes the path cursor
  109632. * @param path The path to track
  109633. */
  109634. constructor(path: Path2);
  109635. /**
  109636. * Gets the cursor point on the path
  109637. * @returns A point on the path cursor at the cursor location
  109638. */
  109639. getPoint(): Vector3;
  109640. /**
  109641. * Moves the cursor ahead by the step amount
  109642. * @param step The amount to move the cursor forward
  109643. * @returns This path cursor
  109644. */
  109645. moveAhead(step?: number): PathCursor;
  109646. /**
  109647. * Moves the cursor behind by the step amount
  109648. * @param step The amount to move the cursor back
  109649. * @returns This path cursor
  109650. */
  109651. moveBack(step?: number): PathCursor;
  109652. /**
  109653. * Moves the cursor by the step amount
  109654. * If the step amount is greater than one, an exception is thrown
  109655. * @param step The amount to move the cursor
  109656. * @returns This path cursor
  109657. */
  109658. move(step: number): PathCursor;
  109659. /**
  109660. * Ensures that the value is limited between zero and one
  109661. * @returns This path cursor
  109662. */
  109663. private ensureLimits;
  109664. /**
  109665. * Runs onchange callbacks on change (used by the animation engine)
  109666. * @returns This path cursor
  109667. */
  109668. private raiseOnChange;
  109669. /**
  109670. * Executes a function on change
  109671. * @param f A path cursor onchange callback
  109672. * @returns This path cursor
  109673. */
  109674. onchange(f: (cursor: PathCursor) => void): PathCursor;
  109675. }
  109676. }
  109677. declare module BABYLON {
  109678. /** @hidden */
  109679. export var blurPixelShader: {
  109680. name: string;
  109681. shader: string;
  109682. };
  109683. }
  109684. declare module BABYLON {
  109685. /** @hidden */
  109686. export var bones300Declaration: {
  109687. name: string;
  109688. shader: string;
  109689. };
  109690. }
  109691. declare module BABYLON {
  109692. /** @hidden */
  109693. export var instances300Declaration: {
  109694. name: string;
  109695. shader: string;
  109696. };
  109697. }
  109698. declare module BABYLON {
  109699. /** @hidden */
  109700. export var pointCloudVertexDeclaration: {
  109701. name: string;
  109702. shader: string;
  109703. };
  109704. }
  109705. // Mixins
  109706. interface Window {
  109707. mozIndexedDB: IDBFactory;
  109708. webkitIndexedDB: IDBFactory;
  109709. msIndexedDB: IDBFactory;
  109710. webkitURL: typeof URL;
  109711. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  109712. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  109713. WebGLRenderingContext: WebGLRenderingContext;
  109714. MSGesture: MSGesture;
  109715. CANNON: any;
  109716. AudioContext: AudioContext;
  109717. webkitAudioContext: AudioContext;
  109718. PointerEvent: any;
  109719. Math: Math;
  109720. Uint8Array: Uint8ArrayConstructor;
  109721. Float32Array: Float32ArrayConstructor;
  109722. mozURL: typeof URL;
  109723. msURL: typeof URL;
  109724. VRFrameData: any; // WebVR, from specs 1.1
  109725. DracoDecoderModule: any;
  109726. setImmediate(handler: (...args: any[]) => void): number;
  109727. }
  109728. interface Document {
  109729. mozCancelFullScreen(): void;
  109730. msCancelFullScreen(): void;
  109731. webkitCancelFullScreen(): void;
  109732. requestPointerLock(): void;
  109733. exitPointerLock(): void;
  109734. mozFullScreen: boolean;
  109735. msIsFullScreen: boolean;
  109736. readonly webkitIsFullScreen: boolean;
  109737. readonly pointerLockElement: Element;
  109738. mozPointerLockElement: HTMLElement;
  109739. msPointerLockElement: HTMLElement;
  109740. webkitPointerLockElement: HTMLElement;
  109741. }
  109742. interface HTMLCanvasElement {
  109743. requestPointerLock(): void;
  109744. msRequestPointerLock?(): void;
  109745. mozRequestPointerLock?(): void;
  109746. webkitRequestPointerLock?(): void;
  109747. /** Track wether a record is in progress */
  109748. isRecording: boolean;
  109749. /** Capture Stream method defined by some browsers */
  109750. captureStream(fps?: number): MediaStream;
  109751. }
  109752. interface CanvasRenderingContext2D {
  109753. msImageSmoothingEnabled: boolean;
  109754. }
  109755. interface MouseEvent {
  109756. mozMovementX: number;
  109757. mozMovementY: number;
  109758. webkitMovementX: number;
  109759. webkitMovementY: number;
  109760. msMovementX: number;
  109761. msMovementY: number;
  109762. }
  109763. interface Navigator {
  109764. mozGetVRDevices: (any: any) => any;
  109765. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109766. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109767. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  109768. webkitGetGamepads(): Gamepad[];
  109769. msGetGamepads(): Gamepad[];
  109770. webkitGamepads(): Gamepad[];
  109771. }
  109772. interface HTMLVideoElement {
  109773. mozSrcObject: any;
  109774. }
  109775. interface Math {
  109776. fround(x: number): number;
  109777. imul(a: number, b: number): number;
  109778. }
  109779. interface WebGLProgram {
  109780. context?: WebGLRenderingContext;
  109781. vertexShader?: WebGLShader;
  109782. fragmentShader?: WebGLShader;
  109783. isParallelCompiled: boolean;
  109784. onCompiled?: () => void;
  109785. }
  109786. interface WebGLRenderingContext {
  109787. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  109788. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  109789. vertexAttribDivisor(index: number, divisor: number): void;
  109790. createVertexArray(): any;
  109791. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  109792. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  109793. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  109794. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  109795. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  109796. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  109797. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  109798. // Queries
  109799. createQuery(): WebGLQuery;
  109800. deleteQuery(query: WebGLQuery): void;
  109801. beginQuery(target: number, query: WebGLQuery): void;
  109802. endQuery(target: number): void;
  109803. getQueryParameter(query: WebGLQuery, pname: number): any;
  109804. getQuery(target: number, pname: number): any;
  109805. MAX_SAMPLES: number;
  109806. RGBA8: number;
  109807. READ_FRAMEBUFFER: number;
  109808. DRAW_FRAMEBUFFER: number;
  109809. UNIFORM_BUFFER: number;
  109810. HALF_FLOAT_OES: number;
  109811. RGBA16F: number;
  109812. RGBA32F: number;
  109813. R32F: number;
  109814. RG32F: number;
  109815. RGB32F: number;
  109816. R16F: number;
  109817. RG16F: number;
  109818. RGB16F: number;
  109819. RED: number;
  109820. RG: number;
  109821. R8: number;
  109822. RG8: number;
  109823. UNSIGNED_INT_24_8: number;
  109824. DEPTH24_STENCIL8: number;
  109825. /* Multiple Render Targets */
  109826. drawBuffers(buffers: number[]): void;
  109827. readBuffer(src: number): void;
  109828. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  109829. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  109830. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  109831. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  109832. // Occlusion Query
  109833. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  109834. ANY_SAMPLES_PASSED: number;
  109835. QUERY_RESULT_AVAILABLE: number;
  109836. QUERY_RESULT: number;
  109837. }
  109838. interface WebGLBuffer {
  109839. references: number;
  109840. capacity: number;
  109841. is32Bits: boolean;
  109842. }
  109843. interface WebGLProgram {
  109844. transformFeedback?: WebGLTransformFeedback | null;
  109845. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  109846. }
  109847. interface EXT_disjoint_timer_query {
  109848. QUERY_COUNTER_BITS_EXT: number;
  109849. TIME_ELAPSED_EXT: number;
  109850. TIMESTAMP_EXT: number;
  109851. GPU_DISJOINT_EXT: number;
  109852. QUERY_RESULT_EXT: number;
  109853. QUERY_RESULT_AVAILABLE_EXT: number;
  109854. queryCounterEXT(query: WebGLQuery, target: number): void;
  109855. createQueryEXT(): WebGLQuery;
  109856. beginQueryEXT(target: number, query: WebGLQuery): void;
  109857. endQueryEXT(target: number): void;
  109858. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  109859. deleteQueryEXT(query: WebGLQuery): void;
  109860. }
  109861. interface WebGLUniformLocation {
  109862. _currentState: any;
  109863. }
  109864. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  109865. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  109866. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  109867. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  109868. interface WebGLRenderingContext {
  109869. readonly RASTERIZER_DISCARD: number;
  109870. readonly DEPTH_COMPONENT24: number;
  109871. readonly TEXTURE_3D: number;
  109872. readonly TEXTURE_2D_ARRAY: number;
  109873. readonly TEXTURE_COMPARE_FUNC: number;
  109874. readonly TEXTURE_COMPARE_MODE: number;
  109875. readonly COMPARE_REF_TO_TEXTURE: number;
  109876. readonly TEXTURE_WRAP_R: number;
  109877. readonly HALF_FLOAT: number;
  109878. readonly RGB8: number;
  109879. readonly RED_INTEGER: number;
  109880. readonly RG_INTEGER: number;
  109881. readonly RGB_INTEGER: number;
  109882. readonly RGBA_INTEGER: number;
  109883. readonly R8_SNORM: number;
  109884. readonly RG8_SNORM: number;
  109885. readonly RGB8_SNORM: number;
  109886. readonly RGBA8_SNORM: number;
  109887. readonly R8I: number;
  109888. readonly RG8I: number;
  109889. readonly RGB8I: number;
  109890. readonly RGBA8I: number;
  109891. readonly R8UI: number;
  109892. readonly RG8UI: number;
  109893. readonly RGB8UI: number;
  109894. readonly RGBA8UI: number;
  109895. readonly R16I: number;
  109896. readonly RG16I: number;
  109897. readonly RGB16I: number;
  109898. readonly RGBA16I: number;
  109899. readonly R16UI: number;
  109900. readonly RG16UI: number;
  109901. readonly RGB16UI: number;
  109902. readonly RGBA16UI: number;
  109903. readonly R32I: number;
  109904. readonly RG32I: number;
  109905. readonly RGB32I: number;
  109906. readonly RGBA32I: number;
  109907. readonly R32UI: number;
  109908. readonly RG32UI: number;
  109909. readonly RGB32UI: number;
  109910. readonly RGBA32UI: number;
  109911. readonly RGB10_A2UI: number;
  109912. readonly R11F_G11F_B10F: number;
  109913. readonly RGB9_E5: number;
  109914. readonly RGB10_A2: number;
  109915. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  109916. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  109917. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  109918. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  109919. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  109920. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  109921. 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;
  109922. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  109923. readonly TRANSFORM_FEEDBACK: number;
  109924. readonly INTERLEAVED_ATTRIBS: number;
  109925. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  109926. createTransformFeedback(): WebGLTransformFeedback;
  109927. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  109928. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  109929. beginTransformFeedback(primitiveMode: number): void;
  109930. endTransformFeedback(): void;
  109931. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  109932. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109933. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109934. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  109935. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  109936. }
  109937. interface ImageBitmap {
  109938. readonly width: number;
  109939. readonly height: number;
  109940. close(): void;
  109941. }
  109942. interface WebGLQuery extends WebGLObject {
  109943. }
  109944. declare var WebGLQuery: {
  109945. prototype: WebGLQuery;
  109946. new(): WebGLQuery;
  109947. };
  109948. interface WebGLSampler extends WebGLObject {
  109949. }
  109950. declare var WebGLSampler: {
  109951. prototype: WebGLSampler;
  109952. new(): WebGLSampler;
  109953. };
  109954. interface WebGLSync extends WebGLObject {
  109955. }
  109956. declare var WebGLSync: {
  109957. prototype: WebGLSync;
  109958. new(): WebGLSync;
  109959. };
  109960. interface WebGLTransformFeedback extends WebGLObject {
  109961. }
  109962. declare var WebGLTransformFeedback: {
  109963. prototype: WebGLTransformFeedback;
  109964. new(): WebGLTransformFeedback;
  109965. };
  109966. interface WebGLVertexArrayObject extends WebGLObject {
  109967. }
  109968. declare var WebGLVertexArrayObject: {
  109969. prototype: WebGLVertexArrayObject;
  109970. new(): WebGLVertexArrayObject;
  109971. };
  109972. // Type definitions for WebVR API
  109973. // Project: https://w3c.github.io/webvr/
  109974. // Definitions by: six a <https://github.com/lostfictions>
  109975. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  109976. interface VRDisplay extends EventTarget {
  109977. /**
  109978. * Dictionary of capabilities describing the VRDisplay.
  109979. */
  109980. readonly capabilities: VRDisplayCapabilities;
  109981. /**
  109982. * z-depth defining the far plane of the eye view frustum
  109983. * enables mapping of values in the render target depth
  109984. * attachment to scene coordinates. Initially set to 10000.0.
  109985. */
  109986. depthFar: number;
  109987. /**
  109988. * z-depth defining the near plane of the eye view frustum
  109989. * enables mapping of values in the render target depth
  109990. * attachment to scene coordinates. Initially set to 0.01.
  109991. */
  109992. depthNear: number;
  109993. /**
  109994. * An identifier for this distinct VRDisplay. Used as an
  109995. * association point in the Gamepad API.
  109996. */
  109997. readonly displayId: number;
  109998. /**
  109999. * A display name, a user-readable name identifying it.
  110000. */
  110001. readonly displayName: string;
  110002. readonly isConnected: boolean;
  110003. readonly isPresenting: boolean;
  110004. /**
  110005. * If this VRDisplay supports room-scale experiences, the optional
  110006. * stage attribute contains details on the room-scale parameters.
  110007. */
  110008. readonly stageParameters: VRStageParameters | null;
  110009. /**
  110010. * Passing the value returned by `requestAnimationFrame` to
  110011. * `cancelAnimationFrame` will unregister the callback.
  110012. * @param handle Define the hanle of the request to cancel
  110013. */
  110014. cancelAnimationFrame(handle: number): void;
  110015. /**
  110016. * Stops presenting to the VRDisplay.
  110017. * @returns a promise to know when it stopped
  110018. */
  110019. exitPresent(): Promise<void>;
  110020. /**
  110021. * Return the current VREyeParameters for the given eye.
  110022. * @param whichEye Define the eye we want the parameter for
  110023. * @returns the eye parameters
  110024. */
  110025. getEyeParameters(whichEye: string): VREyeParameters;
  110026. /**
  110027. * Populates the passed VRFrameData with the information required to render
  110028. * the current frame.
  110029. * @param frameData Define the data structure to populate
  110030. * @returns true if ok otherwise false
  110031. */
  110032. getFrameData(frameData: VRFrameData): boolean;
  110033. /**
  110034. * Get the layers currently being presented.
  110035. * @returns the list of VR layers
  110036. */
  110037. getLayers(): VRLayer[];
  110038. /**
  110039. * Return a VRPose containing the future predicted pose of the VRDisplay
  110040. * when the current frame will be presented. The value returned will not
  110041. * change until JavaScript has returned control to the browser.
  110042. *
  110043. * The VRPose will contain the position, orientation, velocity,
  110044. * and acceleration of each of these properties.
  110045. * @returns the pose object
  110046. */
  110047. getPose(): VRPose;
  110048. /**
  110049. * Return the current instantaneous pose of the VRDisplay, with no
  110050. * prediction applied.
  110051. * @returns the current instantaneous pose
  110052. */
  110053. getImmediatePose(): VRPose;
  110054. /**
  110055. * The callback passed to `requestAnimationFrame` will be called
  110056. * any time a new frame should be rendered. When the VRDisplay is
  110057. * presenting the callback will be called at the native refresh
  110058. * rate of the HMD. When not presenting this function acts
  110059. * identically to how window.requestAnimationFrame acts. Content should
  110060. * make no assumptions of frame rate or vsync behavior as the HMD runs
  110061. * asynchronously from other displays and at differing refresh rates.
  110062. * @param callback Define the eaction to run next frame
  110063. * @returns the request handle it
  110064. */
  110065. requestAnimationFrame(callback: FrameRequestCallback): number;
  110066. /**
  110067. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  110068. * Repeat calls while already presenting will update the VRLayers being displayed.
  110069. * @param layers Define the list of layer to present
  110070. * @returns a promise to know when the request has been fulfilled
  110071. */
  110072. requestPresent(layers: VRLayer[]): Promise<void>;
  110073. /**
  110074. * Reset the pose for this display, treating its current position and
  110075. * orientation as the "origin/zero" values. VRPose.position,
  110076. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  110077. * updated when calling resetPose(). This should be called in only
  110078. * sitting-space experiences.
  110079. */
  110080. resetPose(): void;
  110081. /**
  110082. * The VRLayer provided to the VRDisplay will be captured and presented
  110083. * in the HMD. Calling this function has the same effect on the source
  110084. * canvas as any other operation that uses its source image, and canvases
  110085. * created without preserveDrawingBuffer set to true will be cleared.
  110086. * @param pose Define the pose to submit
  110087. */
  110088. submitFrame(pose?: VRPose): void;
  110089. }
  110090. declare var VRDisplay: {
  110091. prototype: VRDisplay;
  110092. new(): VRDisplay;
  110093. };
  110094. interface VRLayer {
  110095. leftBounds?: number[] | Float32Array | null;
  110096. rightBounds?: number[] | Float32Array | null;
  110097. source?: HTMLCanvasElement | null;
  110098. }
  110099. interface VRDisplayCapabilities {
  110100. readonly canPresent: boolean;
  110101. readonly hasExternalDisplay: boolean;
  110102. readonly hasOrientation: boolean;
  110103. readonly hasPosition: boolean;
  110104. readonly maxLayers: number;
  110105. }
  110106. interface VREyeParameters {
  110107. /** @deprecated */
  110108. readonly fieldOfView: VRFieldOfView;
  110109. readonly offset: Float32Array;
  110110. readonly renderHeight: number;
  110111. readonly renderWidth: number;
  110112. }
  110113. interface VRFieldOfView {
  110114. readonly downDegrees: number;
  110115. readonly leftDegrees: number;
  110116. readonly rightDegrees: number;
  110117. readonly upDegrees: number;
  110118. }
  110119. interface VRFrameData {
  110120. readonly leftProjectionMatrix: Float32Array;
  110121. readonly leftViewMatrix: Float32Array;
  110122. readonly pose: VRPose;
  110123. readonly rightProjectionMatrix: Float32Array;
  110124. readonly rightViewMatrix: Float32Array;
  110125. readonly timestamp: number;
  110126. }
  110127. interface VRPose {
  110128. readonly angularAcceleration: Float32Array | null;
  110129. readonly angularVelocity: Float32Array | null;
  110130. readonly linearAcceleration: Float32Array | null;
  110131. readonly linearVelocity: Float32Array | null;
  110132. readonly orientation: Float32Array | null;
  110133. readonly position: Float32Array | null;
  110134. readonly timestamp: number;
  110135. }
  110136. interface VRStageParameters {
  110137. sittingToStandingTransform?: Float32Array;
  110138. sizeX?: number;
  110139. sizeY?: number;
  110140. }
  110141. interface Navigator {
  110142. getVRDisplays(): Promise<VRDisplay[]>;
  110143. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  110144. }
  110145. interface Window {
  110146. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  110147. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  110148. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  110149. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110150. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  110151. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  110152. }
  110153. interface Gamepad {
  110154. readonly displayId: number;
  110155. }
  110156. interface XRDevice {
  110157. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  110158. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  110159. }
  110160. interface XRSession {
  110161. getInputSources(): Array<any>;
  110162. baseLayer: XRWebGLLayer;
  110163. requestFrameOfReference(type: string): Promise<void>;
  110164. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  110165. end(): Promise<void>;
  110166. requestAnimationFrame: Function;
  110167. addEventListener: Function;
  110168. }
  110169. interface XRSessionCreationOptions {
  110170. outputContext?: WebGLRenderingContext | null;
  110171. immersive?: boolean;
  110172. environmentIntegration?: boolean;
  110173. }
  110174. interface XRLayer {
  110175. getViewport: Function;
  110176. framebufferWidth: number;
  110177. framebufferHeight: number;
  110178. }
  110179. interface XRView {
  110180. projectionMatrix: Float32Array;
  110181. }
  110182. interface XRFrame {
  110183. getDevicePose: Function;
  110184. getInputPose: Function;
  110185. views: Array<XRView>;
  110186. baseLayer: XRLayer;
  110187. }
  110188. interface XRFrameOfReference {
  110189. }
  110190. interface XRWebGLLayer extends XRLayer {
  110191. framebuffer: WebGLFramebuffer;
  110192. }
  110193. declare var XRWebGLLayer: {
  110194. prototype: XRWebGLLayer;
  110195. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  110196. };